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 createFollowersOnlyPost
from posts import createDirectMessagePost
from posts import createReminderPost
from posts import populateRepliesJson
from posts import addToField
from posts import expireCache
@ -5439,10 +5438,12 @@ 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,
createDirectMessagePost(self.server.baseDir,
nickname,
self.server.domain,
self.server.port,
@ -5452,20 +5453,13 @@ class PubServer(BaseHTTPRequestHandler):
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 ' +

View File

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