diff --git a/content.py b/content.py index f9ea8f11..be3d3fb0 100644 --- a/content.py +++ b/content.py @@ -10,7 +10,8 @@ import os import commentjson def addMentions(baseDir: str,httpPrefix: str, \ - nickname: str,domain: str,content: str) -> str: + nickname: str,domain: str,content: str, \ + recipients: []) -> str: """ Replaces plaintext mentions such as @nick@domain into html by matching against known following accounts """ @@ -44,8 +45,11 @@ def addMentions(baseDir: str,httpPrefix: str, \ if not replaceFound: # fall back to a best effort match if an exact one is not found for follow in following: - if follow.startsWith(possibleNickname+'@'): + if follow.startswith(possibleNickname+'@'): replaceDomain=follow.replace('\n','').split('@')[1] + recipientActor=httpPrefix+"://"+replaceDomain+"/users/"+possibleNickname + if recipientActor not in recipients: + recipients.append(recipientActor) replaceMentions[wordStr]="@"+possibleNickname+"" replaceFound=True break diff --git a/daemon.py b/daemon.py index e79f1075..ec41d619 100644 --- a/daemon.py +++ b/daemon.py @@ -1795,7 +1795,7 @@ class PubServer(BaseHTTPRequestHandler): addMentions(self.server.baseDir, \ self.server.httpPrefix, \ nickname, \ - self.server.domain,fields['bio']) + self.server.domain,fields['bio'],[]) actorChanged=True if fields.get('approveFollowers'): approveFollowers=False diff --git a/posts.py b/posts.py index 125a4303..73faa4d7 100644 --- a/posts.py +++ b/posts.py @@ -379,10 +379,12 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ inReplyTo=None, inReplyToAtomUri=None, subject=None) -> {}: """Creates a message """ + mentionedRecipients=[] if not clientToServer: # convert content to html content=addMentions(baseDir,httpPrefix, \ - nickname,domain,content) + nickname,domain,content, \ + mentionedRecipients) if port!=80 and port!=443: if ':' not in domain: @@ -404,6 +406,9 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ summary=subject sensitive=True + # who to send to + toRecipients=[toUrl] + mentionedRecipients + if not clientToServer: actorUrl=httpPrefix+'://'+domain+'/users/'+nickname @@ -434,7 +439,7 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ 'published': published, 'url': httpPrefix+'://'+domain+'/@'+nickname+'/'+statusNumber, 'attributedTo': httpPrefix+'://'+domain+'/users/'+nickname, - 'to': [toUrl], + 'to': toRecipients, 'cc': [], 'sensitive': sensitive, 'atomUri': newPostId, @@ -471,7 +476,7 @@ def createPostBase(baseDir: str,nickname: str, domain: str, port: int, \ 'published': published, 'url': httpPrefix+'://'+domain+'/@'+nickname+'/'+statusNumber, 'attributedTo': httpPrefix+'://'+domain+'/users/'+nickname, - 'to': [toUrl], + 'to': toRecipients, 'cc': [], 'sensitive': sensitive, 'atomUri': newPostId,