mirror of https://gitlab.com/bashrc2/epicyon
Screen for outgoing abusive posts
parent
2cbcd4eeb2
commit
6806218202
5
posts.py
5
posts.py
|
|
@ -31,6 +31,7 @@ from session import postImage
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
from httpsig import createSignedHeader
|
from httpsig import createSignedHeader
|
||||||
from siteactive import siteIsActive
|
from siteactive import siteIsActive
|
||||||
|
from utils import removeInvalidCharacters
|
||||||
from utils import fileLastModified
|
from utils import fileLastModified
|
||||||
from utils import isPublicPost
|
from utils import isPublicPost
|
||||||
from utils import hasUsersPath
|
from utils import hasUsersPath
|
||||||
|
|
@ -823,7 +824,7 @@ def validContentWarning(cw: str) -> str:
|
||||||
# so remove them
|
# so remove them
|
||||||
if '#' in cw:
|
if '#' in cw:
|
||||||
cw = cw.replace('#', '').replace(' ', ' ')
|
cw = cw.replace('#', '').replace(' ', ' ')
|
||||||
return cw
|
return removeInvalidCharacters(cw)
|
||||||
|
|
||||||
|
|
||||||
def _loadAutoCW(baseDir: str, nickname: str, domain: str) -> []:
|
def _loadAutoCW(baseDir: str, nickname: str, domain: str) -> []:
|
||||||
|
|
@ -880,6 +881,8 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
eventStatus=None, ticketUrl=None) -> {}:
|
eventStatus=None, ticketUrl=None) -> {}:
|
||||||
"""Creates a message
|
"""Creates a message
|
||||||
"""
|
"""
|
||||||
|
content = removeInvalidCharacters(content)
|
||||||
|
|
||||||
subject = _addAutoCW(baseDir, nickname, domain, subject, content)
|
subject = _addAutoCW(baseDir, nickname, domain, subject, content)
|
||||||
|
|
||||||
if nickname != 'news':
|
if nickname != 'news':
|
||||||
|
|
|
||||||
23
utils.py
23
utils.py
|
|
@ -18,6 +18,13 @@ from followingCalendar import addPersonToCalendar
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives import hashes
|
from cryptography.hazmat.primitives import hashes
|
||||||
|
|
||||||
|
# posts containing these strings will always get screened out,
|
||||||
|
# both incoming and outgoing.
|
||||||
|
# Could include dubious clacks or admin dogwhistles
|
||||||
|
invalidCharacters = (
|
||||||
|
'卐', '卍', '࿕', '࿖', '࿗', '࿘'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def getSHA256(msg: str):
|
def getSHA256(msg: str):
|
||||||
"""Returns a SHA256 hash of the given string
|
"""Returns a SHA256 hash of the given string
|
||||||
|
|
@ -514,17 +521,23 @@ def isEvil(domain: str) -> bool:
|
||||||
|
|
||||||
def containsInvalidChars(jsonStr: str) -> bool:
|
def containsInvalidChars(jsonStr: str) -> bool:
|
||||||
"""Does the given json string contain invalid characters?
|
"""Does the given json string contain invalid characters?
|
||||||
e.g. dubious clacks/admin dogwhistles
|
|
||||||
"""
|
"""
|
||||||
invalidStrings = {
|
for isInvalid in invalidCharacters:
|
||||||
'卐', '卍', '࿕', '࿖', '࿗', '࿘'
|
|
||||||
}
|
|
||||||
for isInvalid in invalidStrings:
|
|
||||||
if isInvalid in jsonStr:
|
if isInvalid in jsonStr:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def removeInvalidCharacters(text: str) -> str:
|
||||||
|
"""Removes any invalid characters from a string
|
||||||
|
"""
|
||||||
|
for isInvalid in invalidCharacters:
|
||||||
|
if isInvalid not in text:
|
||||||
|
continue
|
||||||
|
text = text.replace(isInvalid, '')
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
def createPersonDir(nickname: str, domain: str, baseDir: str,
|
def createPersonDir(nickname: str, domain: str, baseDir: str,
|
||||||
dirname: str) -> str:
|
dirname: str) -> str:
|
||||||
"""Create a directory for a person
|
"""Create a directory for a person
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue