mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 19:45:11 +00:00
[FIX/ADD] Fix deadlock and DMs.
This commit is contained in:
parent
c5df636bdb
commit
59d5ad6780
7 changed files with 57 additions and 34 deletions
|
|
@ -26,19 +26,22 @@ ParseeMemberHandler(ParseeData *data, HashMap *event)
|
|||
DbRef *ref;
|
||||
HashMap *json;
|
||||
char *jid;
|
||||
bool direct = GrabBoolean(event, 2, "content", "is_direct");
|
||||
bool bot = !strncmp(sender + 1, local, strlen(local));
|
||||
ASJoin(conf, room_id, state_key);
|
||||
|
||||
jid = ParseeDecodeLocalJID(conf, state_key);
|
||||
|
||||
ref = DbCreate(data->db, 3, "rooms", room_id, "data");
|
||||
json = DbJson(ref);
|
||||
HashMapSet(json, "is_direct", JsonValueBoolean(!bot));
|
||||
HashMapSet(json, "xmpp_user", JsonValueString(jid));
|
||||
DbUnlock(data->db, ref);
|
||||
if (direct && !bot)
|
||||
{
|
||||
ref = DbCreate(data->db, 3, "rooms", room_id, "data");
|
||||
json = DbJson(ref);
|
||||
HashMapSet(json, "is_direct", JsonValueBoolean(direct && !bot));
|
||||
HashMapSet(json, "xmpp_user", JsonValueString(jid));
|
||||
DbUnlock(data->db, ref);
|
||||
ParseePushDMRoom(data, sender, jid, room_id);
|
||||
}
|
||||
|
||||
ParseePushDMRoom(data, sender, jid, room_id);
|
||||
/* Pretend everything is a dm, ignoring is_direct */
|
||||
if (jid)
|
||||
{
|
||||
Free(jid);
|
||||
|
|
@ -170,7 +173,9 @@ ParseeMessageHandler(ParseeData *data, HashMap *event)
|
|||
char *user = GrabString(json, 1, "xmpp_user");
|
||||
char *local = ParseeEncodeMXID(sender);
|
||||
|
||||
XMPPSendPlain(jabber, local, user, body, NULL, NULL, NULL, ev_id, NULL, NULL);
|
||||
Log(LOG_INFO," Sending to %s as %s", user, local);
|
||||
|
||||
XMPPSendPlain(jabber, local, user, body, "chat", NULL, NULL, ev_id, NULL, NULL);
|
||||
|
||||
DbUnlock(data->db, ref);
|
||||
Free(chat_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue