Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for invite-notify #359

Merged
merged 2 commits into from
Apr 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 16 additions & 7 deletions src/core/app_irc_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -929,18 +929,27 @@ 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);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to "try get a SrnChat, otherwise add one", this is what srn_server_add_and_get_chat do.

Copy link
Member Author

@progval progval Apr 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly. This code gets the channel chat if it already exists, and add/gets a chat with the origin otherwise

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I get it.

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