From 326fb9fc48cbb0adca877fefb926db9231aebc85 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 24 Jun 2020 13:42:07 +0100 Subject: [PATCH] Don't use a separate function for reminder posts --- daemon.py | 46 ++++++++++++++++++++-------------------------- posts.py | 43 ------------------------------------------- 2 files changed, 20 insertions(+), 69 deletions(-) diff --git a/daemon.py b/daemon.py index 9cc9130a..09d1d041 100644 --- a/daemon.py +++ b/daemon.py @@ -66,7 +66,6 @@ from posts import createReportPost from posts import createUnlistedPost from posts import createFollowersOnlyPost from posts import createDirectMessagePost -from posts import createReminderPost from posts import populateRepliesJson from posts import addToField from posts import expireCache @@ -5439,33 +5438,28 @@ class PubServer(BaseHTTPRequestHandler): return -1 elif postType == 'newreminder': messageJson = None - print('A reminder was posted for ' + - nickname + '@' + self.server.domainFull) + handle = nickname + '@' + self.server.domainFull + print('A reminder was posted for ' + handle) + if handle not in fields['message']: + fields['message'] = handle + ' ' + fields['message'] messageJson = \ - createReminderPost(self.server.baseDir, - nickname, - self.server.domain, - self.server.port, - self.server.httpPrefix, - fields['message'], - True, False, False, - filename, attachmentMediaType, - fields['imageDescription'], - self.server.useBlurHash, - fields['subject'], - True, fields['schedulePost'], - fields['eventDate'], - fields['eventTime'], - fields['location']) + createDirectMessagePost(self.server.baseDir, + nickname, + self.server.domain, + self.server.port, + self.server.httpPrefix, + fields['message'], + True, False, False, + filename, attachmentMediaType, + fields['imageDescription'], + self.server.useBlurHash, + None, None, + fields['subject'], + True, fields['schedulePost'], + fields['eventDate'], + fields['eventTime'], + fields['location']) if messageJson: - # ensure that this is only being sent to the author - messageJson['object']['cc'] = [] - messageJson['cc'] = [] - messageJson['object']['to'] = [ - self.server.httpPrefix + ':\\' + - self.server.domainFull + '/users/' + nickname - ] - messageJson['to'] = messageJson['object']['to'] if fields['schedulePost']: return 1 print('DEBUG: new reminder to ' + diff --git a/posts.py b/posts.py index 79396fa8..4b1a09d8 100644 --- a/posts.py +++ b/posts.py @@ -1177,49 +1177,6 @@ def createDirectMessagePost(baseDir: str, return messageJson -def createReminderPost(baseDir: str, - nickname: str, domain: str, port: int, - httpPrefix: str, - content: str, followersOnly: bool, - saveToFile: bool, clientToServer: bool, - attachImageFilename: str, mediaType: str, - imageDescription: str, useBlurhash: bool, - subject=None, debug=False, - schedulePost=False, - eventDate=None, eventTime=None, - location=None) -> {}: - """Reminder post to self - For example, adding something to your calendar to remind you of an event - """ - postTo = None - postCc = None - domainFull = domain - if port: - if port != 80 and port != 443: - domainFull = domain + ':' + str(port) - handle = '@' + nickname + '@' + domainFull - if handle not in content: - content = handle + ' ' + content - messageJson = \ - createPostBase(baseDir, nickname, domain, port, - postTo, postCc, - httpPrefix, content, followersOnly, saveToFile, - clientToServer, - attachImageFilename, mediaType, - imageDescription, useBlurhash, - False, False, None, None, subject, - schedulePost, eventDate, eventTime, location) - # mentioned recipients go into To rather than Cc - messageJson['to'] = messageJson['object']['cc'] - messageJson['object']['to'] = messageJson['to'] - messageJson['cc'] = [] - messageJson['object']['cc'] = [] - if schedulePost: - savePostToBox(baseDir, httpPrefix, messageJson['object']['id'], - nickname, domain, messageJson, 'scheduled') - return messageJson - - def createReportPost(baseDir: str, nickname: str, domain: str, port: int, httpPrefix: str, content: str, followersOnly: bool, saveToFile: bool,