mirror of https://gitlab.com/bashrc2/epicyon
Create notification when likes arrive
parent
4c09983932
commit
61f7a09670
23
inbox.py
23
inbox.py
|
@ -1033,6 +1033,7 @@ def receiveLike(recentPostsCache: {},
|
||||||
updateLikesCollection(recentPostsCache, baseDir, postFilename,
|
updateLikesCollection(recentPostsCache, baseDir, postFilename,
|
||||||
messageJson['object'],
|
messageJson['object'],
|
||||||
messageJson['actor'], domain, debug)
|
messageJson['actor'], domain, debug)
|
||||||
|
likeNotify(baseDir, handle, messageJson['actor'], messageJson['object'])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -1704,6 +1705,28 @@ def dmNotify(baseDir: str, handle: str, url: str) -> None:
|
||||||
fp.write(url)
|
fp.write(url)
|
||||||
|
|
||||||
|
|
||||||
|
def likeNotify(baseDir: str, handle: str, actor: str, url: str) -> None:
|
||||||
|
"""Creates a notification that a like has arrived
|
||||||
|
"""
|
||||||
|
accountDir = baseDir + '/accounts/' + handle
|
||||||
|
if not os.path.isdir(accountDir):
|
||||||
|
return
|
||||||
|
likeFile = accountDir + '/.newLike'
|
||||||
|
|
||||||
|
domain = handle.split('@')[1]
|
||||||
|
nickname = handle.split('@')[0]
|
||||||
|
actor = '://' + domain + '/users/' + nickname
|
||||||
|
# the liked post is one which you made
|
||||||
|
if actor not in url:
|
||||||
|
return
|
||||||
|
likerNickname = getNicknameFromActor(actor)
|
||||||
|
likerDomain, likerPort = getDomainFromActor(actor)
|
||||||
|
likerHandle = likerNickname + '@' + likerDomain
|
||||||
|
if likerHandle != handle:
|
||||||
|
with open(likeFile, 'w') as fp:
|
||||||
|
fp.write(likerHandle + ' ' + url)
|
||||||
|
|
||||||
|
|
||||||
def replyNotify(baseDir: str, handle: str, url: str) -> None:
|
def replyNotify(baseDir: str, handle: str, url: str) -> None:
|
||||||
"""Creates a notification that a new reply has arrived
|
"""Creates a notification that a new reply has arrived
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue