Send DM bounce messages

merge-requests/30/head
Bob Mottram 2021-02-24 11:01:44 +00:00
parent 4555917eeb
commit a9de85cb13
16 changed files with 103 additions and 20 deletions

View File

@ -58,6 +58,7 @@ from utils import updateAnnounceCollection
from utils import undoAnnounceCollectionEntry from utils import undoAnnounceCollectionEntry
from utils import dangerousMarkup from utils import dangerousMarkup
from httpsig import messageContentDigest from httpsig import messageContentDigest
from posts import createDirectMessagePost
from posts import validContentWarning from posts import validContentWarning
from posts import downloadAnnounce from posts import downloadAnnounce
from posts import isDM from posts import isDM
@ -2056,6 +2057,67 @@ def _updateLastSeen(baseDir: str, handle: str, actor: str) -> None:
lastSeenFile.write(str(daysSinceEpoch)) lastSeenFile.write(str(daysSinceEpoch))
def _bounceDM(senderPostId: str, session, httpPrefix: str,
baseDir: str, nickname: str, domain: str, port: int,
sendingHandle: str, federationList: [],
sendThreads: [], postLog: [],
cachedWebfingers: {}, personCache: {},
translate: {}, debug: bool) -> None:
"""Sends a bounce message back to the sending handle
if a DM has been rejected
"""
print(nickname + '@' + domain +
' cannot receive DM from ' + sendingHandle +
' because they do not follow them')
senderNickname = sendingHandle.split('@')[0]
senderDomain = sendingHandle.split('@')[1]
senderPort = port
if ':' in senderDomain:
senderPortStr = senderDomain.split(':')[1]
if senderPortStr.isdigit():
senderPort = int(senderPortStr)
senderDomain = senderDomain.split(':')[0]
cc = []
# create the bounce DM
subject = None
content = translate['DM bounce']
followersOnly = False
saveToFile = False
clientToServer = False
commentsEnabled = False
attachImageFilename = None
mediaType = None
imageDescription = ''
inReplyTo = removeIdEnding(senderPostId)
inReplyToAtomUri = None
schedulePost = False
eventDate = None
eventTime = None
location = None
postJsonObject = \
createDirectMessagePost(baseDir, nickname, domain, port,
httpPrefix, content, followersOnly,
saveToFile, clientToServer,
commentsEnabled,
attachImageFilename, mediaType,
imageDescription,
inReplyTo, inReplyToAtomUri,
subject, debug, schedulePost,
eventDate, eventTime, location)
if not postJsonObject:
print('WARN: unable to create bounce message to ' + sendingHandle)
return
# bounce DM goes back to the sender
print('Sending bounce DM to ' + sendingHandle)
sendSignedJson(postJsonObject, session, baseDir,
nickname, domain, port,
senderNickname, senderDomain, senderPort, cc,
httpPrefix, False, False, federationList,
sendThreads, postLog, cachedWebfingers,
personCache, debug, __version__)
def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int, def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
session, keyId: str, handle: str, messageJson: {}, session, keyId: str, handle: str, messageJson: {},
baseDir: str, httpPrefix: str, sendThreads: [], baseDir: str, httpPrefix: str, sendThreads: [],
@ -2302,11 +2364,17 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
if not isFollowingActor(baseDir, if not isFollowingActor(baseDir,
nickname, domain, nickname, domain,
sendH): sendH):
print(nickname + '@' + domain + # send back a bounce DM
' cannot receive DM from ' + if postJsonObject.get('id'):
sendH + senderPostId = \
' because they do not ' + postJsonObject['id']
'follow them') _bounceDM(senderPostId,
session, httpPrefix,
baseDir, nickname, domain, port,
sendH, federationList,
sendThreads, postLog,
cachedWebfingers, personCache,
translate, debug)
return False return False
# dm index will be updated # dm index will be updated

View File

@ -370,5 +370,6 @@
"Publish a blog article": "نشر مقال بلوق", "Publish a blog article": "نشر مقال بلوق",
"Featured writer": "كاتب متميز", "Featured writer": "كاتب متميز",
"Broch mode": "وضع الكتيب", "Broch mode": "وضع الكتيب",
"Pixel": "بكسل" "Pixel": "بكسل",
"DM bounce": "يتم قبول الرسائل فقط من الحسابات المتبعة"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Publicar un article del bloc", "Publish a blog article": "Publicar un article del bloc",
"Featured writer": "Escriptor destacat", "Featured writer": "Escriptor destacat",
"Broch mode": "Mode Broch", "Broch mode": "Mode Broch",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "Els missatges només saccepten des dels comptes seguits"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Cyhoeddi erthygl blog", "Publish a blog article": "Cyhoeddi erthygl blog",
"Featured writer": "Awdur dan sylw", "Featured writer": "Awdur dan sylw",
"Broch mode": "Modd Broch", "Broch mode": "Modd Broch",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "Dim ond o gyfrifon a ddilynir y derbynnir negeseuon"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Veröffentlichen Sie einen Blog-Artikel", "Publish a blog article": "Veröffentlichen Sie einen Blog-Artikel",
"Featured writer": "Ausgewählter Schriftsteller", "Featured writer": "Ausgewählter Schriftsteller",
"Broch mode": "Broch-Modus", "Broch mode": "Broch-Modus",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "Nachrichten werden nur von folgenden Konten akzeptiert"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Publish a blog article", "Publish a blog article": "Publish a blog article",
"Featured writer": "Featured writer", "Featured writer": "Featured writer",
"Broch mode": "Broch mode", "Broch mode": "Broch mode",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "Messages are only accepted from followed accounts"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Publica un artículo de blog", "Publish a blog article": "Publica un artículo de blog",
"Featured writer": "Escritora destacada", "Featured writer": "Escritora destacada",
"Broch mode": "Modo broche", "Broch mode": "Modo broche",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "Solo se aceptan mensajes de cuentas seguidas"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Publier un article de blog", "Publish a blog article": "Publier un article de blog",
"Featured writer": "Écrivain en vedette", "Featured writer": "Écrivain en vedette",
"Broch mode": "Mode Broch", "Broch mode": "Mode Broch",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "Les messages ne sont acceptés que des comptes suivis"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Foilsigh alt blagála", "Publish a blog article": "Foilsigh alt blagála",
"Featured writer": "Scríbhneoir mór le rá", "Featured writer": "Scríbhneoir mór le rá",
"Broch mode": "Modh broch", "Broch mode": "Modh broch",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "Ní ghlactar le teachtaireachtaí ach ó chuntais a leanann"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "एक ब्लॉग लेख प्रकाशित करें", "Publish a blog article": "एक ब्लॉग लेख प्रकाशित करें",
"Featured writer": "फीचर्ड लेखक", "Featured writer": "फीचर्ड लेखक",
"Broch mode": "ब्रोच मोड", "Broch mode": "ब्रोच मोड",
"Pixel": "पिक्सेल" "Pixel": "पिक्सेल",
"DM bounce": "संदेश केवल अनुसरण किए गए खातों से स्वीकार किए जाते हैं"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Pubblica un articolo sul blog", "Publish a blog article": "Pubblica un articolo sul blog",
"Featured writer": "Scrittore in primo piano", "Featured writer": "Scrittore in primo piano",
"Broch mode": "Modalità Broch", "Broch mode": "Modalità Broch",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "I messaggi sono accettati solo dagli account seguiti"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "ブログ記事を公開する", "Publish a blog article": "ブログ記事を公開する",
"Featured writer": "注目の作家", "Featured writer": "注目の作家",
"Broch mode": "ブロッホモード", "Broch mode": "ブロッホモード",
"Pixel": "ピクセル" "Pixel": "ピクセル",
"DM bounce": "メッセージはフォローされているアカウントからのみ受け付けられます"
} }

View File

@ -366,5 +366,6 @@
"Publish a blog article": "Publish a blog article", "Publish a blog article": "Publish a blog article",
"Featured writer": "Featured writer", "Featured writer": "Featured writer",
"Broch mode": "Broch mode", "Broch mode": "Broch mode",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "Messages are only accepted from followed accounts"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Publique um artigo de blog", "Publish a blog article": "Publique um artigo de blog",
"Featured writer": "Escritor em destaque", "Featured writer": "Escritor em destaque",
"Broch mode": "Modo broch", "Broch mode": "Modo broch",
"Pixel": "Pixel" "Pixel": "Pixel",
"DM bounce": "Mensagens são aceitas apenas de contas seguidas"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "Опубликовать статью в блоге", "Publish a blog article": "Опубликовать статью в блоге",
"Featured writer": "Избранный писатель", "Featured writer": "Избранный писатель",
"Broch mode": "Брош режим", "Broch mode": "Брош режим",
"Pixel": "Пиксель" "Pixel": "Пиксель",
"DM bounce": "Сообщения принимаются только от следующих аккаунтов"
} }

View File

@ -370,5 +370,6 @@
"Publish a blog article": "发布博客文章", "Publish a blog article": "发布博客文章",
"Featured writer": "特色作家", "Featured writer": "特色作家",
"Broch mode": "断点模式", "Broch mode": "断点模式",
"Pixel": "像素点" "Pixel": "像素点",
"DM bounce": "仅接受来自后续帐户的邮件"
} }