mirror of https://gitlab.com/bashrc2/epicyon
Optionally remove twitter crossposts
parent
a8a90b9245
commit
fad14d0f0c
13
daemon.py
13
daemon.py
|
@ -4252,6 +4252,19 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if not followDMsActive:
|
||||
if os.path.isfile(followDMsFilename):
|
||||
os.remove(followDMsFilename)
|
||||
# remove Twitter retweets
|
||||
removeTwitterFilename= \
|
||||
self.server.baseDir+'/accounts/'+ \
|
||||
nickname+'@'+self.server.domain+'/.removeTwitter'
|
||||
removeTwitterActive=False
|
||||
if fields.get('removeTwitter'):
|
||||
if fields['removeTwitter']=='on':
|
||||
removeTwitterActive=True
|
||||
with open(removeTwitterFilename, "w") as removeTwitterFile:
|
||||
removeTwitterFile.write('\n')
|
||||
if not removeTwitterActive:
|
||||
if os.path.isfile(removeTwitterFilename):
|
||||
os.remove(removeTwitterFilename)
|
||||
# this account is a bot
|
||||
if fields.get('isBot'):
|
||||
if fields['isBot']=='on':
|
||||
|
|
17
filters.py
17
filters.py
|
@ -37,13 +37,28 @@ def removeFilter(baseDir: str,nickname: str,domain: str, \
|
|||
os.rename(filtersFilename+'.new',filtersFilename)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def isTwitterPost(content: str) -> bool:
|
||||
"""Returns true if the given post content is a retweet or twitter crosspost
|
||||
"""
|
||||
if content.contains('/twitter.com') or content.contains('@twitter.com'):
|
||||
return True
|
||||
elif content.contains('RT:'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def isFiltered(baseDir: str,nickname: str,domain: str,content: str) -> bool:
|
||||
"""Should the given content be filtered out?
|
||||
This is a simple type of filter which just matches words, not a regex
|
||||
You can add individual words or use word1+word2 to indicate that two
|
||||
words must be present although not necessarily adjacent
|
||||
"""
|
||||
# optionally remove retweets
|
||||
removeTwitter=baseDir+'/accounts/'+nickname+'@'+domain+'/.removeTwitter'
|
||||
if os.path.isfile(removeTwitter):
|
||||
if isTwitterPost(content):
|
||||
return True
|
||||
|
||||
filtersFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/filters.txt'
|
||||
if os.path.isfile(filtersFilename):
|
||||
with open(filtersFilename, 'r') as fp:
|
||||
|
|
7
posts.py
7
posts.py
|
@ -51,6 +51,7 @@ from content import replaceEmojiFromTags
|
|||
from auth import createBasicAuthHeader
|
||||
from config import getConfigParam
|
||||
from blocking import isBlocked
|
||||
from filters import isFiltered
|
||||
try:
|
||||
from BeautifulSoup import BeautifulSoup
|
||||
except ImportError:
|
||||
|
@ -2721,6 +2722,12 @@ def downloadAnnounce(session,baseDir: str,httpPrefix: str, \
|
|||
rejectAnnounce(announceFilename)
|
||||
#pprint(announcedJson)
|
||||
return None
|
||||
if not announcedJson.get('content'):
|
||||
rejectAnnounce(announceFilename)
|
||||
return None
|
||||
if isFiltered(baseDir,nickname,domain,announcedJson['content']):
|
||||
rejectAnnounce(announceFilename)
|
||||
return None
|
||||
|
||||
# wrap in create to be consistent with other posts
|
||||
announcedJson= \
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "البريد الإلكتروني",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "هذا هو المقرر المقرر.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "Correu electrònic",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "Aquesta és una publicació programada.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "E-bost",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "Mae hon yn swydd wedi'i hamserlennu.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "Email",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "Dies ist ein geplanter Beitrag.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "Email",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "This is a scheduled post.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "Email",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "Esta es una publicación programada.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "Email",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "Il s'agit d'un article programmé.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "Ríomhphost",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "Is post sceidealta é seo.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "ईमेल",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "यह एक अनुसूचित पद है।",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "E-mail",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "Questo è un post programmato",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "Eメール",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "これはスケジュールされた投稿です。",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -202,5 +202,6 @@
|
|||
"Email": "Email",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "This is a scheduled post.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "Email",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "Esta é uma postagem agendada.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "Эл. адрес",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "Это запланированный пост.",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -206,5 +206,6 @@
|
|||
"Email": "电子邮件",
|
||||
"PGP": "PGP",
|
||||
"This is a scheduled post.": "这是预定的帖子。",
|
||||
"Remove scheduled posts": "Remove scheduled posts"
|
||||
"Remove scheduled posts": "Remove scheduled posts",
|
||||
"Remove Twitter posts": "Remove Twitter posts"
|
||||
}
|
||||
|
|
|
@ -597,6 +597,7 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
|
|||
isBot=''
|
||||
isGroup=''
|
||||
followDMs=''
|
||||
removeTwitter=''
|
||||
mediaInstanceStr=''
|
||||
displayNickname=nickname
|
||||
bioStr=''
|
||||
|
@ -631,6 +632,8 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
|
|||
isBot=''
|
||||
if os.path.isfile(baseDir+'/accounts/'+nickname+'@'+domain+'/.followDMs'):
|
||||
followDMs='checked'
|
||||
if os.path.isfile(baseDir+'/accounts/'+nickname+'@'+domain+'/.removeTwitter'):
|
||||
removeTwitter='checked'
|
||||
|
||||
mediaInstance=getConfigParam(baseDir,"mediaInstance")
|
||||
if mediaInstance:
|
||||
|
@ -772,6 +775,7 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
|
|||
editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="isBot" '+isBot+'>'+translate['This is a bot account']+'<br>'
|
||||
editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="isGroup" '+isGroup+'>'+translate['This is a group account']+'<br>'
|
||||
editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="followDMs" '+followDMs+'>'+translate['Only people I follow can send me DMs']+'<br>'
|
||||
editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="removeTwitter" '+removeTwitter+'>'+translate['Remove Twitter posts']+'<br>'
|
||||
if path.startswith('/users/'+adminNickname+'/'):
|
||||
editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="mediaInstance" '+mediaInstanceStr+'>'+translate['This is a media instance']+'<br>'
|
||||
editProfileForm+=' <br><b><label class="labels">'+translate['Filtered words']+'</label></b>'
|
||||
|
|
Loading…
Reference in New Issue