[MOD] Add CHANGELOG, start PEPing

This commit is contained in:
LDA 2024-09-18 07:58:21 +02:00
commit f666f39b7c
7 changed files with 62 additions and 22 deletions

View file

@ -18,10 +18,16 @@ of Parsee. May occasionally deadlock.
*NONE* *NONE*
### v0.1.1[star-of-hope] <X/X/XXXX> ### v0.1.1[star-of-hope] <X/X/XXXX>
Fixes some media metadata things. Fixes some media metadata things, and replaces the build
system of Parsee.
#### New things #### New things
*NONE* *NONE*
#### Bugfixes #### Bugfixes
- Adds more information to media events so that clients can behave. - Adds more information to media events so that clients can behave.
- Fixes issues where SIGPIPE can actually just kill Parsee.
- Allows MbedTLS through a specific Cytoplasm patch.
- "Lone" XMPP messages no longer render weirdly on Element Android's
weird rendering.
#### Deprecated features #### Deprecated features
*NONE* - The old `build.c` and `Makefile`s used for building are removed,
and replaced by the `configure.c` C file(/script via TCC).

View file

@ -68,6 +68,8 @@ Currently, the main sources of documentation are the Ayadocs(for headers) and th
(see `etc/man`) (see `etc/man`)
## TODOS before 1.0 rolls around ## TODOS before 1.0 rolls around
- PROPER FUCKING AVATARS
XMPP->Matrix is decent, Matrix->XMPP is effectiveny not done
- Add [libomemo](https://github.com/gkdr/libomemo) or something as an optional dependency. - Add [libomemo](https://github.com/gkdr/libomemo) or something as an optional dependency.
- It depends on more stuff anyways, and I don't want to weigh down the - It depends on more stuff anyways, and I don't want to weigh down the
dependency list of Parsee for that. dependency list of Parsee for that.
@ -79,8 +81,6 @@ Currently, the main sources of documentation are the Ayadocs(for headers) and th
extension packagers may integrate properly. extension packagers may integrate properly.
- Get rid of the '?'-syntax and use another invalid Matrix char/valid XMPP char - Get rid of the '?'-syntax and use another invalid Matrix char/valid XMPP char
('$'?) for escaped? ('$'?) for escaped?
- PROPER FUCKING AVATARS
XMPP->Matrix is decent, Matrix->XMPP is effectiveny not done
- Consider making room/MUC admins/owners be able to plumb instead of it being - Consider making room/MUC admins/owners be able to plumb instead of it being
restricted to Parsee admins, with permission from MUC owners, too restricted to Parsee admins, with permission from MUC owners, too
- Limiting to admins may be a way to "control" consent for both, but this is - Limiting to admins may be a way to "control" consent for both, but this is
@ -91,7 +91,6 @@ restricted to Parsee admins, with permission from MUC owners, too
support XMPP->Matrix bridging. support XMPP->Matrix bridging.
- Manage MUC DMs in a reasonable manner. Thanks `@freeoffers4u:matrix.org` for being - Manage MUC DMs in a reasonable manner. Thanks `@freeoffers4u:matrix.org` for being
a fucking annoyance and DMing an old Parsee semi-anon user for no clear reason. a fucking annoyance and DMing an old Parsee semi-anon user for no clear reason.
- Deadlocks. It's always deadlocks.
## DONATING/CONTRIBUTING ## DONATING/CONTRIBUTING
If you know things about XMPP or Matrix, yet aren't familiar with C99, or just If you know things about XMPP or Matrix, yet aren't familiar with C99, or just

View file

@ -286,16 +286,6 @@ SetStanzaXParsee(StanzaBuilder *builder, HashMap *e)
XMLAddChild(parsee_link, link_elem); XMLAddChild(parsee_link, link_elem);
XMLAddChild(parsee, parsee_link); XMLAddChild(parsee, parsee_link);
parsee_text = XMLCreateTag("zayds-note");
text_elem = XMLCreateText("\"LDA HANG YOURSELF\" - Zayd");
XMLAddChild(parsee_text, text_elem);
XMLAddChild(parsee, parsee_text);
parsee_text = XMLCreateTag("mcnebs-note");
text_elem = XMLCreateText("LDA will never beat the allegations");
XMLAddChild(parsee_text, text_elem);
XMLAddChild(parsee, parsee_text);
if (event_id) if (event_id)
{ {
parsee_event = XMLCreateTag("event-id"); parsee_event = XMLCreateTag("event-id");

View file

@ -10,6 +10,8 @@
#include <XMPP.h> #include <XMPP.h>
#include <XML.h> #include <XML.h>
#define PUBSUB "http://jabber.org/protocol/pubsub"
XMLElement * XMLElement *
CreatePubsubRequest(char *from, char *to, char *node) CreatePubsubRequest(char *from, char *to, char *node)
{ {
@ -22,7 +24,7 @@ CreatePubsubRequest(char *from, char *to, char *node)
XMLAddAttr(iq_req, "type", "set"); XMLAddAttr(iq_req, "type", "set");
pubsub = XMLCreateTag("pubsub"); pubsub = XMLCreateTag("pubsub");
XMLAddAttr(pubsub, "xmlns", "http://jabber.org/protocol/pubsub"); XMLAddAttr(pubsub, "xmlns", PUBSUB);
XMLAddChild(iq_req, pubsub); XMLAddChild(iq_req, pubsub);
sub = XMLCreateTag("subscribe"); sub = XMLCreateTag("subscribe");
@ -34,12 +36,40 @@ CreatePubsubRequest(char *from, char *to, char *node)
return iq_req; return iq_req;
} }
static bool
IsPubsubRequest(XMLElement *stanza)
{
char *type = HashMapGet(stanza ? stanza->attrs : NULL, "type");
XMLElement *pubsub, *subscribe;
if (!stanza)
{
return false;
}
if (!StrEquals(stanza->name, "iq") ||
!StrEquals(type, "set"))
{
return false;
}
pubsub = XMLookForTKV(stanza, "pubsub", "xmlns", PUBSUB);
if (!pubsub)
{
return false;
}
return XMLookForUnique(pubsub, "subscribe");
}
struct PEPManager { struct PEPManager {
pthread_mutex_t lock; pthread_mutex_t lock;
ParseeData *data; ParseeData *data;
HashMap *node_table; HashMap *node_table;
HashMap *followers;
void *cookie; void *cookie;
}; };
@ -56,6 +86,7 @@ CreatePEPManager(ParseeData *data, void *cookie)
ret->cookie = cookie; ret->cookie = cookie;
ret->data = data; ret->data = data;
ret->node_table = HashMapCreate(); ret->node_table = HashMapCreate();
ret->followers = HashMapCreate();
pthread_mutex_init(&ret->lock, NULL); pthread_mutex_init(&ret->lock, NULL);
return ret; return ret;
@ -91,9 +122,9 @@ PEPManagerHandleEvent(PEPManager *manager, XMLElement *stanza)
{ {
return false; return false;
} }
#define PEP_NS "http://jabber.org/protocol/pubsub"
if (!(ps = XMLookForTKV(stanza, "pubsub", "xmlns", PEP_NS)) && if (!(ps = XMLookForTKV(stanza, "pubsub", "xmlns", PUBSUB)) &&
!(ev = XMLookForTKV(stanza, "event", "xmlns", PEP_NS "#event"))) !(ev = XMLookForTKV(stanza, "event", "xmlns", PUBSUB "#event")))
{ {
return false; return false;
} }
@ -135,6 +166,11 @@ PEPManagerHandle(PEPManager *manager, XMLElement *stanza)
} }
/* Check if it is a PEP stanza */ /* Check if it is a PEP stanza */
if (IsPubsubRequest(stanza))
{
Log(LOG_DEBUG, "UNIMPLEMENTED PUBSUB SUBSCRIPTION");
/* TODO */
}
if (PEPManagerHandleEvent(manager, stanza)) if (PEPManagerHandleEvent(manager, stanza))
{ {
return true; return true;
@ -158,5 +194,8 @@ DestroyPEPManager(PEPManager *manager)
Free(val); Free(val);
} }
HashMapFree(manager->node_table); HashMapFree(manager->node_table);
HashMapFree(manager->followers);
Free(manager); Free(manager);
} }

View file

@ -68,7 +68,7 @@ XMPPDispatcher(void *argp)
if (StrEquals(stanza->name, "presence")) if (StrEquals(stanza->name, "presence"))
{ {
PresenceStanza(args, stanza); PresenceStanza(args, stanza, thread);
XMLFreeElement(stanza); XMLFreeElement(stanza);
continue; continue;
} }

View file

@ -57,7 +57,7 @@ GuessStatus(XMLElement *stanza)
return USER_STATUS_ONLINE; return USER_STATUS_ONLINE;
} }
void void
PresenceStanza(ParseeData *args, XMLElement *stanza) PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr)
{ {
#define MUC_USER_NS "http://jabber.org/protocol/muc#user" #define MUC_USER_NS "http://jabber.org/protocol/muc#user"
XMLElement *user_info; XMLElement *user_info;
@ -66,6 +66,11 @@ PresenceStanza(ParseeData *args, XMLElement *stanza)
char *oid = HashMapGet(stanza->attrs, "from"); char *oid = HashMapGet(stanza->attrs, "from");
if (PEPManagerHandle(thr->info->pep_manager, stanza))
{
return;
}
if (ServerHasXEP421(args, oid)) if (ServerHasXEP421(args, oid))
{ {
XMLElement *occupant = XMLookForTKV( XMLElement *occupant = XMLookForTKV(

View file

@ -78,7 +78,7 @@ XMLElement * CreatePubsubRequest(char *from, char *to, char *node);
bool MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr); bool MessageStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr);
void IQStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr); void IQStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr);
void PresenceStanza(ParseeData *args, XMLElement *stanza); void PresenceStanza(ParseeData *args, XMLElement *stanza, XMPPThread *thr);
bool ServerHasXEP421(ParseeData *data, char *from); bool ServerHasXEP421(ParseeData *data, char *from);
@ -89,6 +89,7 @@ PEPManager * CreatePEPManager(ParseeData *data, void *cookie);
void * PEPManagerCookie(PEPManager *manager); void * PEPManagerCookie(PEPManager *manager);
void PEPManagerAddEvent(PEPManager *manager, char *node, PEPEvent event); void PEPManagerAddEvent(PEPManager *manager, char *node, PEPEvent event);
bool PEPManagerHandle(PEPManager *manager, XMLElement *stanza); bool PEPManagerHandle(PEPManager *manager, XMLElement *stanza);
void PEPManagerBroadcast(PEPManager *manager, char *as, XMLElement *item);
void DestroyPEPManager(PEPManager *manager); void DestroyPEPManager(PEPManager *manager);
/* PEP callbacks for the handler */ /* PEP callbacks for the handler */