From 3d3dff8fc257637c6f174223c96a972cad0c45dc Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Fri, 1 Feb 2013 23:45:21 +0100 Subject: [PATCH] get_mentions() function --- diaspy/client.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/diaspy/client.py b/diaspy/client.py index 0a91670..6d368bd 100644 --- a/diaspy/client.py +++ b/diaspy/client.py @@ -128,3 +128,27 @@ class Client: notifications = r.json() return notifications + + + def get_mentions(self): + """This functions returns a list of posts the current user is being mentioned in. + + :returns: list -- list of Post objects + + """ + + + data = {'authenticity_token': self.get_token()} + r = self.session.get(self.pod + "/mentions.json") + + if r.status_code != 200: + raise Exception('wrong status code: ' + str(r.status_code)) + + mentions = r.json() + + posts = [] + + for post in mentions: + posts.append(diaspy.models.Post(str(post['id']), self)) + + return posts -- 2.25.1