about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2019-04-01 20:39:39 +0320
committerPaul Fariello <paul@fariello.eu>2019-04-10 17:23:46 +0200
commite69f947547160ea2c965a3d4f5966c5f4a289340 (patch)
treeebb71704f3ce98fdb9494dfcfb1b555dc2d212ce /src/ui
parente7be3a605bbb47e462265a379d48aad9cc565fc2 (diff)
downloadprofani-tty-e69f947547160ea2c965a3d4f5966c5f4a289340.tar.gz
Rework MUC reflected message filtering
Reflected messages can't be filtered by nick only otherwise you might
ignore messages comming from you on another devices.

Consequently we maintain a list of sent messages id in mucwin.
To be sure the id will be correctly reflected we use the origin-id
stanza.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/mucwin.c11
-rw-r--r--src/ui/ui.h4
-rw-r--r--src/ui/win_types.h1
-rw-r--r--src/ui/window.c1
-rw-r--r--src/ui/window_list.c1
5 files changed, 14 insertions, 4 deletions
diff --git a/src/ui/mucwin.c b/src/ui/mucwin.c
index abbcd21c..0122950a 100644
--- a/src/ui/mucwin.c
+++ b/src/ui/mucwin.c
@@ -478,10 +478,12 @@ _mucwin_print_triggers(ProfWin *window, const char *const message, GList *trigge
 }
 
 void
-mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, prof_enc_t enc_mode)
+mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode)
 {
     assert(mucwin != NULL);
 
+    g_hash_table_insert(mucwin->sent_messages, strdup(id), NULL);
+
     ProfWin *window = (ProfWin*)mucwin;
     char *mynick = muc_nick(mucwin->roomjid);
 
@@ -500,10 +502,15 @@ mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, prof_enc_t en
 }
 
 void
-mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, GSList *mentions, GList *triggers, prof_enc_t enc_mode)
+mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, const char *const id, GSList *mentions, GList *triggers, prof_enc_t enc_mode)
 {
     assert(mucwin != NULL);
 
+    if (g_hash_table_remove(mucwin->sent_messages, id)) {
+        /* Ignore reflection messages */
+        return;
+    }
+
     ProfWin *window = (ProfWin*)mucwin;
     char *mynick = muc_nick(mucwin->roomjid);
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 79701a27..b94fe475 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -162,8 +162,8 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char
     const char *const role, const char *const affiliation, const char *const actor, const char *const reason);
 void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence);
 void mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, const char *const message);
-void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, prof_enc_t enc_mode);
-void mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, GSList *mentions, GList *triggers, prof_enc_t enc_mode);
+void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode);
+void mucwin_incoming_msg(ProfMucWin *mucwin, const char *const nick, const char *const message, const char *const id, GSList *mentions, GList *triggers, prof_enc_t enc_mode);
 void mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject);
 void mucwin_requires_config(ProfMucWin *mucwin);
 void mucwin_info(ProfMucWin *mucwin);
diff --git a/src/ui/win_types.h b/src/ui/win_types.h
index 498d9bbe..e1e64bf9 100644
--- a/src/ui/win_types.h
+++ b/src/ui/win_types.h
@@ -172,6 +172,7 @@ typedef struct prof_muc_win_t {
     unsigned long memcheck;
     char *enctext;
     char *message_char;
+    GHashTable *sent_messages;
 } ProfMucWin;
 
 typedef struct prof_conf_win_t ProfConfWin;
diff --git a/src/ui/window.c b/src/ui/window.c
index 64b04365..12b6c15b 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -198,6 +198,7 @@ win_create_muc(const char *const roomjid)
     new_win->enctext = NULL;
     new_win->message_char = NULL;
     new_win->is_omemo = FALSE;
+    new_win->sent_messages = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
 
     new_win->memcheck = PROFMUCWIN_MEMCHECK;
 
diff --git a/src/ui/window_list.c b/src/ui/window_list.c
index 5ce68d63..43230b57 100644
--- a/src/ui/window_list.c
+++ b/src/ui/window_list.c
@@ -561,6 +561,7 @@ wins_close_by_num(int i)
                 ProfMucWin *mucwin = (ProfMucWin*)window;
                 autocomplete_remove(wins_ac, mucwin->roomjid);
                 autocomplete_remove(wins_close_ac, mucwin->roomjid);
+                g_hash_table_remove_all(mucwin->sent_messages);
                 break;
             }
             case WIN_PRIVATE:
rate/002trace.tests?h=hlt&id=6042828bdea2a1ed1da1b0d2013a4479fb3d005a'>^
d7494165 ^
35064671 ^
d7494165 ^


51530916 ^
35064671 ^


4a943d4e ^


51530916 ^

51530916 ^
35064671 ^

51530916 ^



35064671 ^

51530916 ^


eba30983 ^
35064671 ^
4c569925 ^
eba30983 ^

6e1eeeeb ^




51530916 ^

36594a43 ^
5f98a10c ^
6e1eeeeb ^

5f98a10c ^
36594a43 ^
5f98a10c ^
51530916 ^
51530916 ^




05d17773 ^
51530916 ^




05d17773 ^
51530916 ^




05d17773 ^

51530916 ^




05d17773 ^


51530916 ^




05d17773 ^


51530916 ^
d7494165 ^















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133