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

Proposed by Ken VanDine
Status: Merged
Merged at revision: 1311
Proposed branch: lp:~ken-vandine/gwibber/facebook_questions
Merge into: lp:gwibber
Diff against target: 38 lines (+20/-1)
1 file modified
gwibber/microblog/plugins/facebook/__init__.py (+20/-1)
To merge this branch: bzr merge lp:~ken-vandine/gwibber/facebook_questions
Reviewer Review Type Date Requested Status
David Klasinc (community) Approve
Review via email: mp+96818@code.launchpad.net

Description of the change

try to handle data from facebook of type=question to prevent empty posts in the feed

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 'gwibber/microblog/plugins/facebook/__init__.py'
2--- gwibber/microblog/plugins/facebook/__init__.py 2012-02-23 08:59:27 +0000
3+++ gwibber/microblog/plugins/facebook/__init__.py 2012-03-09 19:38:22 +0000
4@@ -181,6 +181,25 @@
5 m["link"]["icon"] = data.get("icon", None)
6 m["link"]["caption"] = data.get("caption", None)
7 m["link"]["properties"] = data.get("properties", {})
8+ elif data["type"] == "question":
9+ m["question"] = {}
10+ m["question"]["id"] = data["id"]
11+ m["question"]["text"] = data.get("question", None)
12+ if not m["question"]["text"]:
13+ m["question"]["text"] = data.get("story", None)
14+ if data.has_key("options") and isinstance(data["options"], dict):
15+ if isinstance(data["options"]["data"], dict):
16+ m["question"]["answers"] = []
17+ for a in data["options"]["data"]:
18+ answer = {}
19+ answer["id"] = a.get("id", None)
20+ answer["name"] = a.get("name", None)
21+ answer["votes"] = a.get("votes", None)
22+ m["question"]["answers"].append(answer)
23+ if m["question"]["text"] and len(m["text"]) < 1:
24+ m["text"] = m["question"]["text"]
25+ m["html"] = m["text"]
26+ m["content"] = m["html"]
27 elif data["type"] == "status":
28 pass
29 else:
30@@ -236,7 +255,7 @@
31 else:
32 since = int(mx.DateTime.DateTimeFromTicks(since).localtime())
33
34- data = self._get("me/home")
35+ data = self._get("me/home", since=since, limit=100)
36
37 logger.debug("<STATS> facebook:receive account:%s since:%s size:%s",
38 self.account["id"], mx.DateTime.DateTimeFromTicks(since), len(str(data)))