From ac0dd52c78a878a747f55f73dcd6796324de89fd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 8 Jul 2020 23:17:21 +0100 Subject: [PATCH] Check for repeated like notifications --- inbox.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/inbox.py b/inbox.py index 3c93ca78..5164365a 100644 --- a/inbox.py +++ b/inbox.py @@ -1740,8 +1740,19 @@ def likeNotify(baseDir: str, domain: str, onionDomain: str, str(likerNickname) + '@' + str(likerDomain)) likerHandle = actor if likerHandle != handle: + likeStr = likerHandle + ' ' + url + prevLikeFile = accountDir + '/.prevLike' + # was there a previous like notification? + if os.path.isfile(prevLikeFile): + # is it the same as the current notification ? + with open(prevLikeFile, 'r') as likeFile: + prevLikeStr = likeFile.read() + if prevLikeStr == likeStr: + return + with open(prevLikeFile, 'w') as fp: + fp.write(likeStr) with open(likeFile, 'w') as fp: - fp.write(likerHandle + ' ' + url) + fp.write(likeStr) def replyNotify(baseDir: str, handle: str, url: str) -> None: