mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:25:11 +00:00
[ADD/MOD] XMPP->Matrix media bridge, small cleanup
This commit is contained in:
parent
4de7227ee7
commit
42d69226f0
14 changed files with 327 additions and 54 deletions
53
src/Events.c
53
src/Events.c
|
|
@ -1,5 +1,10 @@
|
|||
#include <Matrix.h>
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
HashMap *
|
||||
MatrixCreateNotice(char *body)
|
||||
{
|
||||
|
|
@ -61,3 +66,51 @@ MatrixCreateNickChange(char *nick)
|
|||
|
||||
return map;
|
||||
}
|
||||
HashMap *
|
||||
MatrixCreateMedia(char *mxc, char *body, char *mime)
|
||||
{
|
||||
HashMap *map;
|
||||
char *mime_type = NULL, *matrix_type = NULL;
|
||||
if (!mxc || !body)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
matrix_type = "m.file";
|
||||
if (mime)
|
||||
{
|
||||
size_t i;
|
||||
mime_type = StrDuplicate(mime);
|
||||
for (i = 0; i < strlen(mime); i++)
|
||||
{
|
||||
if (mime_type[i] == '/')
|
||||
{
|
||||
mime_type[i] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (StrEquals(mime_type, "image"))
|
||||
{
|
||||
matrix_type = "m.image";
|
||||
}
|
||||
else if (StrEquals(mime_type, "video"))
|
||||
{
|
||||
matrix_type = "m.video";
|
||||
}
|
||||
else if (StrEquals(mime_type, "audio"))
|
||||
{
|
||||
matrix_type = "m.audio";
|
||||
}
|
||||
|
||||
Free(mime_type);
|
||||
}
|
||||
|
||||
map = HashMapCreate();
|
||||
HashMapSet(map, "msgtype", JsonValueString(matrix_type));
|
||||
HashMapSet(map, "mimetype", JsonValueString(mime));
|
||||
HashMapSet(map, "body", JsonValueString(body));
|
||||
HashMapSet(map, "url", JsonValueString(mxc));
|
||||
|
||||
return map;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue