mirror of https://gitlab.com/bashrc2/epicyon
Automatic content warnings
parent
3d15ae40ad
commit
74a6f286fc
12
daemon.py
12
daemon.py
|
@ -3363,6 +3363,18 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if os.path.isfile(autoTagsFilename):
|
||||
os.remove(autoTagsFilename)
|
||||
|
||||
# autogenerated content warnings
|
||||
autoCWFilename = \
|
||||
baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + \
|
||||
'/autocw.txt'
|
||||
if fields.get('autoCW'):
|
||||
with open(autoCWFilename, 'w+') as autoCWFile:
|
||||
autoCWFile.write(fields['autoCW'])
|
||||
else:
|
||||
if os.path.isfile(autoCWFilename):
|
||||
os.remove(autoCWFilename)
|
||||
|
||||
# save blocked accounts list
|
||||
blockedFilename = \
|
||||
baseDir + '/accounts/' + \
|
||||
|
|
37
posts.py
37
posts.py
|
@ -668,6 +668,41 @@ def validContentWarning(cw: str) -> str:
|
|||
return cw
|
||||
|
||||
|
||||
def loadAutoCW(baseDir: str, nickname: str, domain: str) -> []:
|
||||
"""Loads automatic CWs file and returns a list containing
|
||||
the lines of the file
|
||||
"""
|
||||
filename = baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '/autocw.txt'
|
||||
if not os.path.isfile(filename):
|
||||
return []
|
||||
with open(filename, "r") as f:
|
||||
return f.readlines()
|
||||
return []
|
||||
|
||||
|
||||
def addAutoCW(baseDir: str, nickname: str, domain: str,
|
||||
subject: str, content: str) -> str:
|
||||
"""Appends any automatic CW to the subject line
|
||||
and returns the new subject line
|
||||
"""
|
||||
newSubject = subject
|
||||
autoCWList = loadAutoCW(baseDir, nickname, domain)
|
||||
for cwRule in autoCWList:
|
||||
if '->' not in cwRule:
|
||||
continue
|
||||
match = cwRule.split('->')[0].strip()
|
||||
if match not in content:
|
||||
continue
|
||||
cwStr = cwRule.split('->')[1].strip()
|
||||
if newSubject:
|
||||
if cwStr not in newSubject:
|
||||
newSubject += ', ' + cwStr
|
||||
else:
|
||||
newSubject = cwStr
|
||||
return newSubject
|
||||
|
||||
|
||||
def createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||
toUrl: str, ccUrl: str, httpPrefix: str, content: str,
|
||||
followersOnly: bool, saveToFile: bool, clientToServer: bool,
|
||||
|
@ -687,6 +722,8 @@ def createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
|||
eventStatus=None, ticketUrl=None) -> {}:
|
||||
"""Creates a message
|
||||
"""
|
||||
subject = addAutoCW(baseDir, nickname, domain, subject, content)
|
||||
|
||||
mentionedRecipients = \
|
||||
getMentionedPeople(baseDir, httpPrefix, content, domain, False)
|
||||
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "تحرير الحدث",
|
||||
"Notify when posts are liked": "يخطر عندما يتم اعجاب المشاركات",
|
||||
"Don't show the Like button": "لا تظهر زر أعجبني",
|
||||
"Autogenerated Hashtags": "علامات التجزئة المُنشأة تلقائيًا"
|
||||
"Autogenerated Hashtags": "علامات التجزئة المُنشأة تلقائيًا",
|
||||
"Autogenerated Content Warnings": "تحذيرات المحتوى المُنشأ تلقائيًا"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Edita l’esdeveniment",
|
||||
"Notify when posts are liked": "Notifiqueu-ho quan us agradin les publicacions",
|
||||
"Don't show the Like button": "No mostreu el botó M'agrada",
|
||||
"Autogenerated Hashtags": "Hashtags autogenerats"
|
||||
"Autogenerated Hashtags": "Hashtags autogenerats",
|
||||
"Autogenerated Content Warnings": "Advertiments de contingut autogenerats"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Golygu digwyddiad",
|
||||
"Notify when posts are liked": "Hysbysu pryd mae swyddi'n cael eu hoffi",
|
||||
"Don't show the Like button": "Peidiwch â dangos y botwm Hoffi",
|
||||
"Autogenerated Hashtags": "Hashtags awtogeneiddiedig"
|
||||
"Autogenerated Hashtags": "Hashtags awtogeneiddiedig",
|
||||
"Autogenerated Content Warnings": "Rhybuddion Cynnwys Autogenerated"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Ereignis bearbeiten",
|
||||
"Notify when posts are liked": "Benachrichtigen, wenn Beiträge gefallen",
|
||||
"Don't show the Like button": "Zeigen Sie nicht die Schaltfläche \"Gefällt mir\" an",
|
||||
"Autogenerated Hashtags": "Automatisch generierte Hashtags"
|
||||
"Autogenerated Hashtags": "Automatisch generierte Hashtags",
|
||||
"Autogenerated Content Warnings": "Warnungen vor automatisch generierten Inhalten"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Edit event",
|
||||
"Notify when posts are liked": "Notify when posts are liked",
|
||||
"Don't show the Like button": "Don't show the Like button",
|
||||
"Autogenerated Hashtags": "Autogenerated Hashtags"
|
||||
"Autogenerated Hashtags": "Autogenerated Hashtags",
|
||||
"Autogenerated Content Warnings": "Autogenerated Content Warnings"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Editar evento",
|
||||
"Notify when posts are liked": "Notificar cuando les gusten las publicaciones",
|
||||
"Don't show the Like button": "No mostrar el botón Me gusta",
|
||||
"Autogenerated Hashtags": "Hashtags autogenerados"
|
||||
"Autogenerated Hashtags": "Hashtags autogenerados",
|
||||
"Autogenerated Content Warnings": "Advertencias de contenido generado automáticamente"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Modifier l'événement",
|
||||
"Notify when posts are liked": "Notifier lorsque les messages sont aimés",
|
||||
"Don't show the Like button": "Ne pas afficher le bouton J'aime",
|
||||
"Autogenerated Hashtags": "Hashtags générés automatiquement"
|
||||
"Autogenerated Hashtags": "Hashtags générés automatiquement",
|
||||
"Autogenerated Content Warnings": "Avertissements de contenu générés automatiquement"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Cuir imeacht in eagar",
|
||||
"Notify when posts are liked": "Cuir in iúl cathain is maith poist",
|
||||
"Don't show the Like button": "Ná taispeáin an cnaipe Cosúil",
|
||||
"Autogenerated Hashtags": "Hashtags uathghinte"
|
||||
"Autogenerated Hashtags": "Hashtags uathghinte",
|
||||
"Autogenerated Content Warnings": "Rabhaidh Ábhar Uathghinte"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "घटना संपादित करें",
|
||||
"Notify when posts are liked": "पोस्ट पसंद आने पर सूचित करें",
|
||||
"Don't show the Like button": "लाइक बटन न दिखाएं",
|
||||
"Autogenerated Hashtags": "ऑटोजेनरेटेड हैशटैग"
|
||||
"Autogenerated Hashtags": "ऑटोजेनरेटेड हैशटैग",
|
||||
"Autogenerated Content Warnings": "स्वतः प्राप्त सामग्री चेतावनी"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Modifica evento",
|
||||
"Notify when posts are liked": "Avvisa quando i post sono piaciuti",
|
||||
"Don't show the Like button": "Non mostrare il pulsante Mi piace",
|
||||
"Autogenerated Hashtags": "Hashtag generati automaticamente"
|
||||
"Autogenerated Hashtags": "Hashtag generati automaticamente",
|
||||
"Autogenerated Content Warnings": "Avvisi sui contenuti generati automaticamente"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "イベントを編集",
|
||||
"Notify when posts are liked": "投稿が高く評価されたときに通知する",
|
||||
"Don't show the Like button": "「いいね!」ボタンを表示しない",
|
||||
"Autogenerated Hashtags": "自動生成されたハッシュタグ"
|
||||
"Autogenerated Hashtags": "自動生成されたハッシュタグ",
|
||||
"Autogenerated Content Warnings": "自動生成されたコンテンツの警告"
|
||||
}
|
||||
|
|
|
@ -280,5 +280,6 @@
|
|||
"Edit event": "Edit event",
|
||||
"Notify when posts are liked": "Notify when posts are liked",
|
||||
"Don't show the Like button": "Don't show the Like button",
|
||||
"Autogenerated Hashtags": "Autogenerated Hashtags"
|
||||
"Autogenerated Hashtags": "Autogenerated Hashtags",
|
||||
"Autogenerated Content Warnings": "Autogenerated Content Warnings"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Editar evento",
|
||||
"Notify when posts are liked": "Notificar quando as postagens forem curtidas",
|
||||
"Don't show the Like button": "Não mostrar o botão Curtir",
|
||||
"Autogenerated Hashtags": "Hashtags autogeradas"
|
||||
"Autogenerated Hashtags": "Hashtags autogeradas",
|
||||
"Autogenerated Content Warnings": "Avisos de conteúdo gerado automaticamente"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "Изменить мероприятие",
|
||||
"Notify when posts are liked": "Уведомлять, когда публикации нравятся",
|
||||
"Don't show the Like button": "Не показывать кнопку \"Нравится\"",
|
||||
"Autogenerated Hashtags": "Автоматически сгенерированные хештеги"
|
||||
"Autogenerated Hashtags": "Автоматически сгенерированные хештеги",
|
||||
"Autogenerated Content Warnings": "Автоматические предупреждения о содержании"
|
||||
}
|
||||
|
|
|
@ -284,5 +284,6 @@
|
|||
"Edit event": "编辑活动",
|
||||
"Notify when posts are liked": "通知喜欢的帖子",
|
||||
"Don't show the Like button": "不显示“赞”按钮",
|
||||
"Autogenerated Hashtags": "自动生成的标签"
|
||||
"Autogenerated Hashtags": "自动生成的标签",
|
||||
"Autogenerated Content Warnings": "自动生成的内容警告"
|
||||
}
|
||||
|
|
|
@ -1175,6 +1175,14 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str,
|
|||
with open(autoTagsFilename, 'r') as autoTagsFile:
|
||||
autoTags = autoTagsFile.read()
|
||||
|
||||
autoCW = ''
|
||||
autoCWFilename = \
|
||||
baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '/autocw.txt'
|
||||
if os.path.isfile(autoCWFilename):
|
||||
with open(autoCWFilename, 'r') as autoCWFile:
|
||||
autoCW = autoCWFile.read()
|
||||
|
||||
blockedStr = ''
|
||||
blockedFilename = \
|
||||
baseDir + '/accounts/' + \
|
||||
|
@ -1523,6 +1531,14 @@ def htmlEditProfile(translate: {}, baseDir: str, path: str,
|
|||
' <textarea id="message" name="autoTags" ' + \
|
||||
'style="height:200px">' + autoTags + '</textarea>\n'
|
||||
|
||||
editProfileForm += \
|
||||
' <br><b><label class="labels">' + \
|
||||
translate['Autogenerated Content Warnings'] + '</label></b>\n'
|
||||
editProfileForm += ' <br><label class="labels">A -> B</label>\n'
|
||||
editProfileForm += \
|
||||
' <textarea id="message" name="autoCW" ' + \
|
||||
'style="height:200px">' + autoCW + '</textarea>\n'
|
||||
|
||||
editProfileForm += \
|
||||
' <br><b><label class="labels">' + \
|
||||
translate['Blocked accounts'] + '</label></b>\n'
|
||||
|
|
Loading…
Reference in New Issue