-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cap_message_tags: copy client tags only
- Loading branch information
1 parent
cd36b6a
commit 5c7df7b
Showing
3 changed files
with
84 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Solanum: a slightly advanced ircd | ||
* cap_allow_list.c: implement the message-tags IRCv3 specification | ||
* | ||
* Copyright (c) 2022 Ryan Lahfa <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice is present in all copies. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | ||
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "stdinc.h" | ||
#include "modules.h" | ||
#include "hook.h" | ||
#include "client.h" | ||
#include "ircd.h" | ||
#include "send.h" | ||
#include "s_conf.h" | ||
#include "s_user.h" | ||
#include "s_serv.h" | ||
#include "numeric.h" | ||
#include "chmode.h" | ||
#include "inline/stringops.h" | ||
|
||
static const char cap_message_tags_desc[] = | ||
"Propagate message tags"; | ||
|
||
static void cap_message_tags_process(void *); | ||
unsigned int CLICAP_MESSAGE_TAGS = 0; | ||
|
||
mapi_hfn_list_av1 cap_message_tags_hfnlist[] = { | ||
{ "outbound_msgbuf", cap_message_tags_process }, | ||
{ NULL, NULL } | ||
}; | ||
mapi_cap_list_av2 cap_message_tags_cap_list[] = { | ||
{ MAPI_CAP_CLIENT, "message-tags", NULL, &CLICAP_MESSAGE_TAGS }, | ||
{ 0, NULL, NULL, NULL }, | ||
}; | ||
|
||
static int | ||
_modinit(void) | ||
{ | ||
return 0; | ||
} | ||
|
||
static void | ||
_moddeinit(void) | ||
{ | ||
} | ||
|
||
static void | ||
cap_message_tags_process(void *data_) | ||
{ | ||
hook_data *data = data_; | ||
struct MsgBuf *msgbuf = data->arg1; | ||
|
||
if (incoming_client != NULL) { | ||
size_t n_tags = incoming_message->n_tags; | ||
for (size_t index = 0 ; index < n_tags ; index++) { | ||
if (incoming_message->tags[index].key[0] == '+') { | ||
msgbuf_append_tag(msgbuf, | ||
incoming_message->tags[index].key, | ||
incoming_message->tags[index].value, | ||
CLICAP_MESSAGE_TAGS); // TODO: client only capa neg | ||
} | ||
} | ||
} | ||
} | ||
|
||
DECLARE_MODULE_AV2(cap_message_tags, NULL, NULL, NULL, NULL, cap_message_tags_hfnlist, cap_message_tags_cap_list, NULL, cap_message_tags_desc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters