get_mentions() function
authorMoritz Kiefer <moritz.kiefer@gmail.com>
Fri, 1 Feb 2013 22:45:21 +0000 (23:45 +0100)
committerMoritz Kiefer <moritz.kiefer@gmail.com>
Fri, 1 Feb 2013 22:45:21 +0000 (23:45 +0100)
diaspy/client.py

index 0a916706f1c2f2ec1e72ec865bfd02100fb35062..6d368bd017b9275e7d3c79a963cd943f7e411d61 100644 (file)
@@ -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