Merge lp:~ken-vandine/gwibber/lp_933694 into lp:gwibber

Proposed by Ken VanDine
Status: Merged
Merged at revision: 1308
Proposed branch: lp:~ken-vandine/gwibber/lp_933694
Merge into: lp:gwibber
Diff against target: 58 lines (+26/-7)
1 file modified
libgwibber/streams.vala (+26/-7)
To merge this branch: bzr merge lp:~ken-vandine/gwibber/lp_933694
Reviewer Review Type Date Requested Status
David Klasinc (community) Approve
Review via email: mp+96591@code.launchpad.net

Description of the change

Fix duplicate detection by falling back to comparing _html, _link_description, _image_url and _video_url (LP: #933694)

To post a comment you must log in.
Revision history for this message
David Klasinc (bigwhale) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libgwibber/streams.vala'
2--- libgwibber/streams.vala 2012-03-07 14:27:42 +0000
3+++ libgwibber/streams.vala 2012-03-08 15:11:18 +0000
4@@ -485,14 +485,8 @@
5 if (obj.has_member("text"))
6 _text = obj.get_string_member("text");
7
8- string _textid = "";
9- foreach (var x in _text.replace(".", "").split(" "))
10- if ((!x.has_prefix("http://")) && (!x.has_prefix("https://"))
11- && (!x.has_prefix("gwibber:/")) && (!x.has_prefix("#"))
12- && (!x.has_prefix("!")))
13- _textid += x + " ";
14+ string _textid = gen_text_id (_text);
15
16- _textid = _textid.strip();
17 // FIXME: the transient == 0 disables dupe checking for transients, we should fix that
18 //string _icon = yield service.avatar_path(_sender_obj.get_string_member("image"));
19 if (_sender_obj.has_member("image"))
20@@ -686,6 +680,16 @@
21 if (_link_description != null)
22 _link_description = scrub (_link_description);
23
24+ /* If textid is empty, lets fallback to check some other fields */
25+ if (_textid.length < 1 && _html != null)
26+ _textid = gen_text_id (_html);
27+ if (_textid.length < 1 && _link_description != null)
28+ _textid = gen_text_id (_link_description);
29+ if (_textid.length < 1 && _image_url != null)
30+ _textid = _image_url.strip ();
31+ if (_textid.length < 1 && _image_url != null)
32+ _textid = _video_url.strip ();
33+
34 string _t = utils.generate_time_string(_time);
35
36 if (seen.has_key(_textid) && transient == "0")
37@@ -778,6 +782,21 @@
38 return res;
39 }
40
41+ private string gen_text_id (string t)
42+ {
43+ string id = "";
44+ if (t.length > 0)
45+ {
46+ foreach (var x in t.replace(".", "").split(" "))
47+ if ((!x.has_prefix("http://")) && (!x.has_prefix("https://"))
48+ && (!x.has_prefix("gwibber:/")) && (!x.has_prefix("#"))
49+ && (!x.has_prefix("!")))
50+ id += x + " ";
51+ id = id.strip();
52+ }
53+ return id;
54+ }
55+
56
57
58 /**