Ability to remove scheduled posts

main
Bob Mottram 2020-01-14 10:23:17 +00:00
parent cdc2b67bc7
commit fb4588d8b2
18 changed files with 69 additions and 15 deletions

View File

@ -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':

View File

@ -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

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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+=' <input type="submit" name="submitProfile" value="'+translate['Submit']+'">'
editProfileForm+=' <a href="'+pathOriginal+'"><button class="cancelbtn">'+translate['Cancel']+'</button></a>'
editProfileForm+=' </div>'
if scheduledPostsExist(baseDir,nickname,domain):
editProfileForm+=' <div class="container">'
editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="removeScheduledPosts">'+translate['Remove scheduled posts']+'<br>'
editProfileForm+=' </div>'
editProfileForm+=' <div class="container">'
editProfileForm+=' <label class="labels">'+translate['Nickname']+'</label>'
editProfileForm+=' <input type="text" name="displayNickname" value="'+displayNickname+'"><br>'