Skip to content

Commit

Permalink
Add support for invite-notify
Browse files Browse the repository at this point in the history
https://ircv3.net/specs/extensions/invite-notify

Also remove the comments about IRCv3.1 / IRCv3.2, because IRCv3 does not
classify its specs this way anymore.
  • Loading branch information
progval committed Mar 30, 2022
1 parent 4449ae7 commit 2833d5e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion doc/support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ batch No
chghost No
echo-message No
extended-join No
invite-notify No
invite-notify Yes
Monitor No
multi-prefix No
SASL v3.1 PLAIN,ECDSA-NIST256P-CHALLENGE
Expand Down
24 changes: 17 additions & 7 deletions src/core/app_irc_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,18 +929,28 @@ static void irc_event_invite(SircSession *sirc, const char *event,
g_return_if_fail(srn_server_is_valid(srv));
srv_user = srn_server_add_and_get_user(srv, origin);
g_return_if_fail(srv_user);
chat = srn_server_add_and_get_chat(srv, origin);
g_return_if_fail(chat);

// Send to room chat if already open
chat = srn_server_get_chat(srv, chan);

// Otherwise, fall back to creating a chat with the sender
if (!chat) {
chat = srn_server_add_and_get_chat(srv, origin);
g_return_if_fail(chat);
}

chat_user = srn_chat_add_and_get_user(chat, srv_user);
g_return_if_fail(chat_user);

if (!sirc_target_equal(srv->user->nick, nick)){
WARN_FR("Received a invite message to %s", nick);
g_return_if_reached();
if (sirc_target_equal(srv->user->nick, nick)){
srn_chat_add_misc_message_with_user_fmt(chat, chat_user, context,
_("%1$s invites you into %2$s"), origin, chan);
}
else {
srn_chat_add_misc_message_with_user_fmt(chat, chat_user, context,
_("%1$s invites %3$s into %2$s"), origin, chan, nick);
}

srn_chat_add_misc_message_with_user_fmt(chat, chat_user, context,
_("%1$s invites you into %2$s"), origin, chan);
}

static void irc_event_ctcp_req(SircSession *sirc, const char *event,
Expand Down
8 changes: 5 additions & 3 deletions src/core/server_cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static ServerCapSupport supported_caps[] = {
// .offset = offsetof(EnabledCap, identify_msg),
// },

// /* IRCv3.1 */
// /* IRCv3 */
// {
// .name = "multi-prefix",
// .offset = offsetof(EnabledCap, mulit_prefix),
Expand All @@ -78,8 +78,6 @@ static ServerCapSupport supported_caps[] = {
.is_support = sasl_is_support,
.on_enable = sasl_on_enable,
},

// /* IRCv3.2 */
{
.name = "message-tags",
.offset = offsetof(EnabledCap, message_tags),
Expand All @@ -101,6 +99,10 @@ static ServerCapSupport supported_caps[] = {
// .name = "chghost",
// .offset = offsetof(EnabledCap, chghost),
// },
{
.name = "invite-notify",
.offset = offsetof(EnabledCap, invite_notify),
},

// /* ZNC */
// {
Expand Down
5 changes: 2 additions & 3 deletions src/inc/core/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,19 @@ struct _SrnServerConfig {
};

struct _EnabledCap {
// Version 3.1
// IRCv3
bool identify_msg;
bool mulit_prefix;
bool away_notify;
bool account_notify;
bool extended_join;
bool sasl;

// Version 3.2
bool message_tags;
bool server_time;
bool userhost_in_names;
bool cap_notify;
bool chghost;
bool invite_notify;

// Vendor-Specific
bool znc_server_time_iso;
Expand Down

0 comments on commit 2833d5e

Please sign in to comment.