Reintroduce conversation field

main
Bob Mottram 2021-08-08 17:52:32 +01:00
parent 05e7c73b5c
commit 361c8fb6bd
9 changed files with 174 additions and 65 deletions

View File

@ -421,6 +421,7 @@ class PubServer(BaseHTTPRequestHandler):
eventDate = None
eventTime = None
location = None
conversationId = None
city = getSpoofedCity(self.server.city,
self.server.baseDir,
nickname, self.server.domain)
@ -441,7 +442,8 @@ class PubServer(BaseHTTPRequestHandler):
eventDate,
eventTime,
location, False,
self.server.systemLanguage)
self.server.systemLanguage,
conversationId)
if messageJson:
# name field contains the answer
messageJson['object']['name'] = answer
@ -2363,7 +2365,7 @@ class PubServer(BaseHTTPRequestHandler):
accessKeys = self.server.keyShortcuts[nickname]
customSubmitText = getConfigParam(baseDir, 'customSubmitText')
conversationId = None
msg = htmlNewPost(self.server.cssCache,
False, self.server.translate,
baseDir,
@ -2378,7 +2380,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.newswire,
self.server.themeName,
True, accessKeys,
customSubmitText).encode('utf-8')
customSubmitText,
conversationId).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, callingDomain)
@ -2476,7 +2479,7 @@ class PubServer(BaseHTTPRequestHandler):
accessKeys = self.server.keyShortcuts[nickname]
customSubmitText = getConfigParam(baseDir, 'customSubmitText')
conversationId = None
msg = htmlNewPost(self.server.cssCache,
False, self.server.translate,
baseDir,
@ -2490,7 +2493,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.newswire,
self.server.themeName,
True, accessKeys,
customSubmitText).encode('utf-8')
customSubmitText,
conversationId).encode('utf-8')
msglen = len(msg)
self._set_headers('text/html', msglen,
cookie, callingDomain)
@ -10433,7 +10437,7 @@ class PubServer(BaseHTTPRequestHandler):
shareDescription: str, replyPageNumber: int,
domain: str, domainFull: str,
GETstartTime, GETtimings: {}, cookie,
noDropDown: bool) -> bool:
noDropDown: bool, conversationId: str) -> bool:
"""Shows the new post screen
"""
isNewPostEndpoint = False
@ -10471,7 +10475,8 @@ class PubServer(BaseHTTPRequestHandler):
self.server.newswire,
self.server.themeName,
noDropDown, accessKeys,
customSubmitText).encode('utf-8')
customSubmitText,
conversationId).encode('utf-8')
if not msg:
print('Error replying to ' + inReplyToUrl)
self._404()
@ -12526,8 +12531,13 @@ class PubServer(BaseHTTPRequestHandler):
replyToList = []
replyPageNumber = 1
shareDescription = None
conversationId = None
# replytoActor = None
if htmlGET:
if '?conversationId=' in self.path:
conversationId = self.path.split('?conversationId=')[1]
if '?' in conversationId:
conversationId = conversationId.split('?')[0]
# public reply
if '?replyto=' in self.path:
inReplyToUrl = self.path.split('?replyto=')[1]
@ -12699,7 +12709,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.domain,
self.server.domainFull,
GETstartTime, GETtimings,
cookie, noDropDown):
cookie, noDropDown, conversationId):
return
self._benchmarkGETtimings(GETstartTime, GETtimings,
@ -13478,6 +13488,9 @@ class PubServer(BaseHTTPRequestHandler):
city = getSpoofedCity(self.server.city,
self.server.baseDir,
nickname, self.server.domain)
conversationId = None
if fields['conversationId']:
conversationId = fields['conversationId']
messageJson = \
createPublicPost(self.server.baseDir,
nickname,
@ -13493,7 +13506,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['subject'], fields['schedulePost'],
fields['eventDate'], fields['eventTime'],
fields['location'], False,
self.server.systemLanguage)
self.server.systemLanguage,
conversationId)
if messageJson:
if fields['schedulePost']:
return 1
@ -13552,6 +13566,9 @@ class PubServer(BaseHTTPRequestHandler):
saveToFile = False
clientToServer = False
city = None
conversationId = None
if fields['conversationId']:
conversationId = fields['conversationId']
messageJson = \
createBlogPost(self.server.baseDir, nickname,
self.server.domain, self.server.port,
@ -13568,7 +13585,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['eventDate'],
fields['eventTime'],
fields['location'],
self.server.systemLanguage)
self.server.systemLanguage,
conversationId)
if messageJson:
if fields['schedulePost']:
return 1
@ -13682,6 +13700,11 @@ class PubServer(BaseHTTPRequestHandler):
followersOnly = False
saveToFile = False
clientToServer = False
conversationId = None
if fields['conversationId']:
conversationId = fields['conversationId']
messageJson = \
createUnlistedPost(self.server.baseDir,
nickname,
@ -13700,7 +13723,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['eventDate'],
fields['eventTime'],
fields['location'],
self.server.systemLanguage)
self.server.systemLanguage,
conversationId)
if messageJson:
if fields['schedulePost']:
return 1
@ -13722,6 +13746,11 @@ class PubServer(BaseHTTPRequestHandler):
followersOnly = True
saveToFile = False
clientToServer = False
conversationId = None
if fields['conversationId']:
conversationId = fields['conversationId']
messageJson = \
createFollowersOnlyPost(self.server.baseDir,
nickname,
@ -13742,7 +13771,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['eventDate'],
fields['eventTime'],
fields['location'],
self.server.systemLanguage)
self.server.systemLanguage,
conversationId)
if messageJson:
if fields['schedulePost']:
return 1
@ -13767,6 +13797,11 @@ class PubServer(BaseHTTPRequestHandler):
followersOnly = True
saveToFile = False
clientToServer = False
conversationId = None
if fields['conversationId']:
conversationId = fields['conversationId']
messageJson = \
createDirectMessagePost(self.server.baseDir,
nickname,
@ -13788,7 +13823,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['eventDate'],
fields['eventTime'],
fields['location'],
self.server.systemLanguage)
self.server.systemLanguage,
conversationId)
if messageJson:
if fields['schedulePost']:
return 1
@ -13818,6 +13854,7 @@ class PubServer(BaseHTTPRequestHandler):
saveToFile = False
clientToServer = False
commentsEnabled = False
conversationId = None
messageJson = \
createDirectMessagePost(self.server.baseDir,
nickname,
@ -13836,7 +13873,8 @@ class PubServer(BaseHTTPRequestHandler):
fields['eventDate'],
fields['eventTime'],
fields['location'],
self.server.systemLanguage)
self.server.systemLanguage,
conversationId)
if messageJson:
if fields['schedulePost']:
return 1

View File

@ -416,7 +416,7 @@ def _desktopReplyToPost(session, postId: str,
cachedWebfingers: {}, personCache: {},
debug: bool, subject: str,
screenreader: str, systemLanguage: str,
espeak) -> None:
espeak, conversationId: str) -> None:
"""Use the desktop client to send a reply to the most recent post
"""
if '://' not in postId:
@ -470,7 +470,7 @@ def _desktopReplyToPost(session, postId: str,
attachedImageDescription, city,
cachedWebfingers, personCache, isArticle,
systemLanguage, debug, postId, postId,
subject) == 0:
conversationId, subject) == 0:
sayStr = 'Reply sent'
else:
sayStr = 'Reply failed'
@ -486,6 +486,7 @@ def _desktopNewPost(session,
espeak) -> None:
"""Use the desktop client to create a new post
"""
conversationId = None
sayStr = 'Create new post'
_sayCommand(sayStr, sayStr, screenreader, systemLanguage, espeak)
sayStr = 'Type your post, then press Enter.'
@ -532,7 +533,7 @@ def _desktopNewPost(session,
attachedImageDescription, city,
cachedWebfingers, personCache, isArticle,
systemLanguage, debug, None, None,
subject) == 0:
conversationId, subject) == 0:
sayStr = 'Post sent'
else:
sayStr = 'Post failed'
@ -1140,6 +1141,7 @@ def _desktopNewDMbase(session, toHandle: str,
espeak) -> None:
"""Use the desktop client to create a new direct message
"""
conversationId = None
toPort = port
if '://' in toHandle:
toNickname = getNicknameFromActor(toHandle)
@ -1225,7 +1227,7 @@ def _desktopNewDMbase(session, toHandle: str,
attachedImageDescription, city,
cachedWebfingers, personCache, isArticle,
systemLanguage, debug, None, None,
subject) == 0:
conversationId, subject) == 0:
sayStr = 'Direct message sent'
else:
sayStr = 'Direct message failed'
@ -1670,6 +1672,10 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
subject = None
if postJsonObject['object'].get('summary'):
subject = postJsonObject['object']['summary']
conversationId = None
if postJsonObject['object'].get('conversation'):
conversationId = \
postJsonObject['object']['conversation']
sessionReply = createSession(proxyType)
_desktopReplyToPost(sessionReply, postId,
baseDir, nickname, password,
@ -1677,7 +1683,7 @@ def runDesktopClient(baseDir: str, proxyType: str, httpPrefix: str,
cachedWebfingers, personCache,
debug, subject,
screenreader, systemLanguage,
espeak)
espeak, conversationId)
refreshTimeline = True
print('')
elif (commandStr == 'post' or commandStr == 'p' or

View File

@ -115,6 +115,10 @@ parser.add_argument('--userAgentBlocks', type=str,
parser.add_argument('--libretranslate', dest='libretranslateUrl', type=str,
default=None,
help='URL for LibreTranslate service')
parser.add_argument('--conversationId', dest='conversationId', type=str,
default=None,
help='Conversation Id which can be added ' +
'when sending a post')
parser.add_argument('--libretranslateApiKey',
dest='libretranslateApiKey', type=str,
default=None,
@ -1179,7 +1183,7 @@ if args.message:
attachedImageDescription, city,
cachedWebfingers, personCache, isArticle,
args.language, args.debug,
replyTo, replyTo, subject)
replyTo, replyTo, args.conversationId, subject)
for i in range(10):
# TODO detect send success/fail
time.sleep(1)
@ -2408,6 +2412,7 @@ if args.testdata:
testEventTime = None
testLocation = None
testIsArticle = False
conversationId = None
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
"like this is totally just a #test man",
@ -2420,7 +2425,7 @@ if args.testdata:
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, args.language)
testIsArticle, args.language, conversationId)
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
"Zoiks!!!",
testFollowersOnly,
@ -2432,7 +2437,7 @@ if args.testdata:
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, args.language)
testIsArticle, args.language, conversationId)
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
"Hey scoob we need like a hundred more #milkshakes",
testFollowersOnly,
@ -2444,7 +2449,7 @@ if args.testdata:
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, args.language)
testIsArticle, args.language, conversationId)
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
"Getting kinda spooky around here",
testFollowersOnly,
@ -2456,7 +2461,7 @@ if args.testdata:
'someone', testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, args.language)
testIsArticle, args.language, conversationId)
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
"And they would have gotten away with it too" +
"if it wasn't for those pesky hackers",
@ -2469,7 +2474,7 @@ if args.testdata:
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, args.language)
testIsArticle, args.language, conversationId)
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
"man these centralized sites are like the worst!",
testFollowersOnly,
@ -2481,7 +2486,7 @@ if args.testdata:
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, args.language)
testIsArticle, args.language, conversationId)
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
"another mystery solved #test",
testFollowersOnly,
@ -2493,7 +2498,7 @@ if args.testdata:
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, args.language)
testIsArticle, args.language, conversationId)
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
"let's go bowling",
testFollowersOnly,
@ -2505,7 +2510,7 @@ if args.testdata:
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, args.language)
testIsArticle, args.language, conversationId)
domainFull = domain + ':' + str(port)
clearFollows(baseDir, nickname, domain)
followPerson(baseDir, nickname, domain, 'maxboardroom', domainFull,

View File

@ -2111,6 +2111,7 @@ def _bounceDM(senderPostId: str, session, httpPrefix: str,
eventDate = None
eventTime = None
location = None
conversationId = None
postJsonObject = \
createDirectMessagePost(baseDir, nickname, domain, port,
httpPrefix, content, followersOnly,
@ -2121,7 +2122,7 @@ def _bounceDM(senderPostId: str, session, httpPrefix: str,
inReplyTo, inReplyToAtomUri,
subject, debug, schedulePost,
eventDate, eventTime, location,
systemLanguage)
systemLanguage, conversationId)
if not postJsonObject:
print('WARN: unable to create bounce message to ' + sendingHandle)
return False

View File

@ -594,13 +594,15 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
mediaType = None
imageDescription = None
city = 'London, England'
conversationId = None
blog = createNewsPost(baseDir,
domain, port, httpPrefix,
rssDescription,
followersOnly, saveToFile,
attachImageFilename, mediaType,
imageDescription, city,
rssTitle, systemLanguage)
rssTitle, systemLanguage,
conversationId)
if not blog:
continue

View File

@ -915,7 +915,8 @@ def _createPostS2S(baseDir: str, nickname: str, domain: str, port: int,
tags: [], attachImageFilename: str,
mediaType: str, imageDescription: str, city: str,
postObjectType: str, summary: str,
inReplyToAtomUri: str, systemLanguage: str) -> {}:
inReplyToAtomUri: str, systemLanguage: str,
conversationId: str) -> {}:
"""Creates a new server-to-server post
"""
actorUrl = httpPrefix + '://' + domain + '/users/' + nickname
@ -926,6 +927,8 @@ def _createPostS2S(baseDir: str, nickname: str, domain: str, port: int,
httpPrefix + '://' + domain + '/@' + nickname + '/' + statusNumber
newPostAttributedTo = \
httpPrefix + '://' + domain + '/users/' + nickname
if not conversationId:
conversationId = newPostId
newPost = {
'@context': postContext,
'id': newPostId + '/activity',
@ -936,6 +939,7 @@ def _createPostS2S(baseDir: str, nickname: str, domain: str, port: int,
'cc': toCC,
'object': {
'id': newPostId,
'conversation': conversationId,
'type': postObjectType,
'summary': summary,
'inReplyTo': inReplyTo,
@ -983,7 +987,8 @@ def _createPostC2S(baseDir: str, nickname: str, domain: str, port: int,
tags: [], attachImageFilename: str,
mediaType: str, imageDescription: str, city: str,
postObjectType: str, summary: str,
inReplyToAtomUri: str, systemLanguage: str) -> {}:
inReplyToAtomUri: str, systemLanguage: str,
conversationId: str) -> {}:
"""Creates a new client-to-server post
"""
idStr = \
@ -991,9 +996,12 @@ def _createPostC2S(baseDir: str, nickname: str, domain: str, port: int,
'/statuses/' + statusNumber + '/replies'
newPostUrl = \
httpPrefix + '://' + domain + '/@' + nickname + '/' + statusNumber
if not conversationId:
conversationId = newPostId
newPost = {
"@context": postContext,
'id': newPostId,
'conversation': conversationId,
'type': postObjectType,
'summary': summary,
'inReplyTo': inReplyTo,
@ -1153,7 +1161,8 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
repliesModerationOption: str,
anonymousParticipationEnabled: bool,
eventStatus: str, ticketUrl: str,
systemLanguage: str) -> {}:
systemLanguage: str,
conversationId: str) -> {}:
"""Creates a message
"""
content = removeInvalidChars(content)
@ -1282,7 +1291,8 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
tags, attachImageFilename,
mediaType, imageDescription, city,
postObjectType, summary,
inReplyToAtomUri, systemLanguage)
inReplyToAtomUri, systemLanguage,
conversationId)
else:
newPost = \
_createPostC2S(baseDir, nickname, domain, port,
@ -1293,7 +1303,8 @@ def _createPostBase(baseDir: str, nickname: str, domain: str, port: int,
tags, attachImageFilename,
mediaType, imageDescription, city,
postObjectType, summary,
inReplyToAtomUri, systemLanguage)
inReplyToAtomUri, systemLanguage,
conversationId)
_createPostMentions(ccUrl, newPost, toRecipients, tags)
@ -1532,7 +1543,8 @@ def createPublicPost(baseDir: str,
eventDate: str, eventTime: str,
location: str,
isArticle: bool,
systemLanguage: str) -> {}:
systemLanguage: str,
conversationId: str) -> {}:
"""Public post
"""
domainFull = getFullDomain(domain, port)
@ -1562,7 +1574,8 @@ def createPublicPost(baseDir: str,
maximumAttendeeCapacity,
repliesModerationOption,
anonymousParticipationEnabled,
eventStatus, ticketUrl, systemLanguage)
eventStatus, ticketUrl, systemLanguage,
conversationId)
def _appendCitationsToBlogPost(baseDir: str,
@ -1604,7 +1617,8 @@ def createBlogPost(baseDir: str,
inReplyTo: str, inReplyToAtomUri: str,
subject: str, schedulePost: bool,
eventDate: str, eventTime: str,
location: str, systemLanguage: str) -> {}:
location: str, systemLanguage: str,
conversationId: str) -> {}:
blogJson = \
createPublicPost(baseDir,
nickname, domain, port, httpPrefix,
@ -1615,7 +1629,7 @@ def createBlogPost(baseDir: str,
inReplyTo, inReplyToAtomUri, subject,
schedulePost,
eventDate, eventTime, location,
True, systemLanguage)
True, systemLanguage, conversationId)
blogJson['object']['url'] = \
blogJson['object']['url'].replace('/@', '/users/')
_appendCitationsToBlogPost(baseDir, nickname, domain, blogJson)
@ -1628,7 +1642,8 @@ def createNewsPost(baseDir: str,
content: str, followersOnly: bool, saveToFile: bool,
attachImageFilename: str, mediaType: str,
imageDescription: str, city: str,
subject: str, systemLanguage: str) -> {}:
subject: str, systemLanguage: str,
conversationId: str) -> {}:
clientToServer = False
inReplyTo = None
inReplyToAtomUri = None
@ -1646,7 +1661,7 @@ def createNewsPost(baseDir: str,
inReplyTo, inReplyToAtomUri, subject,
schedulePost,
eventDate, eventTime, location,
True, systemLanguage)
True, systemLanguage, conversationId)
blog['object']['type'] = 'Article'
return blog
@ -1675,7 +1690,8 @@ def createQuestionPost(baseDir: str,
False, False, None, None, subject,
False, None, None, None, None, None,
None, None, None,
None, None, None, None, None, systemLanguage)
None, None, None, None, None, systemLanguage,
None)
messageJson['object']['type'] = 'Question'
messageJson['object']['oneOf'] = []
messageJson['object']['votersCount'] = 0
@ -1706,7 +1722,8 @@ def createUnlistedPost(baseDir: str,
inReplyTo: str, inReplyToAtomUri: str,
subject: str, schedulePost: bool,
eventDate: str, eventTime: str,
location: str, systemLanguage: str) -> {}:
location: str, systemLanguage: str,
conversationId: str) -> {}:
"""Unlisted post. This has the #Public and followers links inverted.
"""
domainFull = getFullDomain(domain, port)
@ -1722,7 +1739,8 @@ def createUnlistedPost(baseDir: str,
inReplyTo, inReplyToAtomUri, subject,
schedulePost, eventDate, eventTime, location,
None, None, None, None, None,
None, None, None, None, None, systemLanguage)
None, None, None, None, None, systemLanguage,
conversationId)
def createFollowersOnlyPost(baseDir: str,
@ -1737,7 +1755,8 @@ def createFollowersOnlyPost(baseDir: str,
inReplyToAtomUri: str,
subject: str, schedulePost: bool,
eventDate: str, eventTime: str,
location: str, systemLanguage: str) -> {}:
location: str, systemLanguage: str,
conversationId: str) -> {}:
"""Followers only post
"""
domainFull = getFullDomain(domain, port)
@ -1753,7 +1772,8 @@ def createFollowersOnlyPost(baseDir: str,
inReplyTo, inReplyToAtomUri, subject,
schedulePost, eventDate, eventTime, location,
None, None, None, None, None,
None, None, None, None, None, systemLanguage)
None, None, None, None, None, systemLanguage,
conversationId)
def getMentionedPeople(baseDir: str, httpPrefix: str,
@ -1805,7 +1825,8 @@ def createDirectMessagePost(baseDir: str,
subject: str, debug: bool,
schedulePost: bool,
eventDate: str, eventTime: str,
location: str, systemLanguage: str) -> {}:
location: str, systemLanguage: str,
conversationId: str) -> {}:
"""Direct Message post
"""
content = resolvePetnames(baseDir, nickname, domain, content)
@ -1828,7 +1849,8 @@ def createDirectMessagePost(baseDir: str,
inReplyTo, inReplyToAtomUri, subject,
schedulePost, eventDate, eventTime, location,
None, None, None, None, None,
None, None, None, None, None, systemLanguage)
None, None, None, None, None, systemLanguage,
conversationId)
# mentioned recipients go into To rather than Cc
messageJson['to'] = messageJson['object']['cc']
messageJson['object']['to'] = messageJson['to']
@ -1918,7 +1940,8 @@ def createReportPost(baseDir: str,
True, False, None, None, subject,
False, None, None, None, None, None,
None, None, None,
None, None, None, None, None, systemLanguage)
None, None, None, None, None, systemLanguage,
None)
if not postJsonObject:
continue
@ -2014,6 +2037,7 @@ def sendPost(projectVersion: str,
"""Post to another inbox. Used by unit tests.
"""
withDigest = True
conversationId = None
if toNickname == 'inbox':
# shared inbox actor on @domain@domain
@ -2069,7 +2093,8 @@ def sendPost(projectVersion: str,
inReplyToAtomUri, subject,
False, None, None, None, None, None,
None, None, None,
None, None, None, None, None, systemLanguage)
None, None, None, None, None, systemLanguage,
conversationId)
# get the senders private key
privateKeyPem = _getPersonKey(nickname, domain, baseDir, 'private')
@ -2152,6 +2177,7 @@ def sendPostViaServer(projectVersion: str,
debug: bool = False,
inReplyTo: str = None,
inReplyToAtomUri: str = None,
conversationId: str = None,
subject: str = None) -> int:
"""Send a post via a proxy (c2s)
"""
@ -2230,7 +2256,8 @@ def sendPostViaServer(projectVersion: str,
inReplyToAtomUri, subject,
False, None, None, None, None, None,
None, None, None,
None, None, None, None, None, systemLanguage)
None, None, None, None, None, systemLanguage,
conversationId)
authHeader = createBasicAuthHeader(fromNickname, password)

View File

@ -517,6 +517,7 @@ def createServerAlice(path: str, domain: str, port: int,
testEventTime = None
testLocation = None
testIsArticle = False
conversationId = None
createPublicPost(path, nickname, domain, port, httpPrefix,
"No wise fish would go anywhere without a porpoise",
testFollowersOnly,
@ -529,7 +530,7 @@ def createServerAlice(path: str, domain: str, port: int,
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
createPublicPost(path, nickname, domain, port, httpPrefix,
"Curiouser and curiouser!",
testFollowersOnly,
@ -542,7 +543,7 @@ def createServerAlice(path: str, domain: str, port: int,
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
createPublicPost(path, nickname, domain, port, httpPrefix,
"In the gardens of memory, in the palace " +
"of dreams, that is where you and I shall meet",
@ -556,7 +557,7 @@ def createServerAlice(path: str, domain: str, port: int,
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
regenerateIndexForBox(path, nickname, domain, 'outbox')
global testServerAliceRunning
testServerAliceRunning = True
@ -648,6 +649,7 @@ def createServerBob(path: str, domain: str, port: int,
testEventTime = None
testLocation = None
testIsArticle = False
conversationId = None
createPublicPost(path, nickname, domain, port, httpPrefix,
"It's your life, live it your way.",
testFollowersOnly,
@ -660,7 +662,7 @@ def createServerBob(path: str, domain: str, port: int,
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
createPublicPost(path, nickname, domain, port, httpPrefix,
"One of the things I've realised is that " +
"I am very simple",
@ -674,7 +676,7 @@ def createServerBob(path: str, domain: str, port: int,
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
createPublicPost(path, nickname, domain, port, httpPrefix,
"Quantum physics is a bit of a passion of mine",
testFollowersOnly,
@ -687,7 +689,7 @@ def createServerBob(path: str, domain: str, port: int,
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
regenerateIndexForBox(path, nickname, domain, 'outbox')
global testServerBobRunning
testServerBobRunning = True
@ -2353,6 +2355,7 @@ def _testCreatePerson():
commentsEnabled = True
attachImageFilename = None
mediaType = None
conversationId = None
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
content, followersOnly, saveToFile, clientToServer,
commentsEnabled, attachImageFilename, mediaType,
@ -2360,7 +2363,7 @@ def _testCreatePerson():
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
os.chdir(currDir)
shutil.rmtree(baseDir)
@ -2495,6 +2498,7 @@ def testClientToServer():
cachedWebfingers = {}
personCache = {}
password = 'alicepass'
conversationId = None
outboxPath = aliceDir + '/accounts/alice@' + aliceDomain + '/outbox'
inboxPath = bobDir + '/accounts/bob@' + bobDomain + '/inbox'
assert len([name for name in os.listdir(outboxPath)
@ -2511,7 +2515,8 @@ def testClientToServer():
attachedImageFilename, mediaType,
attachedImageDescription, city,
cachedWebfingers, personCache, isArticle,
systemLanguage, True, None, None, None)
systemLanguage, True, None, None,
conversationId, None)
print('sendResult: ' + str(sendResult))
for i in range(30):
@ -3753,6 +3758,7 @@ def _testReplyToPublicPost() -> None:
testEventTime = None
testLocation = None
testIsArticle = False
conversationId = None
reply = \
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
content, followersOnly, saveToFile,
@ -3762,7 +3768,7 @@ def _testReplyToPublicPost() -> None:
testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
# print(str(reply))
assert reply['object']['content'] == \
'<p><span class=\"h-card\">' + \
@ -4283,6 +4289,7 @@ def _testLinksWithinPost() -> None:
testEventTime = None
testLocation = None
testIsArticle = False
conversationId = None
postJsonObject = \
createPublicPost(baseDir, nickname, domain, port, httpPrefix,
@ -4293,7 +4300,7 @@ def _testLinksWithinPost() -> None:
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
assert postJsonObject['object']['content'] == \
'<p>This is a test post with links.<br><br>' + \
@ -4329,7 +4336,7 @@ def _testLinksWithinPost() -> None:
testInReplyTo, testInReplyToAtomUri,
testSubject, testSchedulePost,
testEventDate, testEventTime, testLocation,
testIsArticle, systemLanguage)
testIsArticle, systemLanguage, conversationId)
assert postJsonObject['object']['content'] == content
assert postJsonObject['object']['contentMap'][systemLanguage] == content

View File

@ -184,7 +184,8 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
domainFull: str,
defaultTimeline: str, newswire: {},
theme: str, noDropDown: bool,
accessKeys: {}, customSubmitText: str) -> str:
accessKeys: {}, customSubmitText: str,
conversationId: str) -> str:
"""New post screen
"""
replyStr = ''
@ -541,6 +542,12 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
dropdownFollowersSuffix += '?mention=' + mentionedActor
dropdownDMSuffix += '?mention=' + mentionedActor
dropdownReportSuffix += '?mention=' + mentionedActor
if conversationId and inReplyTo:
dropdownNewPostSuffix += '?conversationId=' + conversationId
dropdownNewBlogSuffix += '?conversationId=' + conversationId
dropdownUnlistedSuffix += '?conversationId=' + conversationId
dropdownFollowersSuffix += '?conversationId=' + conversationId
dropdownDMSuffix += '?conversationId=' + conversationId
dropDownContent = ''
if not reportUrl and not shareDescription:
@ -568,6 +575,10 @@ def htmlNewPost(cssCache: {}, mediaInstance: bool, translate: {},
'<form enctype="multipart/form-data" method="POST" ' + \
'accept-charset="UTF-8" action="' + \
path + '?' + endpoint + '?page=' + str(pageNumber) + '">\n'
if conversationId:
newPostForm += \
' <input type="hidden" name="conversationId" value="' + \
conversationId + '">'
newPostForm += ' <div class="vertical-center">\n'
newPostForm += \
' <label for="nickname"><b>' + newPostText + '</b></label>\n'

View File

@ -276,7 +276,8 @@ def _getAvatarImageHtml(showAvatarOptions: bool,
def _getReplyIconHtml(nickname: str, isPublicRepeat: bool,
showIcons: bool, commentsEnabled: bool,
postJsonObject: {}, pageNumberParam: str,
translate: {}, systemLanguage: str) -> str:
translate: {}, systemLanguage: str,
conversationId: str) -> str:
"""Returns html for the reply icon/button
"""
replyStr = ''
@ -302,11 +303,15 @@ def _getReplyIconHtml(nickname: str, isPublicRepeat: bool,
replyStr = ''
replyToThisPostStr = translate['Reply to this post']
conversationStr = ''
if conversationId:
conversationStr = '?conversationId=' + conversationId
if isPublicRepeat:
replyStr += \
' <a class="imageAnchor" href="/users/' + \
nickname + '?replyto=' + replyToLink + \
'?actor=' + postJsonObject['actor'] + \
conversationStr + \
'" title="' + replyToThisPostStr + '">\n'
else:
if isDM(postJsonObject):
@ -315,6 +320,7 @@ def _getReplyIconHtml(nickname: str, isPublicRepeat: bool,
'<a class="imageAnchor" href="/users/' + nickname + \
'?replydm=' + replyToLink + \
'?actor=' + postJsonObject['actor'] + \
conversationStr + \
'" title="' + replyToThisPostStr + '">\n'
else:
replyStr += \
@ -322,6 +328,7 @@ def _getReplyIconHtml(nickname: str, isPublicRepeat: bool,
'<a class="imageAnchor" href="/users/' + nickname + \
'?replyfollowers=' + replyToLink + \
'?actor=' + postJsonObject['actor'] + \
conversationStr + \
'" title="' + replyToThisPostStr + '">\n'
replyStr += \
@ -1350,10 +1357,15 @@ def individualPostAsHtml(allowDownloads: bool,
if postJsonObject['object']['rejectReplies']:
commentsEnabled = False
conversationId = None
if postJsonObject['object']['conversation']:
conversationId = postJsonObject['object']['conversation']
replyStr = _getReplyIconHtml(nickname, isPublicRepeat,
showIcons, commentsEnabled,
postJsonObject, pageNumberParam,
translate, systemLanguage)
translate, systemLanguage,
conversationId)
_logPostTiming(enableTimingLog, postStartTime, '10')