Added online friends buffer
This commit is contained in:
@@ -84,12 +84,18 @@ def render_person(status, session):
|
||||
Reference: https://vk.com/dev/fields"""
|
||||
if "last_seen" in status:
|
||||
original_date = arrow.get(status["last_seen"]["time"])
|
||||
now = arrow.now()
|
||||
original_date.to(now.tzinfo)
|
||||
diffdate = now-original_date
|
||||
if diffdate.days == 0 and diffdate.seconds <= 360:
|
||||
online_status = _("Online")
|
||||
else:
|
||||
# Translators: This is the date of last seen
|
||||
last_seen = _("{0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
|
||||
online_status = _("Last seen {0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
|
||||
# Account suspended or deleted.
|
||||
elif ("last_seen" in status) == False and "deactivated" in status:
|
||||
last_seen = _("Account deactivated")
|
||||
return ["{0} {1}".format(status["first_name"], status["last_name"]), last_seen]
|
||||
online_status = _("Account deactivated")
|
||||
return ["{0} {1}".format(status["first_name"], status["last_name"]), online_status]
|
||||
|
||||
def render_newsfeed_item(status, session):
|
||||
""" This me☻thod is used to render an item of the news feed.
|
||||
|
@@ -55,6 +55,11 @@ class vkSession(object):
|
||||
@data list: A list with items and some information about cursors.
|
||||
returns the number of items that has been added in this execution"""
|
||||
global post_types
|
||||
# When this method is called by friends.getOnlyne, it gives only friend IDS so we need to retrieve full objects from VK.
|
||||
# ToDo: It would be nice to investigate whether reusing some existing objects would be a good idea, whenever possible.
|
||||
if name == "online_friends":
|
||||
newdata = self.vk.client.users.get(user_ids=",".join([str(z) for z in data]), fields="last_seen")
|
||||
data = newdata
|
||||
first_addition = False
|
||||
num = 0
|
||||
if (name in self.db) == False:
|
||||
@@ -62,7 +67,7 @@ class vkSession(object):
|
||||
self.db[name]["items"] = []
|
||||
first_addition = True
|
||||
for i in data:
|
||||
if "type" in i and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"):
|
||||
if "type" in i and not isinstance(i["type"], int) and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"):
|
||||
log.debug("Skipping unsupported item... %r" % (i,))
|
||||
continue
|
||||
# for some reason, VK sends post data if the post has been deleted already.
|
||||
|
Reference in New Issue
Block a user