mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 12:15:12 +00:00
[MOD] Separate the unlink in another function
This commit is contained in:
parent
749df0feb1
commit
e7ba1fa48d
3 changed files with 48 additions and 15 deletions
39
src/Parsee/Chats.c
Normal file
39
src/Parsee/Chats.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include <Parsee.h>
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Json.h>
|
||||
|
||||
void
|
||||
ParseeUnlinkRoom(ParseeData *data, char *chat_id)
|
||||
{
|
||||
char *muc, *room;
|
||||
DbRef *ref;
|
||||
if (!data || !chat_id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
muc = ParseeGetMUCID(data, chat_id);
|
||||
room = ParseeGetRoomID(data, chat_id);
|
||||
if (!muc || !room)
|
||||
{
|
||||
Free(muc);
|
||||
Free(room);
|
||||
return;
|
||||
}
|
||||
|
||||
ref = DbLock(data->db, 1, "chats");
|
||||
JsonValueFree(HashMapDelete(
|
||||
GrabObject(DbJson(ref), 1, "rooms"),
|
||||
room
|
||||
));
|
||||
JsonValueFree(HashMapDelete(
|
||||
GrabObject(DbJson(ref), 1, "mucs"),
|
||||
muc
|
||||
));
|
||||
DbUnlock(data->db, ref);
|
||||
DbDelete(data->db, 2, "chats", chat_id);
|
||||
|
||||
Free(muc);
|
||||
Free(room);
|
||||
}
|
||||
|
|
@ -216,20 +216,8 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
(IsStatus(301) || IsStatus(307)))
|
||||
{
|
||||
char *chat_id = ParseeGetFromRoomID(args, room);
|
||||
char *muc = ParseeTrimJID(oid);
|
||||
DbRef *ref;
|
||||
|
||||
ref = DbLock(args->db, 1, "chats");
|
||||
JsonValueFree(HashMapDelete(
|
||||
GrabObject(DbJson(ref), 1, "rooms"),
|
||||
room
|
||||
));
|
||||
JsonValueFree(HashMapDelete(
|
||||
GrabObject(DbJson(ref), 1, "mucs"),
|
||||
muc
|
||||
));
|
||||
DbUnlock(args->db, ref);
|
||||
DbDelete(args->db, 2, "chats", chat_id);
|
||||
ParseeUnlinkRoom(args, chat_id);
|
||||
|
||||
Free(ASSend(
|
||||
args->config, room, parsee,
|
||||
|
|
@ -238,7 +226,6 @@ PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
|
|||
));
|
||||
ASLeave(args->config, room, parsee);
|
||||
Free(chat_id);
|
||||
Free(muc);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -344,7 +344,8 @@ extern bool ParseeManageBan(ParseeData *, char *user, char *room);
|
|||
extern bool ParseeVerifyDMStanza(ParseeData *data, char *room_id, char *id);
|
||||
|
||||
|
||||
/** Checks if a Matrix/XMPP user is considered as "administrator" by Parsee.
|
||||
/** Checks if a Matrix/XMPP user is considered as "administrator" by
|
||||
* Parsee.
|
||||
* ----------------------
|
||||
* Returns: (whenever the user is an admin)
|
||||
* Modifies: NOTHING */
|
||||
|
|
@ -411,4 +412,10 @@ extern char * ParseeHMAC(char *key, uint8_t *msg, size_t msglen);
|
|||
* Returns: NOTHING */
|
||||
extern void ParseeBroadcastStanza(ParseeData *data, char *from, XMLElement *s);
|
||||
|
||||
/** Destroys the mapping between a MUC and a room from a chat ID.
|
||||
* ----------------
|
||||
* Modifies: the DB's room mappings
|
||||
* Returns: NOTHING */
|
||||
extern void ParseeUnlinkRoom(ParseeData *data, char *chat_id);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue