forked from indymedia/epicyon
Also send to mentioned recipients
parent
491df84892
commit
88b0b13ddc
|
@ -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]="<span class=\"h-card\"><a href=\""+httpPrefix+"://"+replaceDomain+"/@"+possibleNickname+"\" class=\"u-url mention\">@<span>"+possibleNickname+"</span></a></span>"
|
||||
replaceFound=True
|
||||
break
|
||||
|
|
|
@ -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
|
||||
|
|
11
posts.py
11
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,
|
||||
|
|
Loading…
Reference in New Issue