perlify_message(s)
FossilOrigin-Name: ac178b0d18e84d776b7f6ce8ffad5ad900a3d5af9dbdfca4a137d2e9ae5bf1f0
This commit is contained in:
parent
ce74e7125e
commit
eac2f53aad
2 changed files with 34 additions and 0 deletions
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "account.h"
|
||||
#include "emoji.h"
|
||||
#include "../config.h"
|
||||
#include "conversations.h"
|
||||
#include "helpers.h"
|
||||
|
@ -331,3 +332,33 @@ AV* perlify_chats(const struct mstdnt_chat* chats, size_t len)
|
|||
return av;
|
||||
}
|
||||
|
||||
HV* perlify_message(const struct mstdnt_message* message)
|
||||
{
|
||||
if (!message) return NULL;
|
||||
|
||||
HV* message_hv = newHV();
|
||||
hvstores_str(message_hv, "account_id", message->account_id);
|
||||
hvstores_str(message_hv, "chat_id", message->chat_id);
|
||||
hvstores_str(message_hv, "id", message->id);
|
||||
hvstores_str(message_hv, "content", message->content);
|
||||
hvstores_int(message_hv, "created_at", message->created_at);
|
||||
hvstores_ref(message_hv, "emojis", perlify_emojis(message->emojis, message->emojis_len));
|
||||
hvstores_int(message_hv, "unread", message->unread);
|
||||
|
||||
return message_hv;
|
||||
}
|
||||
|
||||
AV* perlify_messages(const struct mstdnt_message* messages, size_t len)
|
||||
{
|
||||
if (!(messages && len)) return NULL;
|
||||
AV* av = newAV();
|
||||
av_extend(av, len-1);
|
||||
|
||||
for (int i = 0; i < len; ++i)
|
||||
{
|
||||
av_store(av, i, newRV_inc((SV*)perlify_message(messages + i)));
|
||||
}
|
||||
|
||||
return av;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,4 +52,7 @@ void content_chat_view(PATH_ARGS);
|
|||
AV* perlify_chats(const struct mstdnt_chat* chats, size_t chats_len);
|
||||
HV* perlify_chat(const struct mstdnt_chat* chat);
|
||||
|
||||
AV* perlify_messages(const struct mstdnt_message* messages, size_t messages_len);
|
||||
HV* perlify_message(const struct mstdnt_message* message);
|
||||
|
||||
#endif // LISTS_H
|
||||
|
|
Loading…
Reference in a new issue