diff --git a/daemon.py b/daemon.py
index a0f686397..fbf9b5304 100644
--- a/daemon.py
+++ b/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':
diff --git a/filters.py b/filters.py
index 60b7042e5..a8f45b085 100644
--- a/filters.py
+++ b/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:
diff --git a/posts.py b/posts.py
index c5f3462a5..77dd61c9e 100644
--- a/posts.py
+++ b/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= \
diff --git a/translations/ar.json b/translations/ar.json
index d82cd519f..50bf979e2 100644
--- a/translations/ar.json
+++ b/translations/ar.json
@@ -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"
}
diff --git a/translations/ca.json b/translations/ca.json
index 198326f8c..fcb34bc9e 100644
--- a/translations/ca.json
+++ b/translations/ca.json
@@ -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"
}
diff --git a/translations/cy.json b/translations/cy.json
index 394ac157d..0404dcaaa 100644
--- a/translations/cy.json
+++ b/translations/cy.json
@@ -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"
}
diff --git a/translations/de.json b/translations/de.json
index 6621d0515..c70ebc588 100644
--- a/translations/de.json
+++ b/translations/de.json
@@ -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"
}
diff --git a/translations/en.json b/translations/en.json
index b6585a1ea..3951814ca 100644
--- a/translations/en.json
+++ b/translations/en.json
@@ -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"
}
diff --git a/translations/es.json b/translations/es.json
index c258157b6..7ba842d5c 100644
--- a/translations/es.json
+++ b/translations/es.json
@@ -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"
}
diff --git a/translations/fr.json b/translations/fr.json
index 34a2428e7..1cbcc0919 100644
--- a/translations/fr.json
+++ b/translations/fr.json
@@ -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"
}
diff --git a/translations/ga.json b/translations/ga.json
index 776ffd41b..60dfcc994 100644
--- a/translations/ga.json
+++ b/translations/ga.json
@@ -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"
}
diff --git a/translations/hi.json b/translations/hi.json
index b0f3b5e9d..3a0377dd8 100644
--- a/translations/hi.json
+++ b/translations/hi.json
@@ -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"
}
diff --git a/translations/it.json b/translations/it.json
index 64aa78686..124166719 100644
--- a/translations/it.json
+++ b/translations/it.json
@@ -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"
}
diff --git a/translations/ja.json b/translations/ja.json
index c20796485..c2175662f 100644
--- a/translations/ja.json
+++ b/translations/ja.json
@@ -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"
}
diff --git a/translations/oc.json b/translations/oc.json
index 13a59c148..038035d2f 100644
--- a/translations/oc.json
+++ b/translations/oc.json
@@ -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"
}
diff --git a/translations/pt.json b/translations/pt.json
index a33153f42..d3e6ee602 100644
--- a/translations/pt.json
+++ b/translations/pt.json
@@ -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"
}
diff --git a/translations/ru.json b/translations/ru.json
index b689694c0..46b6fb48e 100644
--- a/translations/ru.json
+++ b/translations/ru.json
@@ -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"
}
diff --git a/translations/zh.json b/translations/zh.json
index e8fd99f1d..7d0e57591 100644
--- a/translations/zh.json
+++ b/translations/zh.json
@@ -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"
}
diff --git a/webinterface.py b/webinterface.py
index 373040bbf..920940f8f 100644
--- a/webinterface.py
+++ b/webinterface.py
@@ -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+=' '+translate['This is a bot account']+'
'
editProfileForm+=' '+translate['This is a group account']+'
'
editProfileForm+=' '+translate['Only people I follow can send me DMs']+'
'
+ editProfileForm+=' '+translate['Remove Twitter posts']+'
'
if path.startswith('/users/'+adminNickname+'/'):
editProfileForm+=' '+translate['This is a media instance']+'
'
editProfileForm+='
'