mirror of https://gitlab.com/bashrc2/epicyon
flake8 style
parent
0f1e754913
commit
fa7c457150
35
blurhash.py
35
blurhash.py
|
@ -31,10 +31,12 @@ Very close port of the original Swift implementation by Dag Ågren.
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
|
||||||
# Alphabet for base 83
|
# Alphabet for base 83
|
||||||
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~"
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~"
|
||||||
alphabet_values = dict(zip(alphabet, range(len(alphabet))))
|
alphabet_values = dict(zip(alphabet, range(len(alphabet))))
|
||||||
|
|
||||||
|
|
||||||
def base83_decode(base83_str):
|
def base83_decode(base83_str):
|
||||||
"""
|
"""
|
||||||
Decodes a base83 string, as used in blurhash, to an integer.
|
Decodes a base83 string, as used in blurhash, to an integer.
|
||||||
|
@ -44,6 +46,7 @@ def base83_decode(base83_str):
|
||||||
value = value * 83 + alphabet_values[base83_char]
|
value = value * 83 + alphabet_values[base83_char]
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
def base83_encode(value, length):
|
def base83_encode(value, length):
|
||||||
"""
|
"""
|
||||||
Decodes an integer to a base83 string, as used in blurhash.
|
Decodes an integer to a base83 string, as used in blurhash.
|
||||||
|
@ -60,6 +63,7 @@ def base83_encode(value, length):
|
||||||
result += alphabet[int(digit)]
|
result += alphabet[int(digit)]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def srgb_to_linear(value):
|
def srgb_to_linear(value):
|
||||||
"""
|
"""
|
||||||
srgb 0-255 integer to linear 0.0-1.0 floating point conversion.
|
srgb 0-255 integer to linear 0.0-1.0 floating point conversion.
|
||||||
|
@ -69,12 +73,14 @@ def srgb_to_linear(value):
|
||||||
return value / 12.92
|
return value / 12.92
|
||||||
return math.pow((value + 0.055) / 1.055, 2.4)
|
return math.pow((value + 0.055) / 1.055, 2.4)
|
||||||
|
|
||||||
|
|
||||||
def sign_pow(value, exp):
|
def sign_pow(value, exp):
|
||||||
"""
|
"""
|
||||||
Sign-preserving exponentiation.
|
Sign-preserving exponentiation.
|
||||||
"""
|
"""
|
||||||
return math.copysign(math.pow(abs(value), exp), value)
|
return math.copysign(math.pow(abs(value), exp), value)
|
||||||
|
|
||||||
|
|
||||||
def linear_to_srgb(value):
|
def linear_to_srgb(value):
|
||||||
"""
|
"""
|
||||||
linear 0.0-1.0 floating point to srgb 0-255 integer conversion.
|
linear 0.0-1.0 floating point to srgb 0-255 integer conversion.
|
||||||
|
@ -84,6 +90,7 @@ def linear_to_srgb(value):
|
||||||
return int(value * 12.92 * 255 + 0.5)
|
return int(value * 12.92 * 255 + 0.5)
|
||||||
return int((1.055 * math.pow(value, 1 / 2.4) - 0.055) * 255 + 0.5)
|
return int((1.055 * math.pow(value, 1 / 2.4) - 0.055) * 255 + 0.5)
|
||||||
|
|
||||||
|
|
||||||
def blurhash_components(blurhash):
|
def blurhash_components(blurhash):
|
||||||
"""
|
"""
|
||||||
Decodes and returns the number of x and y components in the given blurhash.
|
Decodes and returns the number of x and y components in the given blurhash.
|
||||||
|
@ -98,6 +105,7 @@ def blurhash_components(blurhash):
|
||||||
|
|
||||||
return size_x, size_y
|
return size_x, size_y
|
||||||
|
|
||||||
|
|
||||||
def blurhash_decode(blurhash, width, height, punch=1.0, linear=False):
|
def blurhash_decode(blurhash, width, height, punch=1.0, linear=False):
|
||||||
"""
|
"""
|
||||||
Decodes the given blurhash to an image of the specified size.
|
Decodes the given blurhash to an image of the specified size.
|
||||||
|
@ -155,8 +163,7 @@ def blurhash_decode(blurhash,width,height,punch=1.0,linear=False):
|
||||||
|
|
||||||
for j in range(size_y):
|
for j in range(size_y):
|
||||||
for i in range(size_x):
|
for i in range(size_x):
|
||||||
basis= \
|
basis = math.cos(math.pi * float(x) * float(i) / float(width)) * \
|
||||||
math.cos(math.pi*float(x)*float(i)/float(width))* \
|
|
||||||
math.cos(math.pi * float(y) * float(j) / float(height))
|
math.cos(math.pi * float(y) * float(j) / float(height))
|
||||||
colour = colours[i + j * size_x]
|
colour = colours[i + j * size_x]
|
||||||
pixel[0] += colour[0] * basis
|
pixel[0] += colour[0] * basis
|
||||||
|
@ -173,6 +180,7 @@ def blurhash_decode(blurhash,width,height,punch=1.0,linear=False):
|
||||||
pixels.append(pixel_row)
|
pixels.append(pixel_row)
|
||||||
return pixels
|
return pixels
|
||||||
|
|
||||||
|
|
||||||
def blurhash_encode(image, components_x=4, components_y=4, linear=False):
|
def blurhash_encode(image, components_x=4, components_y=4, linear=False):
|
||||||
"""
|
"""
|
||||||
Calculates the blurhash for an image using the given x and y component counts.
|
Calculates the blurhash for an image using the given x and y component counts.
|
||||||
|
@ -185,8 +193,10 @@ def blurhash_encode(image,components_x=4,components_y=4,linear=False):
|
||||||
useful if you want to encode a version of your image resized to a smaller size (which
|
useful if you want to encode a version of your image resized to a smaller size (which
|
||||||
you should ideally do in linear colour).
|
you should ideally do in linear colour).
|
||||||
"""
|
"""
|
||||||
if components_x < 1 or components_x > 9 or components_y < 1 or components_y > 9:
|
if components_x < 1 or components_x > 9 or \
|
||||||
raise ValueError("x and y component counts must be between 1 and 9 inclusive.")
|
components_y < 1 or components_y > 9:
|
||||||
|
raise ValueError("x and y component counts must be " +
|
||||||
|
"between 1 and 9 inclusive.")
|
||||||
height = float(len(image))
|
height = float(len(image))
|
||||||
width = float(len(image[0]))
|
width = float(len(image[0]))
|
||||||
|
|
||||||
|
@ -214,8 +224,7 @@ def blurhash_encode(image,components_x=4,components_y=4,linear=False):
|
||||||
component = [0.0, 0.0, 0.0]
|
component = [0.0, 0.0, 0.0]
|
||||||
for y in range(int(height)):
|
for y in range(int(height)):
|
||||||
for x in range(int(width)):
|
for x in range(int(width)):
|
||||||
basis= \
|
basis = norm_factor * math.cos(math.pi * float(i) * float(x) / width) * \
|
||||||
norm_factor * math.cos(math.pi * float(i) * float(x) / width) * \
|
|
||||||
math.cos(math.pi * float(j) * float(y) / height)
|
math.cos(math.pi * float(j) * float(y) / height)
|
||||||
component[0] += basis * image_linear[y][x][0]
|
component[0] += basis * image_linear[y][x][0]
|
||||||
component[1] += basis * image_linear[y][x][1]
|
component[1] += basis * image_linear[y][x][1]
|
||||||
|
@ -227,20 +236,18 @@ def blurhash_encode(image,components_x=4,components_y=4,linear=False):
|
||||||
components.append(component)
|
components.append(component)
|
||||||
|
|
||||||
if not (i==0 and j==0):
|
if not (i==0 and j==0):
|
||||||
max_ac_component= \
|
max_ac_component = max(max_ac_component,abs(component[0]),
|
||||||
max(max_ac_component,abs(component[0]), \
|
|
||||||
abs(component[1]),abs(component[2]))
|
abs(component[1]),abs(component[2]))
|
||||||
|
|
||||||
# Encode components
|
# Encode components
|
||||||
dc_value= \
|
dc_value = (linear_to_srgb(components[0][0]) << 16) + \
|
||||||
(linear_to_srgb(components[0][0]) << 16)+ \
|
|
||||||
(linear_to_srgb(components[0][1]) << 8) + \
|
(linear_to_srgb(components[0][1]) << 8) + \
|
||||||
linear_to_srgb(components[0][2])
|
linear_to_srgb(components[0][2])
|
||||||
|
|
||||||
quant_max_ac_component= \
|
quant_max_ac_component = int(max(0, min(82,
|
||||||
int(max(0, min(82, math.floor(max_ac_component * 166 - 0.5))))
|
math.floor(max_ac_component *
|
||||||
ac_component_norm_factor= \
|
166 - 0.5))))
|
||||||
float(quant_max_ac_component+1) / 166.0
|
ac_component_norm_factor = float(quant_max_ac_component + 1) / 166.0
|
||||||
|
|
||||||
ac_values = []
|
ac_values = []
|
||||||
for r, g, b in components[1:]:
|
for r, g, b in components[1:]:
|
||||||
|
|
346
bookmarks.py
346
bookmarks.py
|
@ -7,8 +7,6 @@ __email__="bob@freedombone.net"
|
||||||
__status__ = "Production"
|
__status__ = "Production"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
|
||||||
import time
|
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from utils import removePostFromCache
|
from utils import removePostFromCache
|
||||||
from utils import urlPermitted
|
from utils import urlPermitted
|
||||||
|
@ -24,8 +22,10 @@ from webfinger import webfingerHandle
|
||||||
from auth import createBasicAuthHeader
|
from auth import createBasicAuthHeader
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
|
|
||||||
def undoBookmarksCollectionEntry(recentPostsCache: {}, \
|
|
||||||
baseDir: str,postFilename: str,objectUrl: str, \
|
def undoBookmarksCollectionEntry(recentPostsCache: {},
|
||||||
|
baseDir: str, postFilename: str,
|
||||||
|
objectUrl: str,
|
||||||
actor: str, domain: str, debug: bool) -> None:
|
actor: str, domain: str, debug: bool) -> None:
|
||||||
"""Undoes a bookmark for a particular actor
|
"""Undoes a bookmark for a particular actor
|
||||||
"""
|
"""
|
||||||
|
@ -33,10 +33,11 @@ def undoBookmarksCollectionEntry(recentPostsCache: {}, \
|
||||||
if not postJsonObject:
|
if not postJsonObject:
|
||||||
return
|
return
|
||||||
|
|
||||||
# remove any cached version of this post so that the bookmark icon is changed
|
# remove any cached version of this post so that the
|
||||||
|
# bookmark icon is changed
|
||||||
nickname = getNicknameFromActor(actor)
|
nickname = getNicknameFromActor(actor)
|
||||||
cachedPostFilename= \
|
cachedPostFilename = getCachedPostFilename(baseDir, nickname,
|
||||||
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
|
domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
@ -68,7 +69,8 @@ def undoBookmarksCollectionEntry(recentPostsCache: {}, \
|
||||||
if bookmarkItem['actor'] == actor:
|
if bookmarkItem['actor'] == actor:
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: bookmark was removed for ' + actor)
|
print('DEBUG: bookmark was removed for ' + actor)
|
||||||
postJsonObject['object']['bookmarks']['items'].remove(bookmarkItem)
|
bmIt = bookmarkItem
|
||||||
|
postJsonObject['object']['bookmarks']['items'].remove(bmIt)
|
||||||
itemFound = True
|
itemFound = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -80,13 +82,13 @@ def undoBookmarksCollectionEntry(recentPostsCache: {}, \
|
||||||
print('DEBUG: bookmarks was removed from post')
|
print('DEBUG: bookmarks was removed from post')
|
||||||
del postJsonObject['object']['bookmarks']
|
del postJsonObject['object']['bookmarks']
|
||||||
else:
|
else:
|
||||||
postJsonObject['object']['bookmarks']['totalItems']= \
|
bmItLen = len(postJsonObject['object']['bookmarks']['items'])
|
||||||
len(postJsonObject['bookmarks']['items'])
|
postJsonObject['object']['bookmarks']['totalItems'] = bmItLen
|
||||||
saveJson(postJsonObject, postFilename)
|
saveJson(postJsonObject, postFilename)
|
||||||
|
|
||||||
# remove from the index
|
# remove from the index
|
||||||
bookmarksIndexFilename= \
|
bookmarksIndexFilename = baseDir + '/accounts/' + \
|
||||||
baseDir+'/accounts/'+nickname+'@'+domain+'/bookmarks.index'
|
nickname + '@' + domain + '/bookmarks.index'
|
||||||
if not os.path.isfile(bookmarksIndexFilename):
|
if not os.path.isfile(bookmarksIndexFilename):
|
||||||
return
|
return
|
||||||
if '/' in postFilename:
|
if '/' in postFilename:
|
||||||
|
@ -106,6 +108,7 @@ def undoBookmarksCollectionEntry(recentPostsCache: {}, \
|
||||||
bookmarksIndexFile.write(indexStr)
|
bookmarksIndexFile.write(indexStr)
|
||||||
bookmarksIndexFile.close()
|
bookmarksIndexFile.close()
|
||||||
|
|
||||||
|
|
||||||
def bookmarkedByPerson(postJsonObject: {}, nickname: str, domain: str) -> bool:
|
def bookmarkedByPerson(postJsonObject: {}, nickname: str, domain: str) -> bool:
|
||||||
"""Returns True if the given post is bookmarked by the given person
|
"""Returns True if the given post is bookmarked by the given person
|
||||||
"""
|
"""
|
||||||
|
@ -117,6 +120,7 @@ def bookmarkedByPerson(postJsonObject: {}, nickname: str,domain: str) -> bool:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def noOfBookmarks(postJsonObject: {}) -> int:
|
def noOfBookmarks(postJsonObject: {}) -> int:
|
||||||
"""Returns the number of bookmarks ona given post
|
"""Returns the number of bookmarks ona given post
|
||||||
"""
|
"""
|
||||||
|
@ -133,18 +137,20 @@ def noOfBookmarks(postJsonObject: {}) -> int:
|
||||||
postJsonObject['object']['bookmarks']['totalItems'] = 0
|
postJsonObject['object']['bookmarks']['totalItems'] = 0
|
||||||
return len(postJsonObject['object']['bookmarks']['items'])
|
return len(postJsonObject['object']['bookmarks']['items'])
|
||||||
|
|
||||||
def updateBookmarksCollection(recentPostsCache: {}, \
|
|
||||||
baseDir: str,postFilename: str, \
|
def updateBookmarksCollection(recentPostsCache: {},
|
||||||
objectUrl: str, \
|
baseDir: str, postFilename: str,
|
||||||
|
objectUrl: str,
|
||||||
actor: str, domain: str, debug: bool) -> None:
|
actor: str, domain: str, debug: bool) -> None:
|
||||||
"""Updates the bookmarks collection within a post
|
"""Updates the bookmarks collection within a post
|
||||||
"""
|
"""
|
||||||
postJsonObject = loadJson(postFilename)
|
postJsonObject = loadJson(postFilename)
|
||||||
if postJsonObject:
|
if postJsonObject:
|
||||||
# remove any cached version of this post so that the bookmark icon is changed
|
# remove any cached version of this post so that the
|
||||||
|
# bookmark icon is changed
|
||||||
nickname = getNicknameFromActor(actor)
|
nickname = getNicknameFromActor(actor)
|
||||||
cachedPostFilename= \
|
cachedPostFilename = getCachedPostFilename(baseDir, nickname,
|
||||||
getCachedPostFilename(baseDir,nickname,domain,postJsonObject)
|
domain, postJsonObject)
|
||||||
if cachedPostFilename:
|
if cachedPostFilename:
|
||||||
if os.path.isfile(cachedPostFilename):
|
if os.path.isfile(cachedPostFilename):
|
||||||
os.remove(cachedPostFilename)
|
os.remove(cachedPostFilename)
|
||||||
|
@ -182,9 +188,10 @@ def updateBookmarksCollection(recentPostsCache: {}, \
|
||||||
'type': 'Bookmark',
|
'type': 'Bookmark',
|
||||||
'actor': actor
|
'actor': actor
|
||||||
}
|
}
|
||||||
postJsonObject['object']['bookmarks']['items'].append(newBookmark)
|
nb = newBookmark
|
||||||
postJsonObject['object']['bookmarks']['totalItems']= \
|
bmIt = len(postJsonObject['object']['bookmarks']['items'])
|
||||||
len(postJsonObject['object']['bookmarks']['items'])
|
postJsonObject['object']['bookmarks']['items'].append(nb)
|
||||||
|
postJsonObject['object']['bookmarks']['totalItems'] = bmIt
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: saving post with bookmarks added')
|
print('DEBUG: saving post with bookmarks added')
|
||||||
|
@ -193,20 +200,20 @@ def updateBookmarksCollection(recentPostsCache: {}, \
|
||||||
saveJson(postJsonObject, postFilename)
|
saveJson(postJsonObject, postFilename)
|
||||||
|
|
||||||
# prepend to the index
|
# prepend to the index
|
||||||
bookmarksIndexFilename= \
|
bookmarksIndexFilename = baseDir + '/accounts/' + \
|
||||||
baseDir+'/accounts/'+nickname+'@'+domain+'/bookmarks.index'
|
nickname + '@' + domain + '/bookmarks.index'
|
||||||
bookmarkIndex = postFilename.split('/')[-1]
|
bookmarkIndex = postFilename.split('/')[-1]
|
||||||
if os.path.isfile(bookmarksIndexFilename):
|
if os.path.isfile(bookmarksIndexFilename):
|
||||||
if bookmarkIndex not in open(bookmarksIndexFilename).read():
|
if bookmarkIndex not in open(bookmarksIndexFilename).read():
|
||||||
try:
|
try:
|
||||||
with open(bookmarksIndexFilename, 'r+') as bookmarksIndexFile:
|
with open(bookmarksIndexFilename, 'r+') as bmIndexFile:
|
||||||
content=bookmarksIndexFile.read()
|
content = bmIndexFile.read()
|
||||||
bookmarksIndexFile.seek(0, 0)
|
bmIndexFile.seek(0, 0)
|
||||||
bookmarksIndexFile.write(bookmarkIndex+'\n'+content)
|
bmIndexFile.write(bookmarkIndex + '\n' + content)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: bookmark added to index')
|
print('DEBUG: bookmark added to index')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('WARN: Failed to write entry to bookmarks index '+ \
|
print('WARN: Failed to write entry to bookmarks index ' +
|
||||||
bookmarksIndexFilename + ' ' + str(e))
|
bookmarksIndexFilename + ' ' + str(e))
|
||||||
else:
|
else:
|
||||||
bookmarksIndexFile = open(bookmarksIndexFilename, 'w')
|
bookmarksIndexFile = open(bookmarksIndexFilename, 'w')
|
||||||
|
@ -214,14 +221,15 @@ def updateBookmarksCollection(recentPostsCache: {}, \
|
||||||
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
bookmarksIndexFile.write(bookmarkIndex + '\n')
|
||||||
bookmarksIndexFile.close()
|
bookmarksIndexFile.close()
|
||||||
|
|
||||||
def bookmark(recentPostsCache: {}, \
|
|
||||||
session,baseDir: str,federationList: [], \
|
def bookmark(recentPostsCache: {},
|
||||||
nickname: str,domain: str,port: int, \
|
session, baseDir: str, federationList: [],
|
||||||
ccList: [],httpPrefix: str, \
|
nickname: str, domain: str, port: int,
|
||||||
objectUrl: str,actorBookmarked: str, \
|
ccList: [], httpPrefix: str,
|
||||||
clientToServer: bool, \
|
objectUrl: str, actorBookmarked: str,
|
||||||
sendThreads: [],postLog: [], \
|
clientToServer: bool,
|
||||||
personCache: {},cachedWebfingers: {}, \
|
sendThreads: [], postLog: [],
|
||||||
|
personCache: {}, cachedWebfingers: {},
|
||||||
debug: bool, projectVersion: str) -> {}:
|
debug: bool, projectVersion: str) -> {}:
|
||||||
"""Creates a bookmark
|
"""Creates a bookmark
|
||||||
actor is the person doing the bookmarking
|
actor is the person doing the bookmarking
|
||||||
|
@ -237,10 +245,6 @@ def bookmark(recentPostsCache: {}, \
|
||||||
if ':' not in domain:
|
if ':' not in domain:
|
||||||
fullDomain = domain + ':' + str(port)
|
fullDomain = domain + ':' + str(port)
|
||||||
|
|
||||||
bookmarkTo=[]
|
|
||||||
if '/statuses/' in objectUrl:
|
|
||||||
bookmarkTo=[objectUrl.split('/statuses/')[0]]
|
|
||||||
|
|
||||||
newBookmarkJson = {
|
newBookmarkJson = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'type': 'Bookmark',
|
'type': 'Bookmark',
|
||||||
|
@ -256,16 +260,16 @@ def bookmark(recentPostsCache: {}, \
|
||||||
bookmarkedPostDomain = None
|
bookmarkedPostDomain = None
|
||||||
bookmarkedPostPort = None
|
bookmarkedPostPort = None
|
||||||
if actorBookmarked:
|
if actorBookmarked:
|
||||||
bookmarkedPostNickname=getNicknameFromActor(actorBookmarked)
|
acBm = actorBookmarked
|
||||||
bookmarkedPostDomain,bookmarkedPostPort= \
|
bookmarkedPostNickname = getNicknameFromActor(acBm)
|
||||||
getDomainFromActor(actorBookmarked)
|
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm)
|
||||||
else:
|
else:
|
||||||
if '/users/' in objectUrl or \
|
if '/users/' in objectUrl or \
|
||||||
'/channel/' in objectUrl or \
|
'/channel/' in objectUrl or \
|
||||||
'/profile/' in objectUrl:
|
'/profile/' in objectUrl:
|
||||||
bookmarkedPostNickname=getNicknameFromActor(objectUrl)
|
ou = objectUrl
|
||||||
bookmarkedPostDomain,bookmarkedPostPort= \
|
bookmarkedPostNickname = getNicknameFromActor(ou)
|
||||||
getDomainFromActor(objectUrl)
|
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(ou)
|
||||||
|
|
||||||
if bookmarkedPostNickname:
|
if bookmarkedPostNickname:
|
||||||
postFilename = locatePost(baseDir, nickname, domain, objectUrl)
|
postFilename = locatePost(baseDir, nickname, domain, objectUrl)
|
||||||
|
@ -276,29 +280,31 @@ def bookmark(recentPostsCache: {}, \
|
||||||
print('DEBUG: bookmark objectUrl: ' + objectUrl)
|
print('DEBUG: bookmark objectUrl: ' + objectUrl)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
updateBookmarksCollection(recentPostsCache, \
|
updateBookmarksCollection(recentPostsCache,
|
||||||
baseDir,postFilename,objectUrl, \
|
baseDir, postFilename, objectUrl,
|
||||||
newBookmarkJson['actor'], domain, debug)
|
newBookmarkJson['actor'], domain, debug)
|
||||||
|
|
||||||
sendSignedJson(newBookmarkJson,session,baseDir, \
|
sendSignedJson(newBookmarkJson, session, baseDir,
|
||||||
nickname,domain,port, \
|
nickname, domain, port,
|
||||||
bookmarkedPostNickname, \
|
bookmarkedPostNickname,
|
||||||
bookmarkedPostDomain,bookmarkedPostPort, \
|
bookmarkedPostDomain, bookmarkedPostPort,
|
||||||
'https://www.w3.org/ns/activitystreams#Public', \
|
'https://www.w3.org/ns/activitystreams#Public',
|
||||||
httpPrefix,True,clientToServer,federationList, \
|
httpPrefix, True, clientToServer, federationList,
|
||||||
sendThreads,postLog,cachedWebfingers,personCache, \
|
sendThreads, postLog, cachedWebfingers, personCache,
|
||||||
debug, projectVersion)
|
debug, projectVersion)
|
||||||
|
|
||||||
return newBookmarkJson
|
return newBookmarkJson
|
||||||
|
|
||||||
def bookmarkPost(recentPostsCache: {}, \
|
|
||||||
session,baseDir: str,federationList: [], \
|
def bookmarkPost(recentPostsCache: {},
|
||||||
nickname: str,domain: str,port: int,httpPrefix: str, \
|
session, baseDir: str, federationList: [],
|
||||||
bookmarkNickname: str,bookmarkedomain: str,bookmarkPort: int, \
|
nickname: str, domain: str, port: int, httpPrefix: str,
|
||||||
ccList: [], \
|
bookmarkNickname: str, bookmarkedomain: str,
|
||||||
bookmarkStatusNumber: int,clientToServer: bool, \
|
bookmarkPort: int,
|
||||||
sendThreads: [],postLog: [], \
|
ccList: [],
|
||||||
personCache: {},cachedWebfingers: {}, \
|
bookmarkStatusNumber: int, clientToServer: bool,
|
||||||
|
sendThreads: [], postLog: [],
|
||||||
|
personCache: {}, cachedWebfingers: {},
|
||||||
debug: bool, projectVersion: str) -> {}:
|
debug: bool, projectVersion: str) -> {}:
|
||||||
"""Bookmarks a given status post. This is only used by unit tests
|
"""Bookmarks a given status post. This is only used by unit tests
|
||||||
"""
|
"""
|
||||||
|
@ -308,32 +314,26 @@ def bookmarkPost(recentPostsCache: {}, \
|
||||||
if ':' not in bookmarkedomain:
|
if ':' not in bookmarkedomain:
|
||||||
bookmarkedomain = bookmarkedomain + ':' + str(bookmarkPort)
|
bookmarkedomain = bookmarkedomain + ':' + str(bookmarkPort)
|
||||||
|
|
||||||
actorBookmarked= \
|
actorBookmarked = httpPrefix + '://' + bookmarkedomain + \
|
||||||
httpPrefix + '://'+bookmarkedomain+'/users/'+bookmarkNickname
|
'/users/' + bookmarkNickname
|
||||||
objectUrl = actorBookmarked + '/statuses/' + str(bookmarkStatusNumber)
|
objectUrl = actorBookmarked + '/statuses/' + str(bookmarkStatusNumber)
|
||||||
|
|
||||||
ccUrl=httpPrefix+'://'+bookmarkedomain+'/users/'+bookmarkNickname
|
return bookmark(recentPostsCache,
|
||||||
if bookmarkPort:
|
session, baseDir, federationList, nickname, domain, port,
|
||||||
if bookmarkPort!=80 and bookmarkPort!=443:
|
ccList, httpPrefix, objectUrl, actorBookmarked,
|
||||||
if ':' not in bookmarkedomain:
|
clientToServer,
|
||||||
ccUrl= \
|
sendThreads, postLog, personCache, cachedWebfingers,
|
||||||
httpPrefix+'://'+bookmarkedomain+':'+ \
|
|
||||||
str(bookmarkPort)+'/users/'+bookmarkNickname
|
|
||||||
|
|
||||||
return bookmark(recentPostsCache, \
|
|
||||||
session,baseDir,federationList,nickname,domain,port, \
|
|
||||||
ccList,httpPrefix,objectUrl,actorBookmarked,clientToServer, \
|
|
||||||
sendThreads,postLog,personCache,cachedWebfingers, \
|
|
||||||
debug, projectVersion)
|
debug, projectVersion)
|
||||||
|
|
||||||
def undoBookmark(recentPostsCache: {}, \
|
|
||||||
session,baseDir: str,federationList: [], \
|
def undoBookmark(recentPostsCache: {},
|
||||||
nickname: str,domain: str,port: int, \
|
session, baseDir: str, federationList: [],
|
||||||
ccList: [],httpPrefix: str, \
|
nickname: str, domain: str, port: int,
|
||||||
objectUrl: str,actorBookmarked: str, \
|
ccList: [], httpPrefix: str,
|
||||||
clientToServer: bool, \
|
objectUrl: str, actorBookmarked: str,
|
||||||
sendThreads: [],postLog: [], \
|
clientToServer: bool,
|
||||||
personCache: {},cachedWebfingers: {}, \
|
sendThreads: [], postLog: [],
|
||||||
|
personCache: {}, cachedWebfingers: {},
|
||||||
debug: bool, projectVersion: str) -> {}:
|
debug: bool, projectVersion: str) -> {}:
|
||||||
"""Removes a bookmark
|
"""Removes a bookmark
|
||||||
actor is the person doing the bookmarking
|
actor is the person doing the bookmarking
|
||||||
|
@ -349,10 +349,6 @@ def undoBookmark(recentPostsCache: {}, \
|
||||||
if ':' not in domain:
|
if ':' not in domain:
|
||||||
fullDomain = domain + ':' + str(port)
|
fullDomain = domain + ':' + str(port)
|
||||||
|
|
||||||
bookmarkTo=[]
|
|
||||||
if '/statuses/' in objectUrl:
|
|
||||||
bookmarkTo=[objectUrl.split('/statuses/')[0]]
|
|
||||||
|
|
||||||
newUndoBookmarkJson = {
|
newUndoBookmarkJson = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'type': 'Undo',
|
'type': 'Undo',
|
||||||
|
@ -373,45 +369,48 @@ def undoBookmark(recentPostsCache: {}, \
|
||||||
bookmarkedPostDomain = None
|
bookmarkedPostDomain = None
|
||||||
bookmarkedPostPort = None
|
bookmarkedPostPort = None
|
||||||
if actorBookmarked:
|
if actorBookmarked:
|
||||||
bookmarkedPostNickname=getNicknameFromActor(actorBookmarked)
|
acBm = actorBookmarked
|
||||||
bookmarkedPostDomain,bookmarkedPostPort= \
|
bookmarkedPostNickname = getNicknameFromActor(acBm)
|
||||||
getDomainFromActor(actorBookmarked)
|
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(acBm)
|
||||||
else:
|
else:
|
||||||
if '/users/' in objectUrl or \
|
if '/users/' in objectUrl or \
|
||||||
'/channel/' in objectUrl or \
|
'/channel/' in objectUrl or \
|
||||||
'/profile/' in objectUrl:
|
'/profile/' in objectUrl:
|
||||||
bookmarkedPostNickname=getNicknameFromActor(objectUrl)
|
ou = objectUrl
|
||||||
bookmarkedPostDomain,bookmarkedPostPort= \
|
bookmarkedPostNickname = getNicknameFromActor(ou)
|
||||||
getDomainFromActor(objectUrl)
|
bookmarkedPostDomain, bookmarkedPostPort = getDomainFromActor(ou)
|
||||||
|
|
||||||
if bookmarkedPostNickname:
|
if bookmarkedPostNickname:
|
||||||
postFilename = locatePost(baseDir, nickname, domain, objectUrl)
|
postFilename = locatePost(baseDir, nickname, domain, objectUrl)
|
||||||
if not postFilename:
|
if not postFilename:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
undoBookmarksCollectionEntry(recentPostsCache, \
|
undoBookmarksCollectionEntry(recentPostsCache,
|
||||||
baseDir,postFilename,objectUrl, \
|
baseDir, postFilename, objectUrl,
|
||||||
newBookmarkJson['actor'],domain,debug)
|
newUndoBookmarkJson['actor'],
|
||||||
|
domain, debug)
|
||||||
|
|
||||||
sendSignedJson(newUndoBookmarkJson,session,baseDir, \
|
sendSignedJson(newUndoBookmarkJson, session, baseDir,
|
||||||
nickname,domain,port, \
|
nickname, domain, port,
|
||||||
bookmarkedPostNickname,bookmarkedPostDomain,bookmarkedPostPort, \
|
bookmarkedPostNickname, bookmarkedPostDomain,
|
||||||
'https://www.w3.org/ns/activitystreams#Public', \
|
bookmarkedPostPort,
|
||||||
httpPrefix,True,clientToServer,federationList, \
|
'https://www.w3.org/ns/activitystreams#Public',
|
||||||
sendThreads,postLog,cachedWebfingers,personCache, \
|
httpPrefix, True, clientToServer, federationList,
|
||||||
|
sendThreads, postLog, cachedWebfingers, personCache,
|
||||||
debug, projectVersion)
|
debug, projectVersion)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return newUndoBookmarkJson
|
return newUndoBookmarkJson
|
||||||
|
|
||||||
def undoBookmarkPost(session,baseDir: str,federationList: [], \
|
|
||||||
nickname: str,domain: str,port: int,httpPrefix: str, \
|
def undoBookmarkPost(session, baseDir: str, federationList: [],
|
||||||
bookmarkNickname: str,bookmarkedomain: str, \
|
nickname: str, domain: str, port: int, httpPrefix: str,
|
||||||
bookmarkPort: int,ccList: [], \
|
bookmarkNickname: str, bookmarkedomain: str,
|
||||||
bookmarkStatusNumber: int,clientToServer: bool, \
|
bookmarkPort: int, ccList: [],
|
||||||
sendThreads: [],postLog: [], \
|
bookmarkStatusNumber: int, clientToServer: bool,
|
||||||
personCache: {},cachedWebfingers: {}, \
|
sendThreads: [], postLog: [],
|
||||||
|
personCache: {}, cachedWebfingers: {},
|
||||||
debug: bool) -> {}:
|
debug: bool) -> {}:
|
||||||
"""Removes a bookmarked post
|
"""Removes a bookmarked post
|
||||||
"""
|
"""
|
||||||
|
@ -421,27 +420,22 @@ def undoBookmarkPost(session,baseDir: str,federationList: [], \
|
||||||
if ':' not in bookmarkedomain:
|
if ':' not in bookmarkedomain:
|
||||||
bookmarkedomain = bookmarkedomain + ':' + str(bookmarkPort)
|
bookmarkedomain = bookmarkedomain + ':' + str(bookmarkPort)
|
||||||
|
|
||||||
objectUrl= \
|
objectUrl = httpPrefix + '://' + bookmarkedomain + \
|
||||||
httpPrefix+'://'+bookmarkedomain+'/users/'+bookmarkNickname+ \
|
'/users/' + bookmarkNickname + \
|
||||||
'/statuses/' + str(bookmarkStatusNumber)
|
'/statuses/' + str(bookmarkStatusNumber)
|
||||||
|
|
||||||
ccUrl=httpPrefix+'://'+bookmarkedomain+'/users/'+bookmarkNickname
|
return undoBookmark(session, baseDir, federationList,
|
||||||
if bookmarkPort:
|
nickname, domain, port,
|
||||||
if bookmarkPort!=80 and bookmarkPort!=443:
|
ccList, httpPrefix, objectUrl, clientToServer,
|
||||||
if ':' not in bookmarkedomain:
|
sendThreads, postLog, personCache,
|
||||||
ccUrl= \
|
cachedWebfingers, debug)
|
||||||
httpPrefix+'://'+bookmarkedomain+':'+ \
|
|
||||||
str(bookmarkPort)+'/users/'+bookmarkNickname
|
|
||||||
|
|
||||||
return undoBookmark(session,baseDir,federationList,nickname,domain,port, \
|
|
||||||
ccList,httpPrefix,objectUrl,clientToServer, \
|
|
||||||
sendThreads,postLog,personCache,cachedWebfingers,debug)
|
|
||||||
|
|
||||||
def sendBookmarkViaServer(baseDir: str,session, \
|
def sendBookmarkViaServer(baseDir: str, session,
|
||||||
fromNickname: str, password: str,
|
fromNickname: str, password: str,
|
||||||
fromDomain: str,fromPort: int, \
|
fromDomain: str, fromPort: int,
|
||||||
httpPrefix: str,bookmarkUrl: str, \
|
httpPrefix: str, bookmarkUrl: str,
|
||||||
cachedWebfingers: {},personCache: {}, \
|
cachedWebfingers: {}, personCache: {},
|
||||||
debug: bool, projectVersion: str) -> {}:
|
debug: bool, projectVersion: str) -> {}:
|
||||||
"""Creates a bookmark via c2s
|
"""Creates a bookmark via c2s
|
||||||
"""
|
"""
|
||||||
|
@ -455,12 +449,6 @@ def sendBookmarkViaServer(baseDir: str,session, \
|
||||||
if ':' not in fromDomain:
|
if ':' not in fromDomain:
|
||||||
fromDomainFull = fromDomain + ':' + str(fromPort)
|
fromDomainFull = fromDomain + ':' + str(fromPort)
|
||||||
|
|
||||||
toUrl=['https://www.w3.org/ns/activitystreams#Public']
|
|
||||||
ccUrl=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
|
||||||
|
|
||||||
if '/statuses/' in bookmarkUrl:
|
|
||||||
toUrl=[bookmarkUrl.split('/statuses/')[0]]
|
|
||||||
|
|
||||||
newBookmarkJson = {
|
newBookmarkJson = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'type': 'Bookmark',
|
'type': 'Bookmark',
|
||||||
|
@ -471,7 +459,8 @@ def sendBookmarkViaServer(baseDir: str,session, \
|
||||||
handle = httpPrefix + '://' + fromDomainFull + '/@' + fromNickname
|
handle = httpPrefix + '://' + fromDomainFull + '/@' + fromNickname
|
||||||
|
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest=webfingerHandle(session,handle,httpPrefix,cachedWebfingers, \
|
wfRequest = webfingerHandle(session, handle, httpPrefix,
|
||||||
|
cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -481,9 +470,11 @@ def sendBookmarkViaServer(baseDir: str,session, \
|
||||||
postToBox = 'outbox'
|
postToBox = 'outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName= \
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
getPersonBox(baseDir,session,wfRequest,personCache, \
|
fromPersonId, sharedInbox,
|
||||||
projectVersion,httpPrefix,fromNickname, \
|
capabilityAcquisition, avatarUrl,
|
||||||
|
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
||||||
|
projectVersion, httpPrefix, fromNickname,
|
||||||
fromDomain, postToBox)
|
fromDomain, postToBox)
|
||||||
|
|
||||||
if not inboxUrl:
|
if not inboxUrl:
|
||||||
|
@ -498,27 +489,28 @@ def sendBookmarkViaServer(baseDir: str,session, \
|
||||||
authHeader = createBasicAuthHeader(fromNickname, password)
|
authHeader = createBasicAuthHeader(fromNickname, password)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'host': fromDomain, \
|
'host': fromDomain,
|
||||||
'Content-type': 'application/json', \
|
'Content-type': 'application/json',
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult= \
|
postResult = postJson(session, newBookmarkJson, [],
|
||||||
postJson(session,newBookmarkJson,[],inboxUrl,headers,"inbox:write")
|
inboxUrl, headers, "inbox:write")
|
||||||
#if not postResult:
|
if not postResult:
|
||||||
# if debug:
|
if debug:
|
||||||
# print('DEBUG: POST announce failed for c2s to '+inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
# return 5
|
return 5
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: c2s POST bookmark success')
|
print('DEBUG: c2s POST bookmark success')
|
||||||
|
|
||||||
return newBookmarkJson
|
return newBookmarkJson
|
||||||
|
|
||||||
def sendUndoBookmarkViaServer(baseDir: str,session, \
|
|
||||||
fromNickname: str,password: str, \
|
def sendUndoBookmarkViaServer(baseDir: str, session,
|
||||||
fromDomain: str,fromPort: int, \
|
fromNickname: str, password: str,
|
||||||
httpPrefix: str,bookmarkUrl: str, \
|
fromDomain: str, fromPort: int,
|
||||||
cachedWebfingers: {},personCache: {}, \
|
httpPrefix: str, bookmarkUrl: str,
|
||||||
|
cachedWebfingers: {}, personCache: {},
|
||||||
debug: bool, projectVersion: str) -> {}:
|
debug: bool, projectVersion: str) -> {}:
|
||||||
"""Undo a bookmark via c2s
|
"""Undo a bookmark via c2s
|
||||||
"""
|
"""
|
||||||
|
@ -532,12 +524,6 @@ def sendUndoBookmarkViaServer(baseDir: str,session, \
|
||||||
if ':' not in fromDomain:
|
if ':' not in fromDomain:
|
||||||
fromDomainFull = fromDomain + ':' + str(fromPort)
|
fromDomainFull = fromDomain + ':' + str(fromPort)
|
||||||
|
|
||||||
toUrl=['https://www.w3.org/ns/activitystreams#Public']
|
|
||||||
ccUrl=httpPrefix+'://'+fromDomainFull+'/users/'+fromNickname+'/followers'
|
|
||||||
|
|
||||||
if '/statuses/' in bookmarkUrl:
|
|
||||||
toUrl=[bookmarkUrl.split('/statuses/')[0]]
|
|
||||||
|
|
||||||
newUndoBookmarkJson = {
|
newUndoBookmarkJson = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
'type': 'Undo',
|
'type': 'Undo',
|
||||||
|
@ -552,7 +538,7 @@ def sendUndoBookmarkViaServer(baseDir: str,session, \
|
||||||
handle = httpPrefix + '://' + fromDomainFull + '/@' + fromNickname
|
handle = httpPrefix + '://' + fromDomainFull + '/@' + fromNickname
|
||||||
|
|
||||||
# lookup the inbox for the To handle
|
# lookup the inbox for the To handle
|
||||||
wfRequest=webfingerHandle(session,handle,httpPrefix,cachedWebfingers, \
|
wfRequest = webfingerHandle(session, handle, httpPrefix, cachedWebfingers,
|
||||||
fromDomain, projectVersion)
|
fromDomain, projectVersion)
|
||||||
if not wfRequest:
|
if not wfRequest:
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -562,9 +548,11 @@ def sendUndoBookmarkViaServer(baseDir: str,session, \
|
||||||
postToBox = 'outbox'
|
postToBox = 'outbox'
|
||||||
|
|
||||||
# get the actor inbox for the To handle
|
# get the actor inbox for the To handle
|
||||||
inboxUrl,pubKeyId,pubKey,fromPersonId,sharedInbox,capabilityAcquisition,avatarUrl,displayName= \
|
(inboxUrl, pubKeyId, pubKey,
|
||||||
getPersonBox(baseDir,session,wfRequest,personCache, \
|
fromPersonId, sharedInbox,
|
||||||
projectVersion,httpPrefix,fromNickname, \
|
capabilityAcquisition, avatarUrl,
|
||||||
|
displayName) = getPersonBox(baseDir, session, wfRequest, personCache,
|
||||||
|
projectVersion, httpPrefix, fromNickname,
|
||||||
fromDomain, postToBox)
|
fromDomain, postToBox)
|
||||||
|
|
||||||
if not inboxUrl:
|
if not inboxUrl:
|
||||||
|
@ -579,25 +567,26 @@ def sendUndoBookmarkViaServer(baseDir: str,session, \
|
||||||
authHeader = createBasicAuthHeader(fromNickname, password)
|
authHeader = createBasicAuthHeader(fromNickname, password)
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'host': fromDomain, \
|
'host': fromDomain,
|
||||||
'Content-type': 'application/json', \
|
'Content-type': 'application/json',
|
||||||
'Authorization': authHeader
|
'Authorization': authHeader
|
||||||
}
|
}
|
||||||
postResult= \
|
postResult = postJson(session, newUndoBookmarkJson, [],
|
||||||
postJson(session,newUndoBookmarkJson,[],inboxUrl,headers,"inbox:write")
|
inboxUrl, headers, "inbox:write")
|
||||||
#if not postResult:
|
if not postResult:
|
||||||
# if debug:
|
if debug:
|
||||||
# print('DEBUG: POST announce failed for c2s to '+inboxUrl)
|
print('DEBUG: POST announce failed for c2s to ' + inboxUrl)
|
||||||
# return 5
|
return 5
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: c2s POST undo bookmark success')
|
print('DEBUG: c2s POST undo bookmark success')
|
||||||
|
|
||||||
return newUndoBookmarkJson
|
return newUndoBookmarkJson
|
||||||
|
|
||||||
def outboxBookmark(recentPostsCache: {}, \
|
|
||||||
baseDir: str,httpPrefix: str, \
|
def outboxBookmark(recentPostsCache: {},
|
||||||
nickname: str,domain: str,port: int, \
|
baseDir: str, httpPrefix: str,
|
||||||
|
nickname: str, domain: str, port: int,
|
||||||
messageJson: {}, debug: bool) -> None:
|
messageJson: {}, debug: bool) -> None:
|
||||||
""" When a bookmark request is received by the outbox from c2s
|
""" When a bookmark request is received by the outbox from c2s
|
||||||
"""
|
"""
|
||||||
|
@ -638,15 +627,16 @@ def outboxBookmark(recentPostsCache: {}, \
|
||||||
print('DEBUG: c2s bookmark post not found in inbox or outbox')
|
print('DEBUG: c2s bookmark post not found in inbox or outbox')
|
||||||
print(messageId)
|
print(messageId)
|
||||||
return True
|
return True
|
||||||
updateBookmarksCollection(recentPostsCache, \
|
updateBookmarksCollection(recentPostsCache,
|
||||||
baseDir,postFilename,messageId, \
|
baseDir, postFilename, messageId,
|
||||||
messageJson['actor'], domain, debug)
|
messageJson['actor'], domain, debug)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post bookmarked via c2s - ' + postFilename)
|
print('DEBUG: post bookmarked via c2s - ' + postFilename)
|
||||||
|
|
||||||
def outboxUndoBookmark(recentPostsCache: {}, \
|
|
||||||
baseDir: str,httpPrefix: str, \
|
def outboxUndoBookmark(recentPostsCache: {},
|
||||||
nickname: str,domain: str,port: int, \
|
baseDir: str, httpPrefix: str,
|
||||||
|
nickname: str, domain: str, port: int,
|
||||||
messageJson: {}, debug: bool) -> None:
|
messageJson: {}, debug: bool) -> None:
|
||||||
""" When an undo bookmark request is received by the outbox from c2s
|
""" When an undo bookmark request is received by the outbox from c2s
|
||||||
"""
|
"""
|
||||||
|
@ -697,8 +687,8 @@ def outboxUndoBookmark(recentPostsCache: {}, \
|
||||||
print('DEBUG: c2s undo bookmark post not found in inbox or outbox')
|
print('DEBUG: c2s undo bookmark post not found in inbox or outbox')
|
||||||
print(messageId)
|
print(messageId)
|
||||||
return True
|
return True
|
||||||
undoBookmarksCollectionEntry(recentPostsCache, \
|
undoBookmarksCollectionEntry(recentPostsCache,
|
||||||
baseDir,postFilename,messageId, \
|
baseDir, postFilename, messageId,
|
||||||
messageJson['actor'], domain, debug)
|
messageJson['actor'], domain, debug)
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: post undo bookmarked via c2s - ' + postFilename)
|
print('DEBUG: post undo bookmarked via c2s - ' + postFilename)
|
||||||
|
|
Loading…
Reference in New Issue