mirror of
https://github.com/ZoiteChat/zoitechat.git
synced 2026-12-05 14:31:49 +00:00
Merge pull request #479 from ZoiteChat/fix-issue-454+468
Fix issue 454+468
This commit is contained in:
4 files changed
+54
-18
No files matched your search
@@ -285,13 +285,15 @@ char *decrypt_raw_message(const char *message, const char *key) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean have_echo_message(void) {
|
||||
return g_strcmp0(zoitechat_get_info(ph, "echo-message"), "1") == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a message is to be sent.
|
||||
*/
|
||||
static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
||||
char *prefix;
|
||||
enum fish_mode mode;
|
||||
char *message;
|
||||
GString *command;
|
||||
GSList *encrypted_list, *encrypted_item;
|
||||
|
||||
@@ -309,15 +311,15 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
||||
return ZOITECHAT_EAT_NONE;
|
||||
}
|
||||
|
||||
/* Get prefix for own nick if any */
|
||||
prefix = get_my_own_prefix();
|
||||
/* Let the decrypted server echo display the message when available. */
|
||||
if (!have_echo_message()) {
|
||||
char *prefix = get_my_own_prefix();
|
||||
char *message = g_strconcat("[", fish_modes[mode], "] ", word_eol[1], NULL);
|
||||
|
||||
/* Add encrypted flag */
|
||||
message = g_strconcat("[", fish_modes[mode], "] ", word_eol[1], NULL);
|
||||
|
||||
/* Display message */
|
||||
zoitechat_emit_print(ph, "Your Message", zoitechat_get_info(ph, "nick"), message, prefix, NULL);
|
||||
g_free(message);
|
||||
zoitechat_emit_print(ph, "Your Message", zoitechat_get_info(ph, "nick"), message, prefix, NULL);
|
||||
g_free(message);
|
||||
g_free(prefix);
|
||||
}
|
||||
|
||||
/* Send encrypted messages */
|
||||
encrypted_item = encrypted_list;
|
||||
@@ -328,7 +330,6 @@ static int handle_outgoing(char *word[], char *word_eol[], void *userdata) {
|
||||
encrypted_item = encrypted_item->next;
|
||||
}
|
||||
|
||||
g_free(prefix);
|
||||
g_string_free(command, TRUE);
|
||||
g_slist_free_full(encrypted_list, g_free);
|
||||
|
||||
@@ -412,6 +413,14 @@ static int handle_keyx_notice(char *word[], char *word_eol[], void *userdata) {
|
||||
return ZOITECHAT_EAT_NONE;
|
||||
|
||||
sender = irc_prefix_get_nick(prefix);
|
||||
/* A reflected outgoing key exchange is not a request from the peer. */
|
||||
if (irc_nick_cmp(sender, zoitechat_get_info(ph, "nick")) == 0 &&
|
||||
irc_nick_cmp(word[3], sender) != 0 &&
|
||||
(!strcmp(dh_message, ":DH1080_INIT") || !strcmp(dh_message, ":DH1080_FINISH"))) {
|
||||
g_free(sender);
|
||||
return ZOITECHAT_EAT_ALL;
|
||||
}
|
||||
|
||||
query_ctx = find_context_on_network(sender);
|
||||
if (query_ctx)
|
||||
g_assert(zoitechat_set_context(ph, query_ctx) == 1);
|
||||
@@ -950,7 +959,6 @@ static int handle_crypt_topic(char *word[], char *word_eol[], void *userdata) {
|
||||
static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
||||
const char *target = word[2];
|
||||
const char *notice = word_eol[3];
|
||||
char *notice_flag;
|
||||
enum fish_mode mode;
|
||||
GString *command;
|
||||
GSList *encrypted_list, *encrypted_item;
|
||||
@@ -976,8 +984,11 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
||||
return ZOITECHAT_EAT_ALL;
|
||||
}
|
||||
|
||||
notice_flag = g_strconcat("[", fish_modes[mode], "] ", notice, NULL);
|
||||
zoitechat_emit_print(ph, "Notice Send", target, notice_flag);
|
||||
if (!have_echo_message()) {
|
||||
char *notice_flag = g_strconcat("[", fish_modes[mode], "] ", notice, NULL);
|
||||
zoitechat_emit_print(ph, "Notice Send", target, notice_flag);
|
||||
g_free(notice_flag);
|
||||
}
|
||||
|
||||
/* Send encrypted messages */
|
||||
encrypted_item = encrypted_list;
|
||||
@@ -987,7 +998,6 @@ static int handle_crypt_notice(char *word[], char *word_eol[], void *userdata) {
|
||||
encrypted_item = encrypted_item->next;
|
||||
}
|
||||
|
||||
g_free(notice_flag);
|
||||
g_string_free(command, TRUE);
|
||||
g_slist_free_full(encrypted_list, g_free);
|
||||
|
||||
@@ -1039,6 +1049,9 @@ static int handle_crypt_msg(char *word[], char *word_eol[], void *userdata) {
|
||||
g_string_free(command, TRUE);
|
||||
g_slist_free_full(encrypted_list, g_free);
|
||||
|
||||
if (have_echo_message())
|
||||
return ZOITECHAT_EAT_ALL;
|
||||
|
||||
query_ctx = find_context_on_network(target);
|
||||
if (query_ctx) {
|
||||
g_assert(zoitechat_set_context(ph, query_ctx) == 1);
|
||||
@@ -1079,7 +1092,8 @@ static int handle_crypt_me(char *word[], char *word_eol[], void *userdata) {
|
||||
return ZOITECHAT_EAT_ALL;
|
||||
}
|
||||
|
||||
zoitechat_emit_print(ph, "Your Action", zoitechat_get_info(ph, "nick"), word_eol[2], NULL);
|
||||
if (!have_echo_message())
|
||||
zoitechat_emit_print(ph, "Your Action", zoitechat_get_info(ph, "nick"), word_eol[2], NULL);
|
||||
|
||||
/* Send encrypted messages */
|
||||
encrypted_item = encrypted_list;
|
||||
|
||||
@@ -3115,7 +3115,8 @@ cmd_notice (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
while ((split_text = split_up_text (sess, text + offset, cmd_length, split_text)))
|
||||
{
|
||||
sess->server->p_notice (sess->server, word[2], split_text);
|
||||
EMIT_SIGNAL (XP_TE_NOTICESEND, sess, word[2], split_text, NULL, NULL, 0);
|
||||
if (!sess->server->have_echo_message || split_text[0] == '\001')
|
||||
EMIT_SIGNAL (XP_TE_NOTICESEND, sess, word[2], split_text, NULL, NULL, 0);
|
||||
|
||||
if (*split_text)
|
||||
offset += strlen(split_text);
|
||||
@@ -3124,7 +3125,8 @@ cmd_notice (struct session *sess, char *tbuf, char *word[], char *word_eol[])
|
||||
}
|
||||
|
||||
sess->server->p_notice (sess->server, word[2], text + offset);
|
||||
EMIT_SIGNAL (XP_TE_NOTICESEND, sess, word[2], text + offset, NULL, NULL, 0);
|
||||
if (!sess->server->have_echo_message || text[offset] == '\001')
|
||||
EMIT_SIGNAL (XP_TE_NOTICESEND, sess, word[2], text + offset, NULL, NULL, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1242,6 +1242,9 @@ zoitechat_get_info (zoitechat_plugin *ph, const char *id)
|
||||
case 0x6de15a2e: /* network */
|
||||
return server_get_network (sess->server, FALSE);
|
||||
|
||||
case 0xa089585f: /* echo-message */
|
||||
return sess->server->have_echo_message ? "1" : "0";
|
||||
|
||||
case 0x339763: /* nick */
|
||||
return sess->server->nick;
|
||||
|
||||
|
||||
@@ -1306,6 +1306,19 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Echoed notices are outgoing, not incoming notifications or CTCP replies. */
|
||||
if (serv->have_echo_message && !serv->p_cmp (nick, serv->nick))
|
||||
{
|
||||
if (text[0] != '\001')
|
||||
{
|
||||
EMIT_SIGNAL_TIMESTAMP (XP_TE_NOTICESEND, sess, word[3], text, NULL, NULL, 0,
|
||||
tags_data->timestamp);
|
||||
return;
|
||||
}
|
||||
if (serv->p_cmp (word[3], serv->nick))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ignore_check (word[1], IG_NOTI))
|
||||
inbound_notice (serv, word[3], nick, text, ip, tags_data->identified, tags_data);
|
||||
}
|
||||
@@ -1335,6 +1348,10 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[],
|
||||
text[len - 1] = 0;
|
||||
}
|
||||
text++;
|
||||
/* Do not answer our own outgoing CTCP or DCC requests. */
|
||||
if (serv->have_echo_message && !serv->p_cmp (nick, serv->nick) &&
|
||||
serv->p_cmp (to, serv->nick) && g_ascii_strncasecmp (text, "ACTION ", 7))
|
||||
return;
|
||||
if (g_ascii_strncasecmp (text, "ACTION", 6) != 0)
|
||||
flood_check (nick, ip, serv, sess, 0);
|
||||
if (g_ascii_strncasecmp (text, "DCC ", 4) == 0)
|
||||
|
||||
Reference in new issue
Block a user