Don't use a separate function for reminder posts

main
Bob Mottram 2020-06-24 13:42:07 +01:00
parent e1470a7d37
commit 326fb9fc48
2 changed files with 20 additions and 69 deletions

View File

@ -66,7 +66,6 @@ from posts import createReportPost
from posts import createUnlistedPost from posts import createUnlistedPost
from posts import createFollowersOnlyPost from posts import createFollowersOnlyPost
from posts import createDirectMessagePost from posts import createDirectMessagePost
from posts import createReminderPost
from posts import populateRepliesJson from posts import populateRepliesJson
from posts import addToField from posts import addToField
from posts import expireCache from posts import expireCache
@ -5439,33 +5438,28 @@ class PubServer(BaseHTTPRequestHandler):
return -1 return -1
elif postType == 'newreminder': elif postType == 'newreminder':
messageJson = None messageJson = None
print('A reminder was posted for ' + handle = nickname + '@' + self.server.domainFull
nickname + '@' + self.server.domainFull) print('A reminder was posted for ' + handle)
if handle not in fields['message']:
fields['message'] = handle + ' ' + fields['message']
messageJson = \ messageJson = \
createReminderPost(self.server.baseDir, createDirectMessagePost(self.server.baseDir,
nickname, nickname,
self.server.domain, self.server.domain,
self.server.port, self.server.port,
self.server.httpPrefix, self.server.httpPrefix,
fields['message'], fields['message'],
True, False, False, True, False, False,
filename, attachmentMediaType, filename, attachmentMediaType,
fields['imageDescription'], fields['imageDescription'],
self.server.useBlurHash, self.server.useBlurHash,
fields['subject'], None, None,
True, fields['schedulePost'], fields['subject'],
fields['eventDate'], True, fields['schedulePost'],
fields['eventTime'], fields['eventDate'],
fields['location']) fields['eventTime'],
fields['location'])
if messageJson: 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']: if fields['schedulePost']:
return 1 return 1
print('DEBUG: new reminder to ' + print('DEBUG: new reminder to ' +

View File

@ -1177,49 +1177,6 @@ def createDirectMessagePost(baseDir: str,
return messageJson 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, def createReportPost(baseDir: str,
nickname: str, domain: str, port: int, httpPrefix: str, nickname: str, domain: str, port: int, httpPrefix: str,
content: str, followersOnly: bool, saveToFile: bool, content: str, followersOnly: bool, saveToFile: bool,