mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Use direct messages instead of MUC-PMs for non-anon MUCs
In https://github.com/profanity-im/profanity/issues/1070 we have: `OMEMO encryption for MUC PM (OMEMO MUCs are not anonymous, so we should start a regular 1:1 in this case instead of MUC PM. A discussion started to make this a general feature #1531)` In https://github.com/profanity-im/profanity/issues/1531 we have the general issue to start regular 1:1 messages instead of MUC PMs if the room is non-anonymous. This is like suggested in https://docs.modernxmpp.org/client/groupchat/.
This commit is contained in:
parent
5906c4ade1
commit
722d07adf6
@ -2108,53 +2108,9 @@ cmd_who(ProfWin* window, const char* const command, gchar** args)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_msg(ProfWin* window, const char* const command, gchar** args)
|
||||
static void
|
||||
_cmd_msg_chatwin(const char* const barejid, const char* const msg)
|
||||
{
|
||||
char* usr = args[0];
|
||||
char* msg = args[1];
|
||||
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currently connected.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// send private message when in MUC room
|
||||
if (window->type == WIN_MUC) {
|
||||
ProfMucWin* mucwin = (ProfMucWin*)window;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
if (muc_roster_contains_nick(mucwin->roomjid, usr)) {
|
||||
GString* full_jid = g_string_new(mucwin->roomjid);
|
||||
g_string_append(full_jid, "/");
|
||||
g_string_append(full_jid, usr);
|
||||
|
||||
ProfPrivateWin* privwin = wins_get_private(full_jid->str);
|
||||
if (!privwin) {
|
||||
privwin = (ProfPrivateWin*)wins_new_private(full_jid->str);
|
||||
}
|
||||
ui_focus_win((ProfWin*)privwin);
|
||||
|
||||
if (msg) {
|
||||
cl_ev_send_priv_msg(privwin, msg, NULL);
|
||||
}
|
||||
|
||||
g_string_free(full_jid, TRUE);
|
||||
|
||||
} else {
|
||||
win_println(window, THEME_DEFAULT, "-", "No such participant \"%s\" in room.", usr);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
// send chat message
|
||||
} else {
|
||||
char* barejid = roster_barejid_from_name(usr);
|
||||
if (barejid == NULL) {
|
||||
barejid = usr;
|
||||
}
|
||||
|
||||
ProfChatWin* chatwin = wins_get_chat(barejid);
|
||||
if (!chatwin) {
|
||||
// NOTE: This will also start the new OMEMO session and send a MAM request.
|
||||
@ -2177,6 +2133,66 @@ cmd_msg(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
#endif // HAVE_LIBOTR
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
cmd_msg(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
char* usr = args[0];
|
||||
char* msg = args[1];
|
||||
|
||||
jabber_conn_status_t conn_status = connection_get_status();
|
||||
|
||||
if (conn_status != JABBER_CONNECTED) {
|
||||
cons_show("You are not currently connected.");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// send private message when in MUC room
|
||||
if (window->type == WIN_MUC) {
|
||||
ProfMucWin* mucwin = (ProfMucWin*)window;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
|
||||
Occupant* occupant = muc_roster_item(mucwin->roomjid, usr);
|
||||
if (occupant) {
|
||||
// in case of non-anon muc send regular chatmessage
|
||||
if (muc_anonymity_type(mucwin->roomjid) == MUC_ANONYMITY_TYPE_NONANONYMOUS) {
|
||||
Jid* jidp = jid_create(occupant->jid);
|
||||
_cmd_msg_chatwin(jidp->barejid, msg);
|
||||
jid_destroy(jidp);
|
||||
} else {
|
||||
// otherwise send mucpm
|
||||
GString* full_jid = g_string_new(mucwin->roomjid);
|
||||
g_string_append(full_jid, "/");
|
||||
g_string_append(full_jid, usr);
|
||||
|
||||
ProfPrivateWin* privwin = wins_get_private(full_jid->str);
|
||||
if (!privwin) {
|
||||
privwin = (ProfPrivateWin*)wins_new_private(full_jid->str);
|
||||
}
|
||||
ui_focus_win((ProfWin*)privwin);
|
||||
|
||||
if (msg) {
|
||||
cl_ev_send_priv_msg(privwin, msg, NULL);
|
||||
}
|
||||
|
||||
g_string_free(full_jid, TRUE);
|
||||
}
|
||||
|
||||
} else {
|
||||
win_println(window, THEME_DEFAULT, "-", "No such participant \"%s\" in room.", usr);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
// send chat message
|
||||
} else {
|
||||
char* barejid = roster_barejid_from_name(usr);
|
||||
if (barejid == NULL) {
|
||||
barejid = usr;
|
||||
}
|
||||
|
||||
_cmd_msg_chatwin(barejid, msg);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user