mirror of https://gitlab.com/bashrc2/epicyon
Keep track of when people that you are following were last seen
parent
11883701ab
commit
a23f47cdf3
27
inbox.py
27
inbox.py
|
@ -67,6 +67,7 @@ from followingCalendar import receivingCalendarEvents
|
||||||
from content import dangerousMarkup
|
from content import dangerousMarkup
|
||||||
from happening import saveEventPost
|
from happening import saveEventPost
|
||||||
from delete import removeOldHashtags
|
from delete import removeOldHashtags
|
||||||
|
from follow import isFollowingActor
|
||||||
|
|
||||||
|
|
||||||
def guessHashtagCategory(tagName: str, hashtagCategories: {}) -> str:
|
def guessHashtagCategory(tagName: str, hashtagCategories: {}) -> str:
|
||||||
|
@ -2066,6 +2067,30 @@ def inboxUpdateIndex(boxname: str, baseDir: str, handle: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def updateLastSeen(baseDir: str, handle: str, actor: str) -> None:
|
||||||
|
"""Updates the time when the given handle last saw the given actor
|
||||||
|
"""
|
||||||
|
if '@' not in handle:
|
||||||
|
return
|
||||||
|
nickname = handle.split('@')[0]
|
||||||
|
domain = handle.split('@')[1]
|
||||||
|
if ':' in domain:
|
||||||
|
domain = domain.split(':')[0]
|
||||||
|
accountPath = baseDir + '/accounts/' + nickname + '@' + domain
|
||||||
|
if not os.path.isdir(accountPath):
|
||||||
|
return
|
||||||
|
if not isFollowingActor(baseDir, nickname, domain, actor):
|
||||||
|
return
|
||||||
|
lastSeenPath = accountPath + '/lastseen'
|
||||||
|
if not os.path.isdir(lastSeenPath):
|
||||||
|
os.mkdir(lastSeenPath)
|
||||||
|
lastSeenFilename = lastSeenPath + '/' + actor.replace('/', '#') + '.txt'
|
||||||
|
currTime = datetime.datetime.utcnow()
|
||||||
|
daysSinceEpoch = (currTime - datetime.datetime(1970, 1, 1)).days
|
||||||
|
with open(lastSeenFilename, 'w+') as lastSeenFile:
|
||||||
|
lastSeenFile.write(str(daysSinceEpoch))
|
||||||
|
|
||||||
|
|
||||||
def inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
def inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
session, keyId: str, handle: str, messageJson: {},
|
session, keyId: str, handle: str, messageJson: {},
|
||||||
baseDir: str, httpPrefix: str, sendThreads: [],
|
baseDir: str, httpPrefix: str, sendThreads: [],
|
||||||
|
@ -2086,6 +2111,8 @@ def inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
||||||
if '#' in actor:
|
if '#' in actor:
|
||||||
actor = keyId.split('#')[0]
|
actor = keyId.split('#')[0]
|
||||||
|
|
||||||
|
updateLastSeen(baseDir, handle, actor)
|
||||||
|
|
||||||
isGroup = groupHandle(baseDir, handle)
|
isGroup = groupHandle(baseDir, handle)
|
||||||
|
|
||||||
if receiveLike(recentPostsCache,
|
if receiveLike(recentPostsCache,
|
||||||
|
|
Loading…
Reference in New Issue