mirror of https://gitlab.com/bashrc2/epicyon
Wanted timeline on profile
parent
1bafb775ef
commit
872f545179
|
@ -10202,6 +10202,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
path.endswith('/followers') or \
|
path.endswith('/followers') or \
|
||||||
path.endswith('/skills') or \
|
path.endswith('/skills') or \
|
||||||
path.endswith('/roles') or \
|
path.endswith('/roles') or \
|
||||||
|
path.endswith('/wanted') or \
|
||||||
path.endswith('/shares'):
|
path.endswith('/shares'):
|
||||||
divertToLoginScreen = False
|
divertToLoginScreen = False
|
||||||
|
|
||||||
|
@ -14577,6 +14578,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.path = self.path.replace('/tlblogs/', '/tlblogs')
|
self.path = self.path.replace('/tlblogs/', '/tlblogs')
|
||||||
self.path = self.path.replace('/inbox/', '/inbox')
|
self.path = self.path.replace('/inbox/', '/inbox')
|
||||||
self.path = self.path.replace('/shares/', '/shares')
|
self.path = self.path.replace('/shares/', '/shares')
|
||||||
|
self.path = self.path.replace('/wanted/', '/wanted')
|
||||||
self.path = self.path.replace('/sharedInbox/', '/sharedInbox')
|
self.path = self.path.replace('/sharedInbox/', '/sharedInbox')
|
||||||
|
|
||||||
if self.path == '/inbox':
|
if self.path == '/inbox':
|
||||||
|
@ -15021,7 +15023,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 15)
|
self._benchmarkPOSTtimings(POSTstartTime, POSTtimings, 15)
|
||||||
|
|
||||||
if self.path.endswith('/outbox') or self.path.endswith('/shares'):
|
if self.path.endswith('/outbox') or \
|
||||||
|
self.path.endswith('/wanted') or \
|
||||||
|
self.path.endswith('/shares'):
|
||||||
if usersInPath:
|
if usersInPath:
|
||||||
if authorized:
|
if authorized:
|
||||||
self.outboxAuthenticated = True
|
self.outboxAuthenticated = True
|
||||||
|
@ -15038,6 +15042,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# check that the post is to an expected path
|
# check that the post is to an expected path
|
||||||
if not (self.path.endswith('/outbox') or
|
if not (self.path.endswith('/outbox') or
|
||||||
self.path.endswith('/inbox') or
|
self.path.endswith('/inbox') or
|
||||||
|
self.path.endswith('/wanted') or
|
||||||
self.path.endswith('/shares') or
|
self.path.endswith('/shares') or
|
||||||
self.path.endswith('/moderationaction') or
|
self.path.endswith('/moderationaction') or
|
||||||
self.path == '/sharedInbox'):
|
self.path == '/sharedInbox'):
|
||||||
|
|
214
shares.py
214
shares.py
|
@ -737,6 +737,220 @@ def sendUndoShareViaServer(baseDir: str, session,
|
||||||
return undoShareJson
|
return undoShareJson
|
||||||
|
|
||||||
|
|
||||||
|
def sendWantedViaServer(baseDir, session,
|
||||||
|
fromNickname: str, password: str,
|
||||||
|
fromDomain: str, fromPort: int,
|
||||||
|
httpPrefix: str, displayName: str,
|
||||||
|
summary: str, imageFilename: str,
|
||||||
|
itemQty: float, itemType: str, itemCategory: str,
|
||||||
|
location: str, duration: str,
|
||||||
|
cachedWebfingers: {}, personCache: {},
|
||||||
|
debug: bool, projectVersion: str,
|
||||||
|
itemMaxPrice: str, itemCurrency: str) -> {}:
|
||||||
|
"""Creates a wanted item via c2s
|
||||||
|
"""
|
||||||
|
if not session:
|
||||||
|
print('WARN: No session for sendWantedViaServer')
|
||||||
|
return 6
|
||||||
|
|
||||||
|
# convert $4.23 to 4.23 USD
|
||||||
|
newItemMaxPrice, newItemCurrency = getPriceFromString(itemMaxPrice)
|
||||||
|
if newItemMaxPrice != itemMaxPrice:
|
||||||
|
itemMaxPrice = newItemMaxPrice
|
||||||
|
if not itemCurrency:
|
||||||
|
if newItemCurrency != itemCurrency:
|
||||||
|
itemCurrency = newItemCurrency
|
||||||
|
|
||||||
|
fromDomainFull = getFullDomain(fromDomain, fromPort)
|
||||||
|
|
||||||
|
toUrl = 'https://www.w3.org/ns/activitystreams#Public'
|
||||||
|
ccUrl = httpPrefix + '://' + fromDomainFull + \
|
||||||
|
'/users/' + fromNickname + '/followers'
|
||||||
|
|
||||||
|
actor = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname
|
||||||
|
newShareJson = {
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
'type': 'Add',
|
||||||
|
'actor': actor,
|
||||||
|
'target': actor + '/wanted',
|
||||||
|
'object': {
|
||||||
|
"type": "Offer",
|
||||||
|
"displayName": displayName,
|
||||||
|
"summary": summary,
|
||||||
|
"itemQty": float(itemQty),
|
||||||
|
"itemType": itemType,
|
||||||
|
"category": itemCategory,
|
||||||
|
"location": location,
|
||||||
|
"duration": duration,
|
||||||
|
"itemPrice": itemMaxPrice,
|
||||||
|
"itemCurrency": itemCurrency,
|
||||||
|
'to': [toUrl],
|
||||||
|
'cc': [ccUrl]
|
||||||
|
},
|
||||||
|
'to': [toUrl],
|
||||||
|
'cc': [ccUrl]
|
||||||
|
}
|
||||||
|
|
||||||
|
handle = httpPrefix + '://' + fromDomainFull + '/@' + fromNickname
|
||||||
|
|
||||||
|
# lookup the inbox for the To handle
|
||||||
|
wfRequest = \
|
||||||
|
webfingerHandle(session, handle, httpPrefix,
|
||||||
|
cachedWebfingers,
|
||||||
|
fromDomain, projectVersion, debug, False)
|
||||||
|
if not wfRequest:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: share webfinger failed for ' + handle)
|
||||||
|
return 1
|
||||||
|
if not isinstance(wfRequest, dict):
|
||||||
|
print('WARN: wanted webfinger for ' + handle +
|
||||||
|
' did not return a dict. ' + str(wfRequest))
|
||||||
|
return 1
|
||||||
|
|
||||||
|
postToBox = 'outbox'
|
||||||
|
|
||||||
|
# get the actor inbox for the To handle
|
||||||
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
|
fromPersonId, sharedInbox,
|
||||||
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
|
personCache, projectVersion,
|
||||||
|
httpPrefix, fromNickname,
|
||||||
|
fromDomain, postToBox,
|
||||||
|
83653)
|
||||||
|
|
||||||
|
if not inboxUrl:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: wanted no ' + postToBox +
|
||||||
|
' was found for ' + handle)
|
||||||
|
return 3
|
||||||
|
if not fromPersonId:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: wanted no actor was found for ' + handle)
|
||||||
|
return 4
|
||||||
|
|
||||||
|
authHeader = createBasicAuthHeader(fromNickname, password)
|
||||||
|
|
||||||
|
if imageFilename:
|
||||||
|
headers = {
|
||||||
|
'host': fromDomain,
|
||||||
|
'Authorization': authHeader
|
||||||
|
}
|
||||||
|
postResult = \
|
||||||
|
postImage(session, imageFilename, [],
|
||||||
|
inboxUrl.replace('/' + postToBox, '/wanted'),
|
||||||
|
headers)
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
'host': fromDomain,
|
||||||
|
'Content-type': 'application/json',
|
||||||
|
'Authorization': authHeader
|
||||||
|
}
|
||||||
|
postResult = \
|
||||||
|
postJson(httpPrefix, fromDomainFull,
|
||||||
|
session, newShareJson, [], inboxUrl, headers, 30, True)
|
||||||
|
if not postResult:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: POST wanted failed for c2s to ' + inboxUrl)
|
||||||
|
# return 5
|
||||||
|
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: c2s POST wanted item success')
|
||||||
|
|
||||||
|
return newShareJson
|
||||||
|
|
||||||
|
|
||||||
|
def sendUndoWantedViaServer(baseDir: str, session,
|
||||||
|
fromNickname: str, password: str,
|
||||||
|
fromDomain: str, fromPort: int,
|
||||||
|
httpPrefix: str, displayName: str,
|
||||||
|
cachedWebfingers: {}, personCache: {},
|
||||||
|
debug: bool, projectVersion: str) -> {}:
|
||||||
|
"""Undoes a wanted item via c2s
|
||||||
|
"""
|
||||||
|
if not session:
|
||||||
|
print('WARN: No session for sendUndoWantedViaServer')
|
||||||
|
return 6
|
||||||
|
|
||||||
|
fromDomainFull = getFullDomain(fromDomain, fromPort)
|
||||||
|
|
||||||
|
toUrl = 'https://www.w3.org/ns/activitystreams#Public'
|
||||||
|
ccUrl = httpPrefix + '://' + fromDomainFull + \
|
||||||
|
'/users/' + fromNickname + '/followers'
|
||||||
|
|
||||||
|
actor = httpPrefix + '://' + fromDomainFull + '/users/' + fromNickname
|
||||||
|
undoShareJson = {
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
'type': 'Remove',
|
||||||
|
'actor': actor,
|
||||||
|
'target': actor + '/wanted',
|
||||||
|
'object': {
|
||||||
|
"type": "Offer",
|
||||||
|
"displayName": displayName,
|
||||||
|
'to': [toUrl],
|
||||||
|
'cc': [ccUrl]
|
||||||
|
},
|
||||||
|
'to': [toUrl],
|
||||||
|
'cc': [ccUrl]
|
||||||
|
}
|
||||||
|
|
||||||
|
handle = httpPrefix + '://' + fromDomainFull + '/@' + fromNickname
|
||||||
|
|
||||||
|
# lookup the inbox for the To handle
|
||||||
|
wfRequest = \
|
||||||
|
webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
|
fromDomain, projectVersion, debug, False)
|
||||||
|
if not wfRequest:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: unwant webfinger failed for ' + handle)
|
||||||
|
return 1
|
||||||
|
if not isinstance(wfRequest, dict):
|
||||||
|
print('WARN: unwant webfinger for ' + handle +
|
||||||
|
' did not return a dict. ' + str(wfRequest))
|
||||||
|
return 1
|
||||||
|
|
||||||
|
postToBox = 'outbox'
|
||||||
|
|
||||||
|
# get the actor inbox for the To handle
|
||||||
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
|
fromPersonId, sharedInbox,
|
||||||
|
avatarUrl, displayName) = getPersonBox(baseDir, session, wfRequest,
|
||||||
|
personCache, projectVersion,
|
||||||
|
httpPrefix, fromNickname,
|
||||||
|
fromDomain, postToBox,
|
||||||
|
12663)
|
||||||
|
|
||||||
|
if not inboxUrl:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: unwant no ' + postToBox +
|
||||||
|
' was found for ' + handle)
|
||||||
|
return 3
|
||||||
|
if not fromPersonId:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: unwant no actor was found for ' + handle)
|
||||||
|
return 4
|
||||||
|
|
||||||
|
authHeader = createBasicAuthHeader(fromNickname, password)
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
'host': fromDomain,
|
||||||
|
'Content-type': 'application/json',
|
||||||
|
'Authorization': authHeader
|
||||||
|
}
|
||||||
|
postResult = \
|
||||||
|
postJson(httpPrefix, fromDomainFull,
|
||||||
|
session, undoShareJson, [], inboxUrl,
|
||||||
|
headers, 30, True)
|
||||||
|
if not postResult:
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: POST unwant failed for c2s to ' + inboxUrl)
|
||||||
|
# return 5
|
||||||
|
|
||||||
|
if debug:
|
||||||
|
print('DEBUG: c2s POST unwant success')
|
||||||
|
|
||||||
|
return undoShareJson
|
||||||
|
|
||||||
|
|
||||||
def getSharedItemsCatalogViaServer(baseDir, session,
|
def getSharedItemsCatalogViaServer(baseDir, session,
|
||||||
nickname: str, password: str,
|
nickname: str, password: str,
|
||||||
domain: str, port: int,
|
domain: str, port: int,
|
||||||
|
|
|
@ -404,7 +404,7 @@ def htmlEditLinks(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
if '/users/' not in path:
|
if '/users/' not in path:
|
||||||
return ''
|
return ''
|
||||||
path = path.replace('/inbox', '').replace('/outbox', '')
|
path = path.replace('/inbox', '').replace('/outbox', '')
|
||||||
path = path.replace('/shares', '')
|
path = path.replace('/shares', '').replace('/wanted', '')
|
||||||
|
|
||||||
nickname = getNicknameFromActor(path)
|
nickname = getNicknameFromActor(path)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
|
|
|
@ -525,7 +525,7 @@ def htmlEditNewswire(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
if '/users/' not in path:
|
if '/users/' not in path:
|
||||||
return ''
|
return ''
|
||||||
path = path.replace('/inbox', '').replace('/outbox', '')
|
path = path.replace('/inbox', '').replace('/outbox', '')
|
||||||
path = path.replace('/shares', '')
|
path = path.replace('/shares', '').replace('/wanted', '')
|
||||||
|
|
||||||
nickname = getNicknameFromActor(path)
|
nickname = getNicknameFromActor(path)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
|
|
|
@ -521,6 +521,7 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
rolesButton = 'button'
|
rolesButton = 'button'
|
||||||
skillsButton = 'button'
|
skillsButton = 'button'
|
||||||
sharesButton = 'button'
|
sharesButton = 'button'
|
||||||
|
wantedButton = 'button'
|
||||||
if selected == 'posts':
|
if selected == 'posts':
|
||||||
postsButton = 'buttonselected'
|
postsButton = 'buttonselected'
|
||||||
elif selected == 'following':
|
elif selected == 'following':
|
||||||
|
@ -533,6 +534,8 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
skillsButton = 'buttonselected'
|
skillsButton = 'buttonselected'
|
||||||
elif selected == 'shares':
|
elif selected == 'shares':
|
||||||
sharesButton = 'buttonselected'
|
sharesButton = 'buttonselected'
|
||||||
|
elif selected == 'wanted':
|
||||||
|
wantedButton = 'buttonselected'
|
||||||
loginButton = ''
|
loginButton = ''
|
||||||
|
|
||||||
followApprovalsSection = ''
|
followApprovalsSection = ''
|
||||||
|
@ -802,6 +805,10 @@ def htmlProfile(rssIconAtTop: bool,
|
||||||
' <a href="' + usersPath + '/shares#buttonheader">' + \
|
' <a href="' + usersPath + '/shares#buttonheader">' + \
|
||||||
'<button class="' + sharesButton + '"><span>' + \
|
'<button class="' + sharesButton + '"><span>' + \
|
||||||
translate['Shares'] + ' </span></button></a>'
|
translate['Shares'] + ' </span></button></a>'
|
||||||
|
profileStr += \
|
||||||
|
' <a href="' + usersPath + '/wanted#buttonheader">' + \
|
||||||
|
'<button class="' + wantedButton + '"><span>' + \
|
||||||
|
translate['Wanted'] + ' </span></button></a>'
|
||||||
profileStr += logoutStr + editProfileStr
|
profileStr += logoutStr + editProfileStr
|
||||||
profileStr += ' </center>'
|
profileStr += ' </center>'
|
||||||
profileStr += '</div>'
|
profileStr += '</div>'
|
||||||
|
@ -1820,7 +1827,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
|
||||||
"""Shows the edit profile screen
|
"""Shows the edit profile screen
|
||||||
"""
|
"""
|
||||||
path = path.replace('/inbox', '').replace('/outbox', '')
|
path = path.replace('/inbox', '').replace('/outbox', '')
|
||||||
path = path.replace('/shares', '')
|
path = path.replace('/shares', '').replace('/wanted', '')
|
||||||
nickname = getNicknameFromActor(path)
|
nickname = getNicknameFromActor(path)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return ''
|
return ''
|
||||||
|
|
Loading…
Reference in New Issue