diff --git a/daemon.py b/daemon.py index c7d702358..995a24078 100644 --- a/daemon.py +++ b/daemon.py @@ -169,6 +169,7 @@ from httpsig import verifyPostHeaders from theme import setTheme from schedule import runPostSchedule from schedule import runPostScheduleWatchdog +from schedule import removeScheduledPosts from outbox import postMessageToOutbox import os import sys @@ -4197,6 +4198,9 @@ class PubServer(BaseHTTPRequestHandler): modNick,self.server.domain, \ 'instance','moderator') + if fields.get('removeScheduledPosts'): + if fields['removeScheduledPosts']=='on': + removeScheduledPosts(self.server.baseDir,nickname,self.server.domain) approveFollowers=False if fields.get('approveFollowers'): if fields['approveFollowers']=='on': diff --git a/schedule.py b/schedule.py index f9f435bb4..00ba864b3 100644 --- a/schedule.py +++ b/schedule.py @@ -153,3 +153,22 @@ def runPostScheduleWatchdog(projectVersion: str,httpd) -> None: postScheduleOriginal.clone(runPostSchedule) httpd.thrPostSchedule.start() print('Restarting scheduled posts...') + +def removeScheduledPosts(baseDir: str,nickname: str,domain: str) -> None: + """Removes any scheduled posts + """ + # remove the index + scheduleIndexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/schedule.index' + if os.path.isfile(scheduleIndexFilename): + os.remove(scheduleIndexFilename) + # remove the scheduled posts + scheduledDir=baseDir+'/accounts/'+nickname+'@'+domain+'/scheduled' + if not os.path.isdir(scheduledDir): + return + for scheduledPostFilename in os.listdir(scheduledDir): + filePath=os.path.join(scheduledDir,scheduledPostFilename) + try: + if os.path.isfile(filePath): + os.remove(filePath) + except: + pass diff --git a/translations/ar.json b/translations/ar.json index 327b90955..d82cd519f 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "البريد الإلكتروني", "PGP": "PGP", - "This is a scheduled post.": "هذا هو المقرر المقرر." + "This is a scheduled post.": "هذا هو المقرر المقرر.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/ca.json b/translations/ca.json index 28b7bd63d..198326f8c 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "Correu electrònic", "PGP": "PGP", - "This is a scheduled post.": "Aquesta és una publicació programada." + "This is a scheduled post.": "Aquesta és una publicació programada.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/cy.json b/translations/cy.json index 0a1c38768..394ac157d 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "E-bost", "PGP": "PGP", - "This is a scheduled post.": "Mae hon yn swydd wedi'i hamserlennu." + "This is a scheduled post.": "Mae hon yn swydd wedi'i hamserlennu.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/de.json b/translations/de.json index c7e7d3e6c..6621d0515 100644 --- a/translations/de.json +++ b/translations/de.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "Email", "PGP": "PGP", - "This is a scheduled post.": "Dies ist ein geplanter Beitrag." + "This is a scheduled post.": "Dies ist ein geplanter Beitrag.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/en.json b/translations/en.json index 7e2488412..b6585a1ea 100644 --- a/translations/en.json +++ b/translations/en.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "Email", "PGP": "PGP", - "This is a scheduled post.": "This is a scheduled post." + "This is a scheduled post.": "This is a scheduled post.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/es.json b/translations/es.json index c00e555ea..c258157b6 100644 --- a/translations/es.json +++ b/translations/es.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "Email", "PGP": "PGP", - "This is a scheduled post.": "Esta es una publicación programada." + "This is a scheduled post.": "Esta es una publicación programada.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/fr.json b/translations/fr.json index 2733be6af..34a2428e7 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "Email", "PGP": "PGP", - "This is a scheduled post.": "Il s'agit d'un article programmé." + "This is a scheduled post.": "Il s'agit d'un article programmé.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/ga.json b/translations/ga.json index 9b1b368a5..776ffd41b 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "Ríomhphost", "PGP": "PGP", - "This is a scheduled post.": "Is post sceidealta é seo." + "This is a scheduled post.": "Is post sceidealta é seo.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/hi.json b/translations/hi.json index 7fe5dc6a4..b0f3b5e9d 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "ईमेल", "PGP": "PGP", - "This is a scheduled post.": "यह एक अनुसूचित पद है।" + "This is a scheduled post.": "यह एक अनुसूचित पद है।", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/it.json b/translations/it.json index 61490e2c7..64aa78686 100644 --- a/translations/it.json +++ b/translations/it.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "E-mail", "PGP": "PGP", - "This is a scheduled post.": "Questo è un post programmato" + "This is a scheduled post.": "Questo è un post programmato", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/ja.json b/translations/ja.json index 31fa110d3..c20796485 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "Eメール", "PGP": "PGP", - "This is a scheduled post.": "これはスケジュールされた投稿です。" + "This is a scheduled post.": "これはスケジュールされた投稿です。", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/oc.json b/translations/oc.json index dda9fda2f..13a59c148 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -201,5 +201,6 @@ "Matrix": "Matrix", "Email": "Email", "PGP": "PGP", - "This is a scheduled post.": "This is a scheduled post." + "This is a scheduled post.": "This is a scheduled post.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/pt.json b/translations/pt.json index 9be07693c..a33153f42 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "Email", "PGP": "PGP", - "This is a scheduled post.": "Esta é uma postagem agendada." + "This is a scheduled post.": "Esta é uma postagem agendada.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/ru.json b/translations/ru.json index 691bd734a..b689694c0 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "Эл. адрес", "PGP": "PGP", - "This is a scheduled post.": "Это запланированный пост." + "This is a scheduled post.": "Это запланированный пост.", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/translations/zh.json b/translations/zh.json index cbacacf98..e8fd99f1d 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -205,5 +205,6 @@ "Matrix": "Matrix", "Email": "电子邮件", "PGP": "PGP", - "This is a scheduled post.": "这是预定的帖子。" + "This is a scheduled post.": "这是预定的帖子。", + "Remove scheduled posts": "Remove scheduled posts" } diff --git a/webinterface.py b/webinterface.py index 2957026af..75860776e 100644 --- a/webinterface.py +++ b/webinterface.py @@ -564,6 +564,16 @@ def htmlSkillsSearch(translate: {},baseDir: str, \ skillSearchForm+=htmlFooter() return skillSearchForm +def scheduledPostsExist(baseDir: str,nickname: str,domain: str) -> bool: + """Returns true if there are posts scheduled to be delivered + """ + scheduleIndexFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/schedule.index' + if not os.path.isfile(scheduleIndexFilename): + return False + if '#users#' in open(scheduleIndexFilename).read(): + return True + return False + def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,httpPrefix: str) -> str: """Shows the edit profile screen """ @@ -716,6 +726,12 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h editProfileForm+=' ' editProfileForm+=' ' editProfileForm+=' ' + + if scheduledPostsExist(baseDir,nickname,domain): + editProfileForm+='
' + editProfileForm+=' '+translate['Remove scheduled posts']+'
' + editProfileForm+='
' + editProfileForm+='
' editProfileForm+=' ' editProfileForm+='
'