mirror of https://gitlab.com/bashrc2/epicyon
Send DM bounce messages
parent
4555917eeb
commit
a9de85cb13
78
inbox.py
78
inbox.py
|
@ -58,6 +58,7 @@ from utils import updateAnnounceCollection
|
|||
from utils import undoAnnounceCollectionEntry
|
||||
from utils import dangerousMarkup
|
||||
from httpsig import messageContentDigest
|
||||
from posts import createDirectMessagePost
|
||||
from posts import validContentWarning
|
||||
from posts import downloadAnnounce
|
||||
from posts import isDM
|
||||
|
@ -2056,6 +2057,67 @@ def _updateLastSeen(baseDir: str, handle: str, actor: str) -> None:
|
|||
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,
|
||||
session, keyId: str, handle: str, messageJson: {},
|
||||
baseDir: str, httpPrefix: str, sendThreads: [],
|
||||
|
@ -2302,11 +2364,17 @@ def _inboxAfterInitial(recentPostsCache: {}, maxRecentPosts: int,
|
|||
if not isFollowingActor(baseDir,
|
||||
nickname, domain,
|
||||
sendH):
|
||||
print(nickname + '@' + domain +
|
||||
' cannot receive DM from ' +
|
||||
sendH +
|
||||
' because they do not ' +
|
||||
'follow them')
|
||||
# send back a bounce DM
|
||||
if postJsonObject.get('id'):
|
||||
senderPostId = \
|
||||
postJsonObject['id']
|
||||
_bounceDM(senderPostId,
|
||||
session, httpPrefix,
|
||||
baseDir, nickname, domain, port,
|
||||
sendH, federationList,
|
||||
sendThreads, postLog,
|
||||
cachedWebfingers, personCache,
|
||||
translate, debug)
|
||||
return False
|
||||
|
||||
# dm index will be updated
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "نشر مقال بلوق",
|
||||
"Featured writer": "كاتب متميز",
|
||||
"Broch mode": "وضع الكتيب",
|
||||
"Pixel": "بكسل"
|
||||
"Pixel": "بكسل",
|
||||
"DM bounce": "يتم قبول الرسائل فقط من الحسابات المتبعة"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Publicar un article del bloc",
|
||||
"Featured writer": "Escriptor destacat",
|
||||
"Broch mode": "Mode Broch",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "Els missatges només s’accepten des dels comptes seguits"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Cyhoeddi erthygl blog",
|
||||
"Featured writer": "Awdur dan sylw",
|
||||
"Broch mode": "Modd Broch",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "Dim ond o gyfrifon a ddilynir y derbynnir negeseuon"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Veröffentlichen Sie einen Blog-Artikel",
|
||||
"Featured writer": "Ausgewählter Schriftsteller",
|
||||
"Broch mode": "Broch-Modus",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "Nachrichten werden nur von folgenden Konten akzeptiert"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Publish a blog article",
|
||||
"Featured writer": "Featured writer",
|
||||
"Broch mode": "Broch mode",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "Messages are only accepted from followed accounts"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Publica un artículo de blog",
|
||||
"Featured writer": "Escritora destacada",
|
||||
"Broch mode": "Modo broche",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "Solo se aceptan mensajes de cuentas seguidas"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Publier un article de blog",
|
||||
"Featured writer": "Écrivain en vedette",
|
||||
"Broch mode": "Mode Broch",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "Les messages ne sont acceptés que des comptes suivis"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Foilsigh alt blagála",
|
||||
"Featured writer": "Scríbhneoir mór le rá",
|
||||
"Broch mode": "Modh broch",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "Ní ghlactar le teachtaireachtaí ach ó chuntais a leanann"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "एक ब्लॉग लेख प्रकाशित करें",
|
||||
"Featured writer": "फीचर्ड लेखक",
|
||||
"Broch mode": "ब्रोच मोड",
|
||||
"Pixel": "पिक्सेल"
|
||||
"Pixel": "पिक्सेल",
|
||||
"DM bounce": "संदेश केवल अनुसरण किए गए खातों से स्वीकार किए जाते हैं"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Pubblica un articolo sul blog",
|
||||
"Featured writer": "Scrittore in primo piano",
|
||||
"Broch mode": "Modalità Broch",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "I messaggi sono accettati solo dagli account seguiti"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "ブログ記事を公開する",
|
||||
"Featured writer": "注目の作家",
|
||||
"Broch mode": "ブロッホモード",
|
||||
"Pixel": "ピクセル"
|
||||
"Pixel": "ピクセル",
|
||||
"DM bounce": "メッセージはフォローされているアカウントからのみ受け付けられます"
|
||||
}
|
||||
|
|
|
@ -366,5 +366,6 @@
|
|||
"Publish a blog article": "Publish a blog article",
|
||||
"Featured writer": "Featured writer",
|
||||
"Broch mode": "Broch mode",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "Messages are only accepted from followed accounts"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Publique um artigo de blog",
|
||||
"Featured writer": "Escritor em destaque",
|
||||
"Broch mode": "Modo broch",
|
||||
"Pixel": "Pixel"
|
||||
"Pixel": "Pixel",
|
||||
"DM bounce": "Mensagens são aceitas apenas de contas seguidas"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "Опубликовать статью в блоге",
|
||||
"Featured writer": "Избранный писатель",
|
||||
"Broch mode": "Брош режим",
|
||||
"Pixel": "Пиксель"
|
||||
"Pixel": "Пиксель",
|
||||
"DM bounce": "Сообщения принимаются только от следующих аккаунтов"
|
||||
}
|
||||
|
|
|
@ -370,5 +370,6 @@
|
|||
"Publish a blog article": "发布博客文章",
|
||||
"Featured writer": "特色作家",
|
||||
"Broch mode": "断点模式",
|
||||
"Pixel": "像素点"
|
||||
"Pixel": "像素点",
|
||||
"DM bounce": "仅接受来自后续帐户的邮件"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue