From 193ac8916cdff577ceed90e29b24b13bc7569063 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 4 Oct 2019 16:17:48 +0100 Subject: [PATCH] Check if mention exists --- inbox.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/inbox.py b/inbox.py index 390ab38d0..76d14183e 100644 --- a/inbox.py +++ b/inbox.py @@ -1311,11 +1311,20 @@ def sendToGroupMembers(session,baseDir: str,handle: str,port: int,postJsonObject # add mention to tag list if not postJsonObject['object']['tag']: postJsonObject['object']['tag']=[] - postJsonObject['object']['tag'].append({ - 'href': sendingActor, - 'name': senderStr, - 'type': 'Mention' - }) + # check if the mention already exists + mentionExists=False + for mention in postJsonObject['object']['tag']: + if mention['type']=='Mention': + if mention.get('href'): + if mention['href']==sendingActor: + mentionExists=True + if not mentionExists: + # add the mention of the original sender + postJsonObject['object']['tag'].append({ + 'href': sendingActor, + 'name': senderStr, + 'type': 'Mention' + }) postJsonObject['actor']=httpPrefix+'://'+domainFull+'/users/'+nickname postJsonObject['to']=[httpPrefix+'://'+domainFull+'/users/'+nickname+'/followers']