Implement the solanum.chat/identify-msg vendor cap

This commit is contained in:
Ed Kellett 2020-10-16 00:24:46 +01:00
parent a6f63a829e
commit 94613c78b6
7 changed files with 102 additions and 1 deletions

View file

@ -78,6 +78,7 @@ extension_LTLIBRARIES = \
spy_stats_p_notice.la \
spy_trace_notice.la \
drain.la \
identify_msg.la \
example_module.la
if HAVE_HYPERSCAN

29
extensions/identify_msg.c Normal file
View file

@ -0,0 +1,29 @@
#include <stdinc.h>
#include <modules.h>
#include <msgbuf.h>
static const char identify_msg_desc[] = "Provides the solanum.chat/identify-msg client capability";
static void identmsg_outbound(void *);
unsigned int CLICAP_IDENTIFY_MSG = 0;
mapi_cap_list_av2 identmsg_cap_list[] = {
{ MAPI_CAP_CLIENT, "solanum.chat/identify-msg", NULL, &CLICAP_IDENTIFY_MSG },
{ 0, NULL, NULL, NULL }
};
static mapi_hfn_list_av1 identmsg_hfnlist[] = {
{ "outbound_msgbuf", identmsg_outbound },
{ NULL, NULL }
};
static void identmsg_outbound(void *data_)
{
hook_data *data = data_;
struct MsgBuf *msgbuf = data->arg1;
if (IsIdentified(data->client))
msgbuf_append_tag(msgbuf, "solanum.chat/identified", NULL, CLICAP_IDENTIFY_MSG);
}
DECLARE_MODULE_AV2(identify_msg, NULL, NULL, NULL, NULL, identmsg_hfnlist, identmsg_cap_list, NULL, identify_msg_desc);