mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
f6e842d6b8
commit
133566c821
477
daemon.py
477
daemon.py
|
@ -78,24 +78,24 @@ from person import person_unsnooze
|
||||||
from posts import get_original_post_from_announce_url
|
from posts import get_original_post_from_announce_url
|
||||||
from posts import save_post_to_box
|
from posts import save_post_to_box
|
||||||
from posts import get_instance_actor_key
|
from posts import get_instance_actor_key
|
||||||
from posts import removePostInteractions
|
from posts import remove_post_interactions
|
||||||
from posts import outboxMessageCreateWrap
|
from posts import outbox_message_create_wrap
|
||||||
from posts import getPinnedPostAsJson
|
from posts import get_pinned_post_as_json
|
||||||
from posts import pinPost
|
from posts import pin_post
|
||||||
from posts import jsonPinPost
|
from posts import json_pin_post
|
||||||
from posts import undoPinnedPost
|
from posts import undo_pinned_post
|
||||||
from posts import isModerator
|
from posts import is_moderator
|
||||||
from posts import createQuestionPost
|
from posts import create_question_post
|
||||||
from posts import createPublicPost
|
from posts import create_public_post
|
||||||
from posts import createBlogPost
|
from posts import create_blog_post
|
||||||
from posts import createReportPost
|
from posts import create_report_post
|
||||||
from posts import createUnlistedPost
|
from posts import create_unlisted_post
|
||||||
from posts import createFollowersOnlyPost
|
from posts import create_followers_only_post
|
||||||
from posts import createDirectMessagePost
|
from posts import create_direct_message_post
|
||||||
from posts import populateRepliesJson
|
from posts import populate_replies_json
|
||||||
from posts import addToField
|
from posts import add_to_field
|
||||||
from posts import expireCache
|
from posts import expire_cache
|
||||||
from inbox import clearQueueItems
|
from inbox import clear_queue_items
|
||||||
from inbox import inboxPermittedMessage
|
from inbox import inboxPermittedMessage
|
||||||
from inbox import inboxMessageHasParams
|
from inbox import inboxMessageHasParams
|
||||||
from inbox import runInboxQueue
|
from inbox import runInboxQueue
|
||||||
|
@ -500,25 +500,25 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname, self.server.domain)
|
nickname, self.server.domain)
|
||||||
|
|
||||||
message_json = \
|
message_json = \
|
||||||
createPublicPost(self.server.base_dir,
|
create_public_post(self.server.base_dir,
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain, self.server.port,
|
self.server.domain, self.server.port,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
answer, False, False, False,
|
answer, False, False, False,
|
||||||
commentsEnabled,
|
commentsEnabled,
|
||||||
attachImageFilename, mediaType,
|
attachImageFilename, mediaType,
|
||||||
imageDescription, city,
|
imageDescription, city,
|
||||||
inReplyTo,
|
inReplyTo,
|
||||||
inReplyToAtomUri,
|
inReplyToAtomUri,
|
||||||
subject,
|
subject,
|
||||||
schedulePost,
|
schedulePost,
|
||||||
eventDate,
|
eventDate,
|
||||||
eventTime,
|
eventTime,
|
||||||
location, False,
|
location, False,
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
conversationId,
|
conversationId,
|
||||||
self.server.low_bandwidth,
|
self.server.low_bandwidth,
|
||||||
self.server.content_license_url)
|
self.server.content_license_url)
|
||||||
if message_json:
|
if message_json:
|
||||||
# name field contains the answer
|
# name field contains the answer
|
||||||
message_json['object']['name'] = answer
|
message_json['object']['name'] = answer
|
||||||
|
@ -1481,7 +1481,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
print('Queue: Inbox queue is full')
|
print('Queue: Inbox queue is full')
|
||||||
self._503()
|
self._503()
|
||||||
clearQueueItems(self.server.base_dir, self.server.inbox_queue)
|
clear_queue_items(self.server.base_dir, self.server.inbox_queue)
|
||||||
if not self.server.restartInboxQueueInProgress:
|
if not self.server.restartInboxQueueInProgress:
|
||||||
self.server.restartInboxQueue = True
|
self.server.restartInboxQueue = True
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
|
@ -1510,12 +1510,12 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
originalMessageJson = message_json.copy()
|
originalMessageJson = message_json.copy()
|
||||||
|
|
||||||
# whether to add a 'to' field to the message
|
# whether to add a 'to' field to the message
|
||||||
addToFieldTypes = (
|
add_to_fieldTypes = (
|
||||||
'Follow', 'Like', 'EmojiReact', 'Add', 'Remove', 'Ignore'
|
'Follow', 'Like', 'EmojiReact', 'Add', 'Remove', 'Ignore'
|
||||||
)
|
)
|
||||||
for addToType in addToFieldTypes:
|
for addToType in add_to_fieldTypes:
|
||||||
message_json, toFieldExists = \
|
message_json, toFieldExists = \
|
||||||
addToField(addToType, message_json, self.server.debug)
|
add_to_field(addToType, message_json, self.server.debug)
|
||||||
|
|
||||||
beginSaveTime = time.time()
|
beginSaveTime = time.time()
|
||||||
# save the json for later queue processing
|
# save the json for later queue processing
|
||||||
|
@ -1841,7 +1841,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
usersPath = path.replace('/moderationaction', '')
|
usersPath = path.replace('/moderationaction', '')
|
||||||
nickname = usersPath.replace('/users/', '')
|
nickname = usersPath.replace('/users/', '')
|
||||||
actorStr = self._get_instance_url(calling_domain) + usersPath
|
actorStr = self._get_instance_url(calling_domain) + usersPath
|
||||||
if not isModerator(self.server.base_dir, nickname):
|
if not is_moderator(self.server.base_dir, nickname):
|
||||||
self._redirect_headers(actorStr + '/moderation',
|
self._redirect_headers(actorStr + '/moderation',
|
||||||
cookie, calling_domain)
|
cookie, calling_domain)
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
|
@ -2488,8 +2488,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
adminNickname = get_config_param(self.server.base_dir, 'admin')
|
adminNickname = get_config_param(self.server.base_dir, 'admin')
|
||||||
if (chooserNickname != optionsNickname and
|
if (chooserNickname != optionsNickname and
|
||||||
(chooserNickname == adminNickname or
|
(chooserNickname == adminNickname or
|
||||||
(isModerator(self.server.base_dir, chooserNickname) and
|
(is_moderator(self.server.base_dir, chooserNickname) and
|
||||||
not isModerator(self.server.base_dir, optionsNickname)))):
|
not is_moderator(self.server.base_dir, optionsNickname)))):
|
||||||
postsToNews = None
|
postsToNews = None
|
||||||
if 'postsToNews=' in optionsConfirmParams:
|
if 'postsToNews=' in optionsConfirmParams:
|
||||||
postsToNews = optionsConfirmParams.split('postsToNews=')[1]
|
postsToNews = optionsConfirmParams.split('postsToNews=')[1]
|
||||||
|
@ -2533,8 +2533,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
adminNickname = get_config_param(self.server.base_dir, 'admin')
|
adminNickname = get_config_param(self.server.base_dir, 'admin')
|
||||||
if (chooserNickname != optionsNickname and
|
if (chooserNickname != optionsNickname and
|
||||||
(chooserNickname == adminNickname or
|
(chooserNickname == adminNickname or
|
||||||
(isModerator(self.server.base_dir, chooserNickname) and
|
(is_moderator(self.server.base_dir, chooserNickname) and
|
||||||
not isModerator(self.server.base_dir, optionsNickname)))):
|
not is_moderator(self.server.base_dir, optionsNickname)))):
|
||||||
postsToFeatures = None
|
postsToFeatures = None
|
||||||
if 'postsToFeatures=' in optionsConfirmParams:
|
if 'postsToFeatures=' in optionsConfirmParams:
|
||||||
postsToFeatures = \
|
postsToFeatures = \
|
||||||
|
@ -2579,8 +2579,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
adminNickname = get_config_param(self.server.base_dir, 'admin')
|
adminNickname = get_config_param(self.server.base_dir, 'admin')
|
||||||
if (chooserNickname != optionsNickname and
|
if (chooserNickname != optionsNickname and
|
||||||
(chooserNickname == adminNickname or
|
(chooserNickname == adminNickname or
|
||||||
(isModerator(self.server.base_dir, chooserNickname) and
|
(is_moderator(self.server.base_dir, chooserNickname) and
|
||||||
not isModerator(self.server.base_dir, optionsNickname)))):
|
not is_moderator(self.server.base_dir, optionsNickname)))):
|
||||||
modPostsToNews = None
|
modPostsToNews = None
|
||||||
if 'modNewsPosts=' in optionsConfirmParams:
|
if 'modNewsPosts=' in optionsConfirmParams:
|
||||||
modPostsToNews = \
|
modPostsToNews = \
|
||||||
|
@ -2746,7 +2746,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# person options screen, Info button
|
# person options screen, Info button
|
||||||
# See htmlPersonOptions
|
# See htmlPersonOptions
|
||||||
if '&submitPersonInfo=' in optionsConfirmParams:
|
if '&submitPersonInfo=' in optionsConfirmParams:
|
||||||
if isModerator(self.server.base_dir, chooserNickname):
|
if is_moderator(self.server.base_dir, chooserNickname):
|
||||||
if debug:
|
if debug:
|
||||||
print('Showing info for ' + optionsActor)
|
print('Showing info for ' + optionsActor)
|
||||||
signing_priv_key_pem = self.server.signing_priv_key_pem
|
signing_priv_key_pem = self.server.signing_priv_key_pem
|
||||||
|
@ -3869,7 +3869,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actor = originPathStr
|
actor = originPathStr
|
||||||
actorNickname = get_nickname_from_actor(actor)
|
actorNickname = get_nickname_from_actor(actor)
|
||||||
if actor == shareActor or actor == adminActor or \
|
if actor == shareActor or actor == adminActor or \
|
||||||
isModerator(base_dir, actorNickname):
|
is_moderator(base_dir, actorNickname):
|
||||||
itemID = removeShareConfirmParams.split('itemID=')[1]
|
itemID = removeShareConfirmParams.split('itemID=')[1]
|
||||||
if '&' in itemID:
|
if '&' in itemID:
|
||||||
itemID = itemID.split('&')[0]
|
itemID = itemID.split('&')[0]
|
||||||
|
@ -3936,7 +3936,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actor = originPathStr
|
actor = originPathStr
|
||||||
actorNickname = get_nickname_from_actor(actor)
|
actorNickname = get_nickname_from_actor(actor)
|
||||||
if actor == shareActor or actor == adminActor or \
|
if actor == shareActor or actor == adminActor or \
|
||||||
isModerator(base_dir, actorNickname):
|
is_moderator(base_dir, actorNickname):
|
||||||
itemID = removeShareConfirmParams.split('itemID=')[1]
|
itemID = removeShareConfirmParams.split('itemID=')[1]
|
||||||
if '&' in itemID:
|
if '&' in itemID:
|
||||||
itemID = itemID.split('&')[0]
|
itemID = itemID.split('&')[0]
|
||||||
|
@ -4318,7 +4318,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname = get_nickname_from_actor(actorStr)
|
nickname = get_nickname_from_actor(actorStr)
|
||||||
moderator = None
|
moderator = None
|
||||||
if nickname:
|
if nickname:
|
||||||
moderator = isModerator(base_dir, nickname)
|
moderator = is_moderator(base_dir, nickname)
|
||||||
if not nickname or not moderator:
|
if not nickname or not moderator:
|
||||||
if not nickname:
|
if not nickname:
|
||||||
print('WARN: nickname not found in ' + actorStr)
|
print('WARN: nickname not found in ' + actorStr)
|
||||||
|
@ -6377,7 +6377,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'unable to delete ' +
|
'unable to delete ' +
|
||||||
allowedInstancesFilename)
|
allowedInstancesFilename)
|
||||||
|
|
||||||
if isModerator(self.server.base_dir, nickname):
|
if is_moderator(self.server.base_dir, nickname):
|
||||||
# set selected content warning lists
|
# set selected content warning lists
|
||||||
newListsEnabled = ''
|
newListsEnabled = ''
|
||||||
for name, item in self.server.cw_lists.items():
|
for name, item in self.server.cw_lists.items():
|
||||||
|
@ -7949,7 +7949,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname = nickname.split('/')[0]
|
nickname = nickname.split('/')[0]
|
||||||
print('Newswire item date: ' + dateStr)
|
print('Newswire item date: ' + dateStr)
|
||||||
if newswire.get(dateStr):
|
if newswire.get(dateStr):
|
||||||
if isModerator(base_dir, nickname):
|
if is_moderator(base_dir, nickname):
|
||||||
newswireItem = newswire[dateStr]
|
newswireItem = newswire[dateStr]
|
||||||
print('Voting on newswire item: ' + str(newswireItem))
|
print('Voting on newswire item: ' + str(newswireItem))
|
||||||
votesIndex = 2
|
votesIndex = 2
|
||||||
|
@ -8004,7 +8004,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '/' in nickname:
|
if '/' in nickname:
|
||||||
nickname = nickname.split('/')[0]
|
nickname = nickname.split('/')[0]
|
||||||
if newswire.get(dateStr):
|
if newswire.get(dateStr):
|
||||||
if isModerator(base_dir, nickname):
|
if is_moderator(base_dir, nickname):
|
||||||
votesIndex = 2
|
votesIndex = 2
|
||||||
filenameIndex = 3
|
filenameIndex = 3
|
||||||
newswireItem = newswire[dateStr]
|
newswireItem = newswire[dateStr]
|
||||||
|
@ -9568,9 +9568,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
}
|
}
|
||||||
|
|
||||||
# populate the items list with replies
|
# populate the items list with replies
|
||||||
populateRepliesJson(base_dir, nickname, domain,
|
populate_replies_json(base_dir, nickname, domain,
|
||||||
postRepliesFilename,
|
postRepliesFilename,
|
||||||
authorized, repliesJson)
|
authorized, repliesJson)
|
||||||
|
|
||||||
# send the replies json
|
# send the replies json
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
|
@ -9977,7 +9977,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._404()
|
self._404()
|
||||||
self.server.GETbusy = False
|
self.server.GETbusy = False
|
||||||
return True
|
return True
|
||||||
removePostInteractions(pjo, True)
|
remove_post_interactions(pjo, True)
|
||||||
if self._requestHTTP():
|
if self._requestHTTP():
|
||||||
msg = \
|
msg = \
|
||||||
htmlIndividualPost(self.server.css_cache,
|
htmlIndividualPost(self.server.css_cache,
|
||||||
|
@ -10950,7 +10950,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
currNickname = path.split('/users/')[1]
|
currNickname = path.split('/users/')[1]
|
||||||
if '/' in currNickname:
|
if '/' in currNickname:
|
||||||
currNickname = currNickname.split('/')[0]
|
currNickname = currNickname.split('/')[0]
|
||||||
moderator = isModerator(base_dir, currNickname)
|
moderator = is_moderator(base_dir, currNickname)
|
||||||
editor = is_editor(base_dir, currNickname)
|
editor = is_editor(base_dir, currNickname)
|
||||||
artist = is_artist(base_dir, currNickname)
|
artist = is_artist(base_dir, currNickname)
|
||||||
full_width_tl_button_header = \
|
full_width_tl_button_header = \
|
||||||
|
@ -12153,8 +12153,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actor/collections/featured
|
actor/collections/featured
|
||||||
"""
|
"""
|
||||||
featuredCollection = \
|
featuredCollection = \
|
||||||
jsonPinPost(base_dir, http_prefix,
|
json_pin_post(base_dir, http_prefix,
|
||||||
nickname, domain, domain_full, system_language)
|
nickname, domain, domain_full, system_language)
|
||||||
msg = json.dumps(featuredCollection,
|
msg = json.dumps(featuredCollection,
|
||||||
ensure_ascii=False).encode('utf-8')
|
ensure_ascii=False).encode('utf-8')
|
||||||
msglen = len(msg)
|
msglen = len(msg)
|
||||||
|
@ -13038,7 +13038,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname = get_nickname_from_actor(path)
|
nickname = get_nickname_from_actor(path)
|
||||||
if not nickname:
|
if not nickname:
|
||||||
return False
|
return False
|
||||||
if not isModerator(base_dir, nickname):
|
if not is_moderator(base_dir, nickname):
|
||||||
return False
|
return False
|
||||||
crawlersList = []
|
crawlersList = []
|
||||||
curr_time = int(time.time())
|
curr_time = int(time.time())
|
||||||
|
@ -13963,20 +13963,20 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if '/' in nickname:
|
if '/' in nickname:
|
||||||
nickname = nickname.split('/')[0]
|
nickname = nickname.split('/')[0]
|
||||||
pinnedPostJson = \
|
pinnedPostJson = \
|
||||||
getPinnedPostAsJson(self.server.base_dir,
|
get_pinned_post_as_json(self.server.base_dir,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
nickname, self.server.domain,
|
nickname, self.server.domain,
|
||||||
self.server.domain_full,
|
self.server.domain_full,
|
||||||
self.server.system_language)
|
self.server.system_language)
|
||||||
message_json = {}
|
message_json = {}
|
||||||
if pinnedPostJson:
|
if pinnedPostJson:
|
||||||
post_id = remove_id_ending(pinnedPostJson['id'])
|
post_id = remove_id_ending(pinnedPostJson['id'])
|
||||||
message_json = \
|
message_json = \
|
||||||
outboxMessageCreateWrap(self.server.http_prefix,
|
outbox_message_create_wrap(self.server.http_prefix,
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain,
|
self.server.domain,
|
||||||
self.server.port,
|
self.server.port,
|
||||||
pinnedPostJson)
|
pinnedPostJson)
|
||||||
message_json['id'] = post_id + '/activity'
|
message_json['id'] = post_id + '/activity'
|
||||||
message_json['object']['id'] = post_id
|
message_json['object']['id'] = post_id
|
||||||
message_json['object']['url'] = replace_users_with_at(post_id)
|
message_json['object']['url'] = replace_users_with_at(post_id)
|
||||||
|
@ -16108,7 +16108,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname = self.path.split('/users/')[1]
|
nickname = self.path.split('/users/')[1]
|
||||||
if '/' in nickname:
|
if '/' in nickname:
|
||||||
nickname = nickname.split('/')[0]
|
nickname = nickname.split('/')[0]
|
||||||
if not isModerator(self.server.base_dir, nickname):
|
if not is_moderator(self.server.base_dir, nickname):
|
||||||
self._400()
|
self._400()
|
||||||
self.server.GETbusy = False
|
self.server.GETbusy = False
|
||||||
return
|
return
|
||||||
|
@ -16147,7 +16147,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname = self.path.split('/users/')[1]
|
nickname = self.path.split('/users/')[1]
|
||||||
if '/' in nickname:
|
if '/' in nickname:
|
||||||
nickname = nickname.split('/')[0]
|
nickname = nickname.split('/')[0]
|
||||||
if not isModerator(self.server.base_dir, nickname):
|
if not is_moderator(self.server.base_dir, nickname):
|
||||||
self._400()
|
self._400()
|
||||||
self.server.GETbusy = False
|
self.server.GETbusy = False
|
||||||
return
|
return
|
||||||
|
@ -16615,8 +16615,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# is the post message empty?
|
# is the post message empty?
|
||||||
if not fields['message']:
|
if not fields['message']:
|
||||||
# remove the pinned content from profile screen
|
# remove the pinned content from profile screen
|
||||||
undoPinnedPost(self.server.base_dir,
|
undo_pinned_post(self.server.base_dir,
|
||||||
nickname, self.server.domain)
|
nickname, self.server.domain)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
city = getSpoofedCity(self.server.city,
|
city = getSpoofedCity(self.server.city,
|
||||||
|
@ -16626,24 +16626,26 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields.get('conversationId'):
|
if fields.get('conversationId'):
|
||||||
conversationId = fields['conversationId']
|
conversationId = fields['conversationId']
|
||||||
message_json = \
|
message_json = \
|
||||||
createPublicPost(self.server.base_dir,
|
create_public_post(self.server.base_dir,
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain,
|
self.server.domain,
|
||||||
self.server.port,
|
self.server.port,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
mentionsStr + fields['message'],
|
mentionsStr + fields['message'],
|
||||||
False, False, False, commentsEnabled,
|
False, False, False, commentsEnabled,
|
||||||
filename, attachmentMediaType,
|
filename, attachmentMediaType,
|
||||||
fields['imageDescription'],
|
fields['imageDescription'],
|
||||||
city,
|
city,
|
||||||
fields['replyTo'], fields['replyTo'],
|
fields['replyTo'], fields['replyTo'],
|
||||||
fields['subject'], fields['schedulePost'],
|
fields['subject'],
|
||||||
fields['eventDate'], fields['eventTime'],
|
fields['schedulePost'],
|
||||||
fields['location'], False,
|
fields['eventDate'],
|
||||||
self.server.system_language,
|
fields['eventTime'],
|
||||||
conversationId,
|
fields['location'], False,
|
||||||
self.server.low_bandwidth,
|
self.server.system_language,
|
||||||
self.server.content_license_url)
|
conversationId,
|
||||||
|
self.server.low_bandwidth,
|
||||||
|
self.server.content_license_url)
|
||||||
if message_json:
|
if message_json:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -16653,9 +16655,9 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
get_base_content_from_post(message_json,
|
get_base_content_from_post(message_json,
|
||||||
sys_language)
|
sys_language)
|
||||||
followersOnly = False
|
followersOnly = False
|
||||||
pinPost(self.server.base_dir,
|
pin_post(self.server.base_dir,
|
||||||
nickname, self.server.domain, contentStr,
|
nickname, self.server.domain, contentStr,
|
||||||
followersOnly)
|
followersOnly)
|
||||||
return 1
|
return 1
|
||||||
if self._postToOutbox(message_json,
|
if self._postToOutbox(message_json,
|
||||||
self.server.project_version,
|
self.server.project_version,
|
||||||
|
@ -16711,25 +16713,25 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
if fields.get('conversationId'):
|
if fields.get('conversationId'):
|
||||||
conversationId = fields['conversationId']
|
conversationId = fields['conversationId']
|
||||||
message_json = \
|
message_json = \
|
||||||
createBlogPost(self.server.base_dir, nickname,
|
create_blog_post(self.server.base_dir, nickname,
|
||||||
self.server.domain, self.server.port,
|
self.server.domain, self.server.port,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
fields['message'],
|
fields['message'],
|
||||||
followersOnly, saveToFile,
|
followersOnly, saveToFile,
|
||||||
client_to_server, commentsEnabled,
|
client_to_server, commentsEnabled,
|
||||||
filename, attachmentMediaType,
|
filename, attachmentMediaType,
|
||||||
fields['imageDescription'],
|
fields['imageDescription'],
|
||||||
city,
|
city,
|
||||||
fields['replyTo'], fields['replyTo'],
|
fields['replyTo'], fields['replyTo'],
|
||||||
fields['subject'],
|
fields['subject'],
|
||||||
fields['schedulePost'],
|
fields['schedulePost'],
|
||||||
fields['eventDate'],
|
fields['eventDate'],
|
||||||
fields['eventTime'],
|
fields['eventTime'],
|
||||||
fields['location'],
|
fields['location'],
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
conversationId,
|
conversationId,
|
||||||
self.server.low_bandwidth,
|
self.server.low_bandwidth,
|
||||||
self.server.content_license_url)
|
self.server.content_license_url)
|
||||||
if message_json:
|
if message_json:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -16862,27 +16864,27 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
conversationId = fields['conversationId']
|
conversationId = fields['conversationId']
|
||||||
|
|
||||||
message_json = \
|
message_json = \
|
||||||
createUnlistedPost(self.server.base_dir,
|
create_unlisted_post(self.server.base_dir,
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain, self.server.port,
|
self.server.domain, self.server.port,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
mentionsStr + fields['message'],
|
mentionsStr + fields['message'],
|
||||||
followersOnly, saveToFile,
|
followersOnly, saveToFile,
|
||||||
client_to_server, commentsEnabled,
|
client_to_server, commentsEnabled,
|
||||||
filename, attachmentMediaType,
|
filename, attachmentMediaType,
|
||||||
fields['imageDescription'],
|
fields['imageDescription'],
|
||||||
city,
|
city,
|
||||||
fields['replyTo'],
|
fields['replyTo'],
|
||||||
fields['replyTo'],
|
fields['replyTo'],
|
||||||
fields['subject'],
|
fields['subject'],
|
||||||
fields['schedulePost'],
|
fields['schedulePost'],
|
||||||
fields['eventDate'],
|
fields['eventDate'],
|
||||||
fields['eventTime'],
|
fields['eventTime'],
|
||||||
fields['location'],
|
fields['location'],
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
conversationId,
|
conversationId,
|
||||||
self.server.low_bandwidth,
|
self.server.low_bandwidth,
|
||||||
self.server.content_license_url)
|
self.server.content_license_url)
|
||||||
if message_json:
|
if message_json:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -16912,29 +16914,29 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
conversationId = fields['conversationId']
|
conversationId = fields['conversationId']
|
||||||
|
|
||||||
message_json = \
|
message_json = \
|
||||||
createFollowersOnlyPost(self.server.base_dir,
|
create_followers_only_post(self.server.base_dir,
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain,
|
self.server.domain,
|
||||||
self.server.port,
|
self.server.port,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
mentionsStr + fields['message'],
|
mentionsStr + fields['message'],
|
||||||
followersOnly, saveToFile,
|
followersOnly, saveToFile,
|
||||||
client_to_server,
|
client_to_server,
|
||||||
commentsEnabled,
|
commentsEnabled,
|
||||||
filename, attachmentMediaType,
|
filename, attachmentMediaType,
|
||||||
fields['imageDescription'],
|
fields['imageDescription'],
|
||||||
city,
|
city,
|
||||||
fields['replyTo'],
|
fields['replyTo'],
|
||||||
fields['replyTo'],
|
fields['replyTo'],
|
||||||
fields['subject'],
|
fields['subject'],
|
||||||
fields['schedulePost'],
|
fields['schedulePost'],
|
||||||
fields['eventDate'],
|
fields['eventDate'],
|
||||||
fields['eventTime'],
|
fields['eventTime'],
|
||||||
fields['location'],
|
fields['location'],
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
conversationId,
|
conversationId,
|
||||||
self.server.low_bandwidth,
|
self.server.low_bandwidth,
|
||||||
self.server.content_license_url)
|
self.server.content_license_url)
|
||||||
if message_json:
|
if message_json:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -16968,30 +16970,32 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
content_license_url = self.server.content_license_url
|
content_license_url = self.server.content_license_url
|
||||||
|
|
||||||
message_json = \
|
message_json = \
|
||||||
createDirectMessagePost(self.server.base_dir,
|
create_direct_message_post(self.server.base_dir,
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain,
|
self.server.domain,
|
||||||
self.server.port,
|
self.server.port,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
mentionsStr +
|
mentionsStr +
|
||||||
fields['message'],
|
fields['message'],
|
||||||
followersOnly, saveToFile,
|
followersOnly, saveToFile,
|
||||||
client_to_server,
|
client_to_server,
|
||||||
commentsEnabled,
|
commentsEnabled,
|
||||||
filename, attachmentMediaType,
|
filename,
|
||||||
fields['imageDescription'],
|
attachmentMediaType,
|
||||||
city,
|
fields['imageDescription'],
|
||||||
fields['replyTo'],
|
city,
|
||||||
fields['replyTo'],
|
fields['replyTo'],
|
||||||
fields['subject'],
|
fields['replyTo'],
|
||||||
True, fields['schedulePost'],
|
fields['subject'],
|
||||||
fields['eventDate'],
|
True,
|
||||||
fields['eventTime'],
|
fields['schedulePost'],
|
||||||
fields['location'],
|
fields['eventDate'],
|
||||||
self.server.system_language,
|
fields['eventTime'],
|
||||||
conversationId,
|
fields['location'],
|
||||||
self.server.low_bandwidth,
|
self.server.system_language,
|
||||||
content_license_url)
|
conversationId,
|
||||||
|
self.server.low_bandwidth,
|
||||||
|
content_license_url)
|
||||||
if message_json:
|
if message_json:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -17025,27 +17029,28 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
commentsEnabled = False
|
commentsEnabled = False
|
||||||
conversationId = None
|
conversationId = None
|
||||||
message_json = \
|
message_json = \
|
||||||
createDirectMessagePost(self.server.base_dir,
|
create_direct_message_post(self.server.base_dir,
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain,
|
self.server.domain,
|
||||||
self.server.port,
|
self.server.port,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
mentionsStr + fields['message'],
|
mentionsStr + fields['message'],
|
||||||
followersOnly, saveToFile,
|
followersOnly, saveToFile,
|
||||||
client_to_server, commentsEnabled,
|
client_to_server,
|
||||||
filename, attachmentMediaType,
|
commentsEnabled,
|
||||||
fields['imageDescription'],
|
filename, attachmentMediaType,
|
||||||
city,
|
fields['imageDescription'],
|
||||||
None, None,
|
city,
|
||||||
fields['subject'],
|
None, None,
|
||||||
True, fields['schedulePost'],
|
fields['subject'],
|
||||||
fields['eventDate'],
|
True, fields['schedulePost'],
|
||||||
fields['eventTime'],
|
fields['eventDate'],
|
||||||
fields['location'],
|
fields['eventTime'],
|
||||||
self.server.system_language,
|
fields['location'],
|
||||||
conversationId,
|
self.server.system_language,
|
||||||
self.server.low_bandwidth,
|
conversationId,
|
||||||
self.server.content_license_url)
|
self.server.low_bandwidth,
|
||||||
|
self.server.content_license_url)
|
||||||
if message_json:
|
if message_json:
|
||||||
if fields['schedulePost']:
|
if fields['schedulePost']:
|
||||||
return 1
|
return 1
|
||||||
|
@ -17070,19 +17075,19 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain)
|
self.server.domain)
|
||||||
message_json = \
|
message_json = \
|
||||||
createReportPost(self.server.base_dir,
|
create_report_post(self.server.base_dir,
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain, self.server.port,
|
self.server.domain, self.server.port,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
mentionsStr + fields['message'],
|
mentionsStr + fields['message'],
|
||||||
True, False, False, True,
|
True, False, False, True,
|
||||||
filename, attachmentMediaType,
|
filename, attachmentMediaType,
|
||||||
fields['imageDescription'],
|
fields['imageDescription'],
|
||||||
city,
|
city,
|
||||||
self.server.debug, fields['subject'],
|
self.server.debug, fields['subject'],
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
self.server.low_bandwidth,
|
self.server.low_bandwidth,
|
||||||
self.server.content_license_url)
|
self.server.content_license_url)
|
||||||
if message_json:
|
if message_json:
|
||||||
if self._postToOutbox(message_json,
|
if self._postToOutbox(message_json,
|
||||||
self.server.project_version,
|
self.server.project_version,
|
||||||
|
@ -17109,22 +17114,22 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.domain)
|
self.server.domain)
|
||||||
intDuration = int(fields['duration'])
|
intDuration = int(fields['duration'])
|
||||||
message_json = \
|
message_json = \
|
||||||
createQuestionPost(self.server.base_dir,
|
create_question_post(self.server.base_dir,
|
||||||
nickname,
|
nickname,
|
||||||
self.server.domain,
|
self.server.domain,
|
||||||
self.server.port,
|
self.server.port,
|
||||||
self.server.http_prefix,
|
self.server.http_prefix,
|
||||||
fields['message'], qOptions,
|
fields['message'], qOptions,
|
||||||
False, False, False,
|
False, False, False,
|
||||||
commentsEnabled,
|
commentsEnabled,
|
||||||
filename, attachmentMediaType,
|
filename, attachmentMediaType,
|
||||||
fields['imageDescription'],
|
fields['imageDescription'],
|
||||||
city,
|
city,
|
||||||
fields['subject'],
|
fields['subject'],
|
||||||
intDuration,
|
intDuration,
|
||||||
self.server.system_language,
|
self.server.system_language,
|
||||||
self.server.low_bandwidth,
|
self.server.low_bandwidth,
|
||||||
self.server.content_license_url)
|
self.server.content_license_url)
|
||||||
if message_json:
|
if message_json:
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: new Question')
|
print('DEBUG: new Question')
|
||||||
|
@ -18876,7 +18881,7 @@ def runDaemon(content_license_url: str,
|
||||||
|
|
||||||
print('Creating cache expiry thread')
|
print('Creating cache expiry thread')
|
||||||
httpd.thrCache = \
|
httpd.thrCache = \
|
||||||
threadWithTrace(target=expireCache,
|
threadWithTrace(target=expire_cache,
|
||||||
args=(base_dir, httpd.person_cache,
|
args=(base_dir, httpd.person_cache,
|
||||||
httpd.http_prefix,
|
httpd.http_prefix,
|
||||||
archive_dir,
|
archive_dir,
|
||||||
|
|
212
epicyon.py
212
epicyon.py
|
@ -34,7 +34,7 @@ from posts import getPublicPostDomains
|
||||||
from posts import getPublicPostDomainsBlocked
|
from posts import getPublicPostDomainsBlocked
|
||||||
from posts import sendBlockViaServer
|
from posts import sendBlockViaServer
|
||||||
from posts import sendUndoBlockViaServer
|
from posts import sendUndoBlockViaServer
|
||||||
from posts import createPublicPost
|
from posts import create_public_post
|
||||||
from posts import deleteAllPosts
|
from posts import deleteAllPosts
|
||||||
from posts import archivePosts
|
from posts import archivePosts
|
||||||
from posts import sendPostViaServer
|
from posts import sendPostViaServer
|
||||||
|
@ -2876,111 +2876,111 @@ if args.testdata:
|
||||||
conversationId = None
|
conversationId = None
|
||||||
low_bandwidth = False
|
low_bandwidth = False
|
||||||
|
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
"like this is totally just a #test man",
|
"like this is totally just a #test man",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
testC2S,
|
testC2S,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType, testImageDescription, testCity,
|
testMediaType, testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId,
|
testIsArticle, args.language, conversationId,
|
||||||
low_bandwidth, args.content_license_url)
|
low_bandwidth, args.content_license_url)
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
"Zoiks!!!",
|
"Zoiks!!!",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
testC2S,
|
testC2S,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType, testImageDescription, testCity,
|
testMediaType, testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId,
|
testIsArticle, args.language, conversationId,
|
||||||
low_bandwidth, args.content_license_url)
|
low_bandwidth, args.content_license_url)
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
"Hey scoob we need like a hundred more #milkshakes",
|
"Hey scoob we need like a hundred more #milkshakes",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
testC2S,
|
testC2S,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType, testImageDescription, testCity,
|
testMediaType, testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId,
|
testIsArticle, args.language, conversationId,
|
||||||
low_bandwidth, args.content_license_url)
|
low_bandwidth, args.content_license_url)
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
"Getting kinda spooky around here",
|
"Getting kinda spooky around here",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
testC2S,
|
testC2S,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType, testImageDescription, testCity,
|
testMediaType, testImageDescription, testCity,
|
||||||
'someone', testInReplyToAtomUri,
|
'someone', testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId,
|
testIsArticle, args.language, conversationId,
|
||||||
low_bandwidth, args.content_license_url)
|
low_bandwidth, args.content_license_url)
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
"And they would have gotten away with it too" +
|
"And they would have gotten away with it too" +
|
||||||
"if it wasn't for those pesky hackers",
|
"if it wasn't for those pesky hackers",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
testC2S,
|
testC2S,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
'img/logo.png', 'image/png',
|
'img/logo.png', 'image/png',
|
||||||
'Description of image', testCity,
|
'Description of image', testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId,
|
testIsArticle, args.language, conversationId,
|
||||||
low_bandwidth, args.content_license_url)
|
low_bandwidth, args.content_license_url)
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
"man these centralized sites are like the worst!",
|
"man these centralized sites are like the worst!",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
testC2S,
|
testC2S,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType, testImageDescription, testCity,
|
testMediaType, testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId,
|
testIsArticle, args.language, conversationId,
|
||||||
low_bandwidth, args.content_license_url)
|
low_bandwidth, args.content_license_url)
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
"another mystery solved #test",
|
"another mystery solved #test",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
testC2S,
|
testC2S,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType, testImageDescription, testCity,
|
testMediaType, testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId,
|
testIsArticle, args.language, conversationId,
|
||||||
low_bandwidth, args.content_license_url)
|
low_bandwidth, args.content_license_url)
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
"let's go bowling",
|
"let's go bowling",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
testC2S,
|
testC2S,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType, testImageDescription, testCity,
|
testMediaType, testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, args.language, conversationId,
|
testIsArticle, args.language, conversationId,
|
||||||
low_bandwidth, args.content_license_url)
|
low_bandwidth, args.content_license_url)
|
||||||
domain_full = domain + ':' + str(port)
|
domain_full = domain + ':' + str(port)
|
||||||
clearFollows(base_dir, nickname, domain)
|
clearFollows(base_dir, nickname, domain)
|
||||||
follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full,
|
follow_person(base_dir, nickname, domain, 'maxboardroom', domain_full,
|
||||||
|
|
30
inbox.py
30
inbox.py
|
@ -96,7 +96,7 @@ from httpsig import messageContentDigest
|
||||||
from posts import editedPostFilename
|
from posts import editedPostFilename
|
||||||
from posts import save_post_to_box
|
from posts import save_post_to_box
|
||||||
from posts import isCreateInsideAnnounce
|
from posts import isCreateInsideAnnounce
|
||||||
from posts import createDirectMessagePost
|
from posts import create_direct_message_post
|
||||||
from posts import validContentWarning
|
from posts import validContentWarning
|
||||||
from posts import downloadAnnounce
|
from posts import downloadAnnounce
|
||||||
from posts import isMuted
|
from posts import isMuted
|
||||||
|
@ -2860,17 +2860,18 @@ def _bounceDM(senderPostId: str, session, http_prefix: str,
|
||||||
conversationId = None
|
conversationId = None
|
||||||
low_bandwidth = False
|
low_bandwidth = False
|
||||||
post_json_object = \
|
post_json_object = \
|
||||||
createDirectMessagePost(base_dir, nickname, domain, port,
|
create_direct_message_post(base_dir, nickname, domain, port,
|
||||||
http_prefix, content, followersOnly,
|
http_prefix, content, followersOnly,
|
||||||
saveToFile, client_to_server,
|
saveToFile, client_to_server,
|
||||||
commentsEnabled,
|
commentsEnabled,
|
||||||
attachImageFilename, mediaType,
|
attachImageFilename, mediaType,
|
||||||
imageDescription, city,
|
imageDescription, city,
|
||||||
inReplyTo, inReplyToAtomUri,
|
inReplyTo, inReplyToAtomUri,
|
||||||
subject, debug, schedulePost,
|
subject, debug, schedulePost,
|
||||||
eventDate, eventTime, location,
|
eventDate, eventTime, location,
|
||||||
system_language, conversationId, low_bandwidth,
|
system_language, conversationId,
|
||||||
content_license_url)
|
low_bandwidth,
|
||||||
|
content_license_url)
|
||||||
if not post_json_object:
|
if not post_json_object:
|
||||||
print('WARN: unable to create bounce message to ' + sendingHandle)
|
print('WARN: unable to create bounce message to ' + sendingHandle)
|
||||||
return False
|
return False
|
||||||
|
@ -3637,7 +3638,7 @@ def _inboxAfterInitial(recent_posts_cache: {}, max_recent_posts: int,
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def clearQueueItems(base_dir: str, queue: []) -> None:
|
def clear_queue_items(base_dir: str, queue: []) -> None:
|
||||||
"""Clears the queue for each account
|
"""Clears the queue for each account
|
||||||
"""
|
"""
|
||||||
ctr = 0
|
ctr = 0
|
||||||
|
@ -3653,7 +3654,8 @@ def clearQueueItems(base_dir: str, queue: []) -> None:
|
||||||
os.remove(os.path.join(queueDir, qfile))
|
os.remove(os.path.join(queueDir, qfile))
|
||||||
ctr += 1
|
ctr += 1
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: clearQueueItems unable to delete ' + qfile)
|
print('EX: clear_queue_items unable to delete ' +
|
||||||
|
qfile)
|
||||||
break
|
break
|
||||||
break
|
break
|
||||||
if ctr > 0:
|
if ctr > 0:
|
||||||
|
|
10
outbox.py
10
outbox.py
|
@ -12,7 +12,7 @@ from shutil import copyfile
|
||||||
from session import create_session
|
from session import create_session
|
||||||
from auth import createPassword
|
from auth import createPassword
|
||||||
from posts import isImageMedia
|
from posts import isImageMedia
|
||||||
from posts import outboxMessageCreateWrap
|
from posts import outbox_message_create_wrap
|
||||||
from posts import save_post_to_box
|
from posts import save_post_to_box
|
||||||
from posts import sendToFollowersThread
|
from posts import sendToFollowersThread
|
||||||
from posts import sendToNamedAddressesThread
|
from posts import sendToNamedAddressesThread
|
||||||
|
@ -215,10 +215,10 @@ def postMessageToOutbox(session, translate: {},
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: POST to outbox - adding Create wrapper')
|
print('DEBUG: POST to outbox - adding Create wrapper')
|
||||||
message_json = \
|
message_json = \
|
||||||
outboxMessageCreateWrap(http_prefix,
|
outbox_message_create_wrap(http_prefix,
|
||||||
postToNickname,
|
postToNickname,
|
||||||
domain, port,
|
domain, port,
|
||||||
message_json)
|
message_json)
|
||||||
|
|
||||||
# check that the outgoing post doesn't contain any markup
|
# check that the outgoing post doesn't contain any markup
|
||||||
# which can be used to implement exploits
|
# which can be used to implement exploits
|
||||||
|
|
294
posts.py
294
posts.py
|
@ -90,7 +90,7 @@ from video import convertVideoToNote
|
||||||
from context import getIndividualPostContext
|
from context import getIndividualPostContext
|
||||||
|
|
||||||
|
|
||||||
def isModerator(base_dir: str, nickname: str) -> bool:
|
def is_moderator(base_dir: str, nickname: str) -> bool:
|
||||||
"""Returns true if the given nickname is a moderator
|
"""Returns true if the given nickname is a moderator
|
||||||
"""
|
"""
|
||||||
moderatorsFile = base_dir + '/accounts/moderators.txt'
|
moderatorsFile = base_dir + '/accounts/moderators.txt'
|
||||||
|
@ -1562,9 +1562,9 @@ def _createPostBase(base_dir: str,
|
||||||
return newPost
|
return newPost
|
||||||
|
|
||||||
|
|
||||||
def outboxMessageCreateWrap(http_prefix: str,
|
def outbox_message_create_wrap(http_prefix: str,
|
||||||
nickname: str, domain: str, port: int,
|
nickname: str, domain: str, port: int,
|
||||||
message_json: {}) -> {}:
|
message_json: {}) -> {}:
|
||||||
"""Wraps a received message in a Create
|
"""Wraps a received message in a Create
|
||||||
https://www.w3.org/TR/activitypub/#object-without-create
|
https://www.w3.org/TR/activitypub/#object-without-create
|
||||||
"""
|
"""
|
||||||
|
@ -1634,8 +1634,8 @@ def _postIsAddressedToFollowers(base_dir: str,
|
||||||
return addressedToFollowers
|
return addressedToFollowers
|
||||||
|
|
||||||
|
|
||||||
def pinPost(base_dir: str, nickname: str, domain: str,
|
def pin_post(base_dir: str, nickname: str, domain: str,
|
||||||
pinnedContent: str, followersOnly: bool) -> None:
|
pinnedContent: str, followersOnly: bool) -> None:
|
||||||
"""Pins the given post Id to the profile of then given account
|
"""Pins the given post Id to the profile of then given account
|
||||||
"""
|
"""
|
||||||
accountDir = acct_dir(base_dir, nickname, domain)
|
accountDir = acct_dir(base_dir, nickname, domain)
|
||||||
|
@ -1647,7 +1647,7 @@ def pinPost(base_dir: str, nickname: str, domain: str,
|
||||||
print('EX: unable to write ' + pinnedFilename)
|
print('EX: unable to write ' + pinnedFilename)
|
||||||
|
|
||||||
|
|
||||||
def undoPinnedPost(base_dir: str, nickname: str, domain: str) -> None:
|
def undo_pinned_post(base_dir: str, nickname: str, domain: str) -> None:
|
||||||
"""Removes pinned content for then given account
|
"""Removes pinned content for then given account
|
||||||
"""
|
"""
|
||||||
accountDir = acct_dir(base_dir, nickname, domain)
|
accountDir = acct_dir(base_dir, nickname, domain)
|
||||||
|
@ -1656,12 +1656,12 @@ def undoPinnedPost(base_dir: str, nickname: str, domain: str) -> None:
|
||||||
try:
|
try:
|
||||||
os.remove(pinnedFilename)
|
os.remove(pinnedFilename)
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: undoPinnedPost unable to delete ' + pinnedFilename)
|
print('EX: undo_pinned_post unable to delete ' + pinnedFilename)
|
||||||
|
|
||||||
|
|
||||||
def getPinnedPostAsJson(base_dir: str, http_prefix: str,
|
def get_pinned_post_as_json(base_dir: str, http_prefix: str,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str,
|
||||||
domain_full: str, system_language: str) -> {}:
|
domain_full: str, system_language: str) -> {}:
|
||||||
"""Returns the pinned profile post as json
|
"""Returns the pinned profile post as json
|
||||||
"""
|
"""
|
||||||
accountDir = acct_dir(base_dir, nickname, domain)
|
accountDir = acct_dir(base_dir, nickname, domain)
|
||||||
|
@ -1699,15 +1699,15 @@ def getPinnedPostAsJson(base_dir: str, http_prefix: str,
|
||||||
return pinnedPostJson
|
return pinnedPostJson
|
||||||
|
|
||||||
|
|
||||||
def jsonPinPost(base_dir: str, http_prefix: str,
|
def json_pin_post(base_dir: str, http_prefix: str,
|
||||||
nickname: str, domain: str,
|
nickname: str, domain: str,
|
||||||
domain_full: str, system_language: str) -> {}:
|
domain_full: str, system_language: str) -> {}:
|
||||||
"""Returns a pinned post as json
|
"""Returns a pinned post as json
|
||||||
"""
|
"""
|
||||||
pinnedPostJson = \
|
pinnedPostJson = \
|
||||||
getPinnedPostAsJson(base_dir, http_prefix,
|
get_pinned_post_as_json(base_dir, http_prefix,
|
||||||
nickname, domain,
|
nickname, domain,
|
||||||
domain_full, system_language)
|
domain_full, system_language)
|
||||||
itemsList = []
|
itemsList = []
|
||||||
if pinnedPostJson:
|
if pinnedPostJson:
|
||||||
itemsList = [pinnedPostJson]
|
itemsList = [pinnedPostJson]
|
||||||
|
@ -1754,21 +1754,21 @@ def regenerateIndexForBox(base_dir: str,
|
||||||
print('Index generated for ' + boxName + '\n' + result)
|
print('Index generated for ' + boxName + '\n' + result)
|
||||||
|
|
||||||
|
|
||||||
def createPublicPost(base_dir: str,
|
def create_public_post(base_dir: str,
|
||||||
nickname: str, domain: str, port: int, http_prefix: str,
|
nickname: str, domain: str, port: int, http_prefix: str,
|
||||||
content: str, followersOnly: bool, saveToFile: bool,
|
content: str, followersOnly: bool, saveToFile: bool,
|
||||||
client_to_server: bool, commentsEnabled: bool,
|
client_to_server: bool, commentsEnabled: bool,
|
||||||
attachImageFilename: str, mediaType: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
imageDescription: str, city: str,
|
imageDescription: str, city: str,
|
||||||
inReplyTo: str,
|
inReplyTo: str,
|
||||||
inReplyToAtomUri: str, subject: str,
|
inReplyToAtomUri: str, subject: str,
|
||||||
schedulePost: bool,
|
schedulePost: bool,
|
||||||
eventDate: str, eventTime: str,
|
eventDate: str, eventTime: str,
|
||||||
location: str,
|
location: str,
|
||||||
isArticle: bool,
|
isArticle: bool,
|
||||||
system_language: str,
|
system_language: str,
|
||||||
conversationId: str, low_bandwidth: bool,
|
conversationId: str, low_bandwidth: bool,
|
||||||
content_license_url: str) -> {}:
|
content_license_url: str) -> {}:
|
||||||
"""Public post
|
"""Public post
|
||||||
"""
|
"""
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
|
@ -1833,30 +1833,30 @@ def _appendCitationsToBlogPost(base_dir: str,
|
||||||
blogJson['object']['tag'].append(tagJson)
|
blogJson['object']['tag'].append(tagJson)
|
||||||
|
|
||||||
|
|
||||||
def createBlogPost(base_dir: str,
|
def create_blog_post(base_dir: str,
|
||||||
nickname: str, domain: str, port: int, http_prefix: str,
|
nickname: str, domain: str, port: int, http_prefix: str,
|
||||||
content: str, followersOnly: bool, saveToFile: bool,
|
content: str, followersOnly: bool, saveToFile: bool,
|
||||||
client_to_server: bool, commentsEnabled: bool,
|
client_to_server: bool, commentsEnabled: bool,
|
||||||
attachImageFilename: str, mediaType: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
imageDescription: str, city: str,
|
imageDescription: str, city: str,
|
||||||
inReplyTo: str, inReplyToAtomUri: str,
|
inReplyTo: str, inReplyToAtomUri: str,
|
||||||
subject: str, schedulePost: bool,
|
subject: str, schedulePost: bool,
|
||||||
eventDate: str, eventTime: str,
|
eventDate: str, eventTime: str,
|
||||||
location: str, system_language: str,
|
location: str, system_language: str,
|
||||||
conversationId: str, low_bandwidth: bool,
|
conversationId: str, low_bandwidth: bool,
|
||||||
content_license_url: str) -> {}:
|
content_license_url: str) -> {}:
|
||||||
blogJson = \
|
blogJson = \
|
||||||
createPublicPost(base_dir,
|
create_public_post(base_dir,
|
||||||
nickname, domain, port, http_prefix,
|
nickname, domain, port, http_prefix,
|
||||||
content, followersOnly, saveToFile,
|
content, followersOnly, saveToFile,
|
||||||
client_to_server, commentsEnabled,
|
client_to_server, commentsEnabled,
|
||||||
attachImageFilename, mediaType,
|
attachImageFilename, mediaType,
|
||||||
imageDescription, city,
|
imageDescription, city,
|
||||||
inReplyTo, inReplyToAtomUri, subject,
|
inReplyTo, inReplyToAtomUri, subject,
|
||||||
schedulePost,
|
schedulePost,
|
||||||
eventDate, eventTime, location,
|
eventDate, eventTime, location,
|
||||||
True, system_language, conversationId,
|
True, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
blogJson['object']['url'] = \
|
blogJson['object']['url'] = \
|
||||||
blogJson['object']['url'].replace('/@', '/users/')
|
blogJson['object']['url'].replace('/@', '/users/')
|
||||||
_appendCitationsToBlogPost(base_dir, nickname, domain, blogJson)
|
_appendCitationsToBlogPost(base_dir, nickname, domain, blogJson)
|
||||||
|
@ -1880,31 +1880,32 @@ def createNewsPost(base_dir: str,
|
||||||
eventTime = None
|
eventTime = None
|
||||||
location = None
|
location = None
|
||||||
blog = \
|
blog = \
|
||||||
createPublicPost(base_dir,
|
create_public_post(base_dir,
|
||||||
'news', domain, port, http_prefix,
|
'news', domain, port, http_prefix,
|
||||||
content, followersOnly, saveToFile,
|
content, followersOnly, saveToFile,
|
||||||
client_to_server, False,
|
client_to_server, False,
|
||||||
attachImageFilename, mediaType,
|
attachImageFilename, mediaType,
|
||||||
imageDescription, city,
|
imageDescription, city,
|
||||||
inReplyTo, inReplyToAtomUri, subject,
|
inReplyTo, inReplyToAtomUri, subject,
|
||||||
schedulePost,
|
schedulePost,
|
||||||
eventDate, eventTime, location,
|
eventDate, eventTime, location,
|
||||||
True, system_language, conversationId,
|
True, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
blog['object']['type'] = 'Article'
|
blog['object']['type'] = 'Article'
|
||||||
return blog
|
return blog
|
||||||
|
|
||||||
|
|
||||||
def createQuestionPost(base_dir: str,
|
def create_question_post(base_dir: str,
|
||||||
nickname: str, domain: str, port: int, http_prefix: str,
|
nickname: str, domain: str, port: int,
|
||||||
content: str, qOptions: [],
|
http_prefix: str,
|
||||||
followersOnly: bool, saveToFile: bool,
|
content: str, qOptions: [],
|
||||||
client_to_server: bool, commentsEnabled: bool,
|
followersOnly: bool, saveToFile: bool,
|
||||||
attachImageFilename: str, mediaType: str,
|
client_to_server: bool, commentsEnabled: bool,
|
||||||
imageDescription: str, city: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
subject: str, durationDays: int,
|
imageDescription: str, city: str,
|
||||||
system_language: str, low_bandwidth: bool,
|
subject: str, durationDays: int,
|
||||||
content_license_url: str) -> {}:
|
system_language: str, low_bandwidth: bool,
|
||||||
|
content_license_url: str) -> {}:
|
||||||
"""Question post with multiple choice options
|
"""Question post with multiple choice options
|
||||||
"""
|
"""
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
|
@ -1943,18 +1944,19 @@ def createQuestionPost(base_dir: str,
|
||||||
return message_json
|
return message_json
|
||||||
|
|
||||||
|
|
||||||
def createUnlistedPost(base_dir: str,
|
def create_unlisted_post(base_dir: str,
|
||||||
nickname: str, domain: str, port: int, http_prefix: str,
|
nickname: str, domain: str, port: int,
|
||||||
content: str, followersOnly: bool, saveToFile: bool,
|
http_prefix: str,
|
||||||
client_to_server: bool, commentsEnabled: bool,
|
content: str, followersOnly: bool, saveToFile: bool,
|
||||||
attachImageFilename: str, mediaType: str,
|
client_to_server: bool, commentsEnabled: bool,
|
||||||
imageDescription: str, city: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
inReplyTo: str, inReplyToAtomUri: str,
|
imageDescription: str, city: str,
|
||||||
subject: str, schedulePost: bool,
|
inReplyTo: str, inReplyToAtomUri: str,
|
||||||
eventDate: str, eventTime: str,
|
subject: str, schedulePost: bool,
|
||||||
location: str, system_language: str,
|
eventDate: str, eventTime: str,
|
||||||
conversationId: str, low_bandwidth: bool,
|
location: str, system_language: str,
|
||||||
content_license_url: str) -> {}:
|
conversationId: str, low_bandwidth: bool,
|
||||||
|
content_license_url: str) -> {}:
|
||||||
"""Unlisted post. This has the #Public and followers links inverted.
|
"""Unlisted post. This has the #Public and followers links inverted.
|
||||||
"""
|
"""
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
|
@ -1975,21 +1977,21 @@ def createUnlistedPost(base_dir: str,
|
||||||
content_license_url)
|
content_license_url)
|
||||||
|
|
||||||
|
|
||||||
def createFollowersOnlyPost(base_dir: str,
|
def create_followers_only_post(base_dir: str,
|
||||||
nickname: str, domain: str, port: int,
|
nickname: str, domain: str, port: int,
|
||||||
http_prefix: str,
|
http_prefix: str,
|
||||||
content: str, followersOnly: bool,
|
content: str, followersOnly: bool,
|
||||||
saveToFile: bool,
|
saveToFile: bool,
|
||||||
client_to_server: bool, commentsEnabled: bool,
|
client_to_server: bool, commentsEnabled: bool,
|
||||||
attachImageFilename: str, mediaType: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
imageDescription: str, city: str,
|
imageDescription: str, city: str,
|
||||||
inReplyTo: str,
|
inReplyTo: str,
|
||||||
inReplyToAtomUri: str,
|
inReplyToAtomUri: str,
|
||||||
subject: str, schedulePost: bool,
|
subject: str, schedulePost: bool,
|
||||||
eventDate: str, eventTime: str,
|
eventDate: str, eventTime: str,
|
||||||
location: str, system_language: str,
|
location: str, system_language: str,
|
||||||
conversationId: str, low_bandwidth: bool,
|
conversationId: str, low_bandwidth: bool,
|
||||||
content_license_url: str) -> {}:
|
content_license_url: str) -> {}:
|
||||||
"""Followers only post
|
"""Followers only post
|
||||||
"""
|
"""
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
|
@ -2046,22 +2048,22 @@ def getMentionedPeople(base_dir: str, http_prefix: str,
|
||||||
return mentions
|
return mentions
|
||||||
|
|
||||||
|
|
||||||
def createDirectMessagePost(base_dir: str,
|
def create_direct_message_post(base_dir: str,
|
||||||
nickname: str, domain: str, port: int,
|
nickname: str, domain: str, port: int,
|
||||||
http_prefix: str,
|
http_prefix: str,
|
||||||
content: str, followersOnly: bool,
|
content: str, followersOnly: bool,
|
||||||
saveToFile: bool, client_to_server: bool,
|
saveToFile: bool, client_to_server: bool,
|
||||||
commentsEnabled: bool,
|
commentsEnabled: bool,
|
||||||
attachImageFilename: str, mediaType: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
imageDescription: str, city: str,
|
imageDescription: str, city: str,
|
||||||
inReplyTo: str,
|
inReplyTo: str,
|
||||||
inReplyToAtomUri: str,
|
inReplyToAtomUri: str,
|
||||||
subject: str, debug: bool,
|
subject: str, debug: bool,
|
||||||
schedulePost: bool,
|
schedulePost: bool,
|
||||||
eventDate: str, eventTime: str,
|
eventDate: str, eventTime: str,
|
||||||
location: str, system_language: str,
|
location: str, system_language: str,
|
||||||
conversationId: str, low_bandwidth: bool,
|
conversationId: str, low_bandwidth: bool,
|
||||||
content_license_url: str) -> {}:
|
content_license_url: str) -> {}:
|
||||||
"""Direct Message post
|
"""Direct Message post
|
||||||
"""
|
"""
|
||||||
content = resolvePetnames(base_dir, nickname, domain, content)
|
content = resolvePetnames(base_dir, nickname, domain, content)
|
||||||
|
@ -2099,15 +2101,15 @@ def createDirectMessagePost(base_dir: str,
|
||||||
return message_json
|
return message_json
|
||||||
|
|
||||||
|
|
||||||
def createReportPost(base_dir: str,
|
def create_report_post(base_dir: str,
|
||||||
nickname: str, domain: str, port: int, http_prefix: str,
|
nickname: str, domain: str, port: int, http_prefix: str,
|
||||||
content: str, followersOnly: bool, saveToFile: bool,
|
content: str, followersOnly: bool, saveToFile: bool,
|
||||||
client_to_server: bool, commentsEnabled: bool,
|
client_to_server: bool, commentsEnabled: bool,
|
||||||
attachImageFilename: str, mediaType: str,
|
attachImageFilename: str, mediaType: str,
|
||||||
imageDescription: str, city: str,
|
imageDescription: str, city: str,
|
||||||
debug: bool, subject: str, system_language: str,
|
debug: bool, subject: str, system_language: str,
|
||||||
low_bandwidth: bool,
|
low_bandwidth: bool,
|
||||||
content_license_url: str) -> {}:
|
content_license_url: str) -> {}:
|
||||||
"""Send a report to moderators
|
"""Send a report to moderators
|
||||||
"""
|
"""
|
||||||
domain_full = get_full_domain(domain, port)
|
domain_full = get_full_domain(domain, port)
|
||||||
|
@ -2195,7 +2197,7 @@ def createReportPost(base_dir: str,
|
||||||
with open(newReportFile, 'w+') as fp:
|
with open(newReportFile, 'w+') as fp:
|
||||||
fp.write(toUrl + '/moderation')
|
fp.write(toUrl + '/moderation')
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: createReportPost unable to write ' + newReportFile)
|
print('EX: create_report_post unable to write ' + newReportFile)
|
||||||
|
|
||||||
return post_json_object
|
return post_json_object
|
||||||
|
|
||||||
|
@ -2781,8 +2783,8 @@ def sendSignedJson(post_json_object: {}, session, base_dir: str,
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def addToField(activityType: str, post_json_object: {},
|
def add_to_field(activityType: str, post_json_object: {},
|
||||||
debug: bool) -> ({}, bool):
|
debug: bool) -> ({}, bool):
|
||||||
"""The Follow/Add/Remove activity doesn't have a 'to' field and so one
|
"""The Follow/Add/Remove activity doesn't have a 'to' field and so one
|
||||||
needs to be added so that activity distribution happens in a consistent way
|
needs to be added so that activity distribution happens in a consistent way
|
||||||
Returns true if a 'to' field exists or was added
|
Returns true if a 'to' field exists or was added
|
||||||
|
@ -2905,11 +2907,11 @@ def _sendToNamedAddresses(session, base_dir: str,
|
||||||
recipientsObject = post_json_object['object']
|
recipientsObject = post_json_object['object']
|
||||||
else:
|
else:
|
||||||
post_json_object, fieldAdded = \
|
post_json_object, fieldAdded = \
|
||||||
addToField('Follow', post_json_object, debug)
|
add_to_field('Follow', post_json_object, debug)
|
||||||
if not fieldAdded:
|
if not fieldAdded:
|
||||||
return
|
return
|
||||||
post_json_object, fieldAdded = \
|
post_json_object, fieldAdded = \
|
||||||
addToField('Like', post_json_object, debug)
|
add_to_field('Like', post_json_object, debug)
|
||||||
if not fieldAdded:
|
if not fieldAdded:
|
||||||
return
|
return
|
||||||
recipientsObject = post_json_object
|
recipientsObject = post_json_object
|
||||||
|
@ -3421,7 +3423,7 @@ def createModeration(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
'type': 'OrderedCollectionPage'
|
'type': 'OrderedCollectionPage'
|
||||||
}
|
}
|
||||||
|
|
||||||
if isModerator(base_dir, nickname):
|
if is_moderator(base_dir, nickname):
|
||||||
moderationIndexFile = base_dir + '/accounts/moderation.txt'
|
moderationIndexFile = base_dir + '/accounts/moderation.txt'
|
||||||
if os.path.isfile(moderationIndexFile):
|
if os.path.isfile(moderationIndexFile):
|
||||||
with open(moderationIndexFile, 'r') as f:
|
with open(moderationIndexFile, 'r') as f:
|
||||||
|
@ -3566,7 +3568,7 @@ def _addPostToTimeline(filePath: str, boxname: str,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def removePostInteractions(post_json_object: {}, force: bool) -> bool:
|
def remove_post_interactions(post_json_object: {}, force: bool) -> bool:
|
||||||
""" Don't show likes, replies, bookmarks, DMs or shares (announces) to
|
""" Don't show likes, replies, bookmarks, DMs or shares (announces) to
|
||||||
unauthorized viewers. This makes the timeline less useful to
|
unauthorized viewers. This makes the timeline less useful to
|
||||||
marketers and other surveillance-oriented organizations.
|
marketers and other surveillance-oriented organizations.
|
||||||
|
@ -3870,7 +3872,7 @@ def _createBoxIndexed(recent_posts_cache: {},
|
||||||
p['hasReplies'] = hasReplies
|
p['hasReplies'] = hasReplies
|
||||||
|
|
||||||
if not authorized:
|
if not authorized:
|
||||||
if not removePostInteractions(p, False):
|
if not remove_post_interactions(p, False):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
boxItems['orderedItems'].append(p)
|
boxItems['orderedItems'].append(p)
|
||||||
|
@ -3878,10 +3880,10 @@ def _createBoxIndexed(recent_posts_cache: {},
|
||||||
return boxItems
|
return boxItems
|
||||||
|
|
||||||
|
|
||||||
def expireCache(base_dir: str, person_cache: {},
|
def expire_cache(base_dir: str, person_cache: {},
|
||||||
http_prefix: str, archive_dir: str,
|
http_prefix: str, archive_dir: str,
|
||||||
recent_posts_cache: {},
|
recent_posts_cache: {},
|
||||||
maxPostsInBox=32000):
|
maxPostsInBox=32000):
|
||||||
"""Thread used to expire actors from the cache and archive old posts
|
"""Thread used to expire actors from the cache and archive old posts
|
||||||
"""
|
"""
|
||||||
while True:
|
while True:
|
||||||
|
@ -4432,9 +4434,9 @@ def checkDomains(session, base_dir: str,
|
||||||
print(followerWarningStr)
|
print(followerWarningStr)
|
||||||
|
|
||||||
|
|
||||||
def populateRepliesJson(base_dir: str, nickname: str, domain: str,
|
def populate_replies_json(base_dir: str, nickname: str, domain: str,
|
||||||
postRepliesFilename: str, authorized: bool,
|
postRepliesFilename: str, authorized: bool,
|
||||||
repliesJson: {}) -> None:
|
repliesJson: {}) -> None:
|
||||||
pubStr = 'https://www.w3.org/ns/activitystreams#Public'
|
pubStr = 'https://www.w3.org/ns/activitystreams#Public'
|
||||||
# populate the items list with replies
|
# populate the items list with replies
|
||||||
repliesBoxes = ('outbox', 'inbox')
|
repliesBoxes = ('outbox', 'inbox')
|
||||||
|
@ -4708,9 +4710,9 @@ def downloadAnnounce(session, base_dir: str, http_prefix: str,
|
||||||
|
|
||||||
# wrap in create to be consistent with other posts
|
# wrap in create to be consistent with other posts
|
||||||
announcedJson = \
|
announcedJson = \
|
||||||
outboxMessageCreateWrap(http_prefix,
|
outbox_message_create_wrap(http_prefix,
|
||||||
actorNickname, actorDomain, actorPort,
|
actorNickname, actorDomain, actorPort,
|
||||||
announcedJson)
|
announcedJson)
|
||||||
if announcedJson['type'] != 'Create':
|
if announcedJson['type'] != 'Create':
|
||||||
# Create wrap failed
|
# Create wrap failed
|
||||||
_rejectAnnounce(announceFilename,
|
_rejectAnnounce(announceFilename,
|
||||||
|
|
282
tests.py
282
tests.py
|
@ -38,11 +38,11 @@ from session import create_session
|
||||||
from session import getJson
|
from session import getJson
|
||||||
from posts import getActorFromInReplyTo
|
from posts import getActorFromInReplyTo
|
||||||
from posts import regenerateIndexForBox
|
from posts import regenerateIndexForBox
|
||||||
from posts import removePostInteractions
|
from posts import remove_post_interactions
|
||||||
from posts import getMentionedPeople
|
from posts import getMentionedPeople
|
||||||
from posts import validContentWarning
|
from posts import validContentWarning
|
||||||
from posts import deleteAllPosts
|
from posts import deleteAllPosts
|
||||||
from posts import createPublicPost
|
from posts import create_public_post
|
||||||
from posts import sendPost
|
from posts import sendPost
|
||||||
from posts import noOfFollowersOnDomain
|
from posts import noOfFollowersOnDomain
|
||||||
from posts import groupFollowersByDomain
|
from posts import groupFollowersByDomain
|
||||||
|
@ -729,49 +729,49 @@ def createServerAlice(path: str, domain: str, port: int,
|
||||||
testIsArticle = False
|
testIsArticle = False
|
||||||
conversationId = None
|
conversationId = None
|
||||||
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
||||||
createPublicPost(path, nickname, domain, port, http_prefix,
|
create_public_post(path, nickname, domain, port, http_prefix,
|
||||||
"No wise fish would go anywhere without a porpoise",
|
"No wise fish would go anywhere without a porpoise",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
client_to_server,
|
client_to_server,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType,
|
testMediaType,
|
||||||
testImageDescription, testCity,
|
testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
createPublicPost(path, nickname, domain, port, http_prefix,
|
create_public_post(path, nickname, domain, port, http_prefix,
|
||||||
"Curiouser and curiouser!",
|
"Curiouser and curiouser!",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
client_to_server,
|
client_to_server,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType,
|
testMediaType,
|
||||||
testImageDescription, testCity,
|
testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
createPublicPost(path, nickname, domain, port, http_prefix,
|
create_public_post(path, nickname, domain, port, http_prefix,
|
||||||
"In the gardens of memory, in the palace " +
|
"In the gardens of memory, in the palace " +
|
||||||
"of dreams, that is where you and I shall meet",
|
"of dreams, that is where you and I shall meet",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
client_to_server,
|
client_to_server,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType,
|
testMediaType,
|
||||||
testImageDescription, testCity,
|
testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
regenerateIndexForBox(path, nickname, domain, 'outbox')
|
regenerateIndexForBox(path, nickname, domain, 'outbox')
|
||||||
global testServerAliceRunning
|
global testServerAliceRunning
|
||||||
testServerAliceRunning = True
|
testServerAliceRunning = True
|
||||||
|
@ -871,49 +871,49 @@ def createServerBob(path: str, domain: str, port: int,
|
||||||
testIsArticle = False
|
testIsArticle = False
|
||||||
conversationId = None
|
conversationId = None
|
||||||
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
||||||
createPublicPost(path, nickname, domain, port, http_prefix,
|
create_public_post(path, nickname, domain, port, http_prefix,
|
||||||
"It's your life, live it your way.",
|
"It's your life, live it your way.",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
client_to_server,
|
client_to_server,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType,
|
testMediaType,
|
||||||
testImageDescription, testCity,
|
testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
createPublicPost(path, nickname, domain, port, http_prefix,
|
create_public_post(path, nickname, domain, port, http_prefix,
|
||||||
"One of the things I've realised is that " +
|
"One of the things I've realised is that " +
|
||||||
"I am very simple",
|
"I am very simple",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
client_to_server,
|
client_to_server,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType,
|
testMediaType,
|
||||||
testImageDescription, testCity,
|
testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
createPublicPost(path, nickname, domain, port, http_prefix,
|
create_public_post(path, nickname, domain, port, http_prefix,
|
||||||
"Quantum physics is a bit of a passion of mine",
|
"Quantum physics is a bit of a passion of mine",
|
||||||
testFollowersOnly,
|
testFollowersOnly,
|
||||||
testSaveToFile,
|
testSaveToFile,
|
||||||
client_to_server,
|
client_to_server,
|
||||||
testCommentsEnabled,
|
testCommentsEnabled,
|
||||||
testAttachImageFilename,
|
testAttachImageFilename,
|
||||||
testMediaType,
|
testMediaType,
|
||||||
testImageDescription, testCity,
|
testImageDescription, testCity,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
regenerateIndexForBox(path, nickname, domain, 'outbox')
|
regenerateIndexForBox(path, nickname, domain, 'outbox')
|
||||||
global testServerBobRunning
|
global testServerBobRunning
|
||||||
testServerBobRunning = True
|
testServerBobRunning = True
|
||||||
|
@ -2710,15 +2710,15 @@ def _testCreatePerson(base_dir: str):
|
||||||
conversationId = None
|
conversationId = None
|
||||||
low_bandwidth = True
|
low_bandwidth = True
|
||||||
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
content, followersOnly, saveToFile, client_to_server,
|
content, followersOnly, saveToFile, client_to_server,
|
||||||
commentsEnabled, attachImageFilename, mediaType,
|
commentsEnabled, attachImageFilename, mediaType,
|
||||||
'Not suitable for Vogons', 'London, England',
|
'Not suitable for Vogons', 'London, England',
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
|
|
||||||
os.chdir(currDir)
|
os.chdir(currDir)
|
||||||
shutil.rmtree(base_dir, ignore_errors=False, onerror=None)
|
shutil.rmtree(base_dir, ignore_errors=False, onerror=None)
|
||||||
|
@ -4255,16 +4255,16 @@ def _testReplyToPublicPost(base_dir: str) -> None:
|
||||||
low_bandwidth = True
|
low_bandwidth = True
|
||||||
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
||||||
reply = \
|
reply = \
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
content, followersOnly, saveToFile,
|
content, followersOnly, saveToFile,
|
||||||
client_to_server, commentsEnabled,
|
client_to_server, commentsEnabled,
|
||||||
attachImageFilename, mediaType,
|
attachImageFilename, mediaType,
|
||||||
imageDescription, city, testInReplyTo,
|
imageDescription, city, testInReplyTo,
|
||||||
testInReplyToAtomUri,
|
testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
# print(str(reply))
|
# print(str(reply))
|
||||||
assert reply['object']['content'] == \
|
assert reply['object']['content'] == \
|
||||||
'<p><span class=\"h-card\">' + \
|
'<p><span class=\"h-card\">' + \
|
||||||
|
@ -4624,7 +4624,7 @@ def _testFunctions():
|
||||||
'fitnessThread',
|
'fitnessThread',
|
||||||
'threadSendPost',
|
'threadSendPost',
|
||||||
'sendToFollowers',
|
'sendToFollowers',
|
||||||
'expireCache',
|
'expire_cache',
|
||||||
'getMutualsOfPerson',
|
'getMutualsOfPerson',
|
||||||
'runPostsQueue',
|
'runPostsQueue',
|
||||||
'runSharesExpire',
|
'runSharesExpire',
|
||||||
|
@ -4801,16 +4801,16 @@ def _testLinksWithinPost(base_dir: str) -> None:
|
||||||
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
||||||
|
|
||||||
post_json_object = \
|
post_json_object = \
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
content, followersOnly, saveToFile,
|
content, followersOnly, saveToFile,
|
||||||
client_to_server, commentsEnabled,
|
client_to_server, commentsEnabled,
|
||||||
attachImageFilename, mediaType,
|
attachImageFilename, mediaType,
|
||||||
imageDescription, city,
|
imageDescription, city,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
|
|
||||||
assert post_json_object['object']['content'] == \
|
assert post_json_object['object']['content'] == \
|
||||||
'<p>This is a test post with links.<br><br>' + \
|
'<p>This is a test post with links.<br><br>' + \
|
||||||
|
@ -4837,17 +4837,17 @@ def _testLinksWithinPost(base_dir: str) -> None:
|
||||||
"taggedthing\" class=\"mention hashtag\" rel=\"tag\" " + \
|
"taggedthing\" class=\"mention hashtag\" rel=\"tag\" " + \
|
||||||
"target=\"_blank\">#<span>taggedthing</span></a></p>"
|
"target=\"_blank\">#<span>taggedthing</span></a></p>"
|
||||||
post_json_object = \
|
post_json_object = \
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
content,
|
content,
|
||||||
False, False,
|
False, False,
|
||||||
False, True,
|
False, True,
|
||||||
None, None,
|
None, None,
|
||||||
False, None,
|
False, None,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
assert post_json_object['object']['content'] == content
|
assert post_json_object['object']['content'] == content
|
||||||
assert post_json_object['object']['contentMap'][system_language] == content
|
assert post_json_object['object']['contentMap'][system_language] == content
|
||||||
|
|
||||||
|
@ -5201,14 +5201,14 @@ def _testRemovePostInteractions() -> None:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
removePostInteractions(post_json_object, True)
|
remove_post_interactions(post_json_object, True)
|
||||||
assert post_json_object['object']['likes']['items'] == []
|
assert post_json_object['object']['likes']['items'] == []
|
||||||
assert post_json_object['object']['replies'] == {}
|
assert post_json_object['object']['replies'] == {}
|
||||||
assert post_json_object['object']['shares'] == {}
|
assert post_json_object['object']['shares'] == {}
|
||||||
assert post_json_object['object']['bookmarks'] == {}
|
assert post_json_object['object']['bookmarks'] == {}
|
||||||
assert post_json_object['object']['ignores'] == {}
|
assert post_json_object['object']['ignores'] == {}
|
||||||
post_json_object['object']['to'] = ["some private address"]
|
post_json_object['object']['to'] = ["some private address"]
|
||||||
assert not removePostInteractions(post_json_object, False)
|
assert not remove_post_interactions(post_json_object, False)
|
||||||
|
|
||||||
|
|
||||||
def _testSpoofGeolocation() -> None:
|
def _testSpoofGeolocation() -> None:
|
||||||
|
@ -5788,16 +5788,16 @@ def _testCanReplyTo(base_dir: str) -> None:
|
||||||
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
content_license_url = 'https://creativecommons.org/licenses/by/4.0'
|
||||||
|
|
||||||
post_json_object = \
|
post_json_object = \
|
||||||
createPublicPost(base_dir, nickname, domain, port, http_prefix,
|
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||||
content, followersOnly, saveToFile,
|
content, followersOnly, saveToFile,
|
||||||
client_to_server, commentsEnabled,
|
client_to_server, commentsEnabled,
|
||||||
attachImageFilename, mediaType,
|
attachImageFilename, mediaType,
|
||||||
imageDescription, city,
|
imageDescription, city,
|
||||||
testInReplyTo, testInReplyToAtomUri,
|
testInReplyTo, testInReplyToAtomUri,
|
||||||
testSubject, testSchedulePost,
|
testSubject, testSchedulePost,
|
||||||
testEventDate, testEventTime, testLocation,
|
testEventDate, testEventTime, testLocation,
|
||||||
testIsArticle, system_language, conversationId,
|
testIsArticle, system_language, conversationId,
|
||||||
low_bandwidth, content_license_url)
|
low_bandwidth, content_license_url)
|
||||||
# set the date on the post
|
# set the date on the post
|
||||||
currDateStr = "2021-09-08T20:45:00Z"
|
currDateStr = "2021-09-08T20:45:00Z"
|
||||||
post_json_object['published'] = currDateStr
|
post_json_object['published'] = currDateStr
|
||||||
|
|
|
@ -22,7 +22,7 @@ from utils import is_editor
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import remove_domain_port
|
from utils import remove_domain_port
|
||||||
from utils import acct_dir
|
from utils import acct_dir
|
||||||
from posts import isModerator
|
from posts import is_moderator
|
||||||
from newswire import getNewswireFaviconUrl
|
from newswire import getNewswireFaviconUrl
|
||||||
from webapp_utils import getRightImageFile
|
from webapp_utils import getRightImageFile
|
||||||
from webapp_utils import htmlHeaderWithExternalStyle
|
from webapp_utils import htmlHeaderWithExternalStyle
|
||||||
|
@ -472,7 +472,7 @@ def htmlNewswireMobile(css_cache: {}, base_dir: str, nickname: str,
|
||||||
moderator = False
|
moderator = False
|
||||||
else:
|
else:
|
||||||
# is the user a moderator?
|
# is the user a moderator?
|
||||||
moderator = isModerator(base_dir, nickname)
|
moderator = is_moderator(base_dir, nickname)
|
||||||
|
|
||||||
# is the user a site editor?
|
# is the user a site editor?
|
||||||
editor = is_editor(base_dir, nickname)
|
editor = is_editor(base_dir, nickname)
|
||||||
|
@ -535,7 +535,7 @@ def htmlEditNewswire(css_cache: {}, translate: {}, base_dir: str, path: str,
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
# is the user a moderator?
|
# is the user a moderator?
|
||||||
if not isModerator(base_dir, nickname):
|
if not is_moderator(base_dir, nickname):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
cssFilename = base_dir + '/epicyon-links.css'
|
cssFilename = base_dir + '/epicyon-links.css'
|
||||||
|
|
|
@ -19,7 +19,7 @@ from utils import get_config_param
|
||||||
from utils import local_actor_url
|
from utils import local_actor_url
|
||||||
from posts import downloadFollowCollection
|
from posts import downloadFollowCollection
|
||||||
from posts import getPublicPostInfo
|
from posts import getPublicPostInfo
|
||||||
from posts import isModerator
|
from posts import is_moderator
|
||||||
from webapp_timeline import htmlTimeline
|
from webapp_timeline import htmlTimeline
|
||||||
# from webapp_utils import getPersonAvatarUrl
|
# from webapp_utils import getPersonAvatarUrl
|
||||||
from webapp_utils import getContentWarningButton
|
from webapp_utils import getContentWarningButton
|
||||||
|
@ -340,7 +340,7 @@ def htmlModerationInfo(css_cache: {}, translate: {},
|
||||||
infoForm += '<img loading="lazy" style="width:90%" '
|
infoForm += '<img loading="lazy" style="width:90%" '
|
||||||
infoForm += 'src="' + avatarUrl + '" />'
|
infoForm += 'src="' + avatarUrl + '" />'
|
||||||
infoForm += '<br><center>'
|
infoForm += '<br><center>'
|
||||||
if isModerator(base_dir, acctNickname):
|
if is_moderator(base_dir, acctNickname):
|
||||||
infoForm += '<b><u>' + acctNickname + '</u></b>'
|
infoForm += '<b><u>' + acctNickname + '</u></b>'
|
||||||
else:
|
else:
|
||||||
infoForm += acctNickname
|
infoForm += acctNickname
|
||||||
|
|
|
@ -11,7 +11,7 @@ import os
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from petnames import getPetName
|
from petnames import getPetName
|
||||||
from person import isPersonSnoozed
|
from person import isPersonSnoozed
|
||||||
from posts import isModerator
|
from posts import is_moderator
|
||||||
from utils import get_full_domain
|
from utils import get_full_domain
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
from utils import is_dormant
|
from utils import is_dormant
|
||||||
|
@ -291,8 +291,8 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
if optionsDomainFull == domain_full:
|
if optionsDomainFull == domain_full:
|
||||||
adminNickname = get_config_param(base_dir, 'admin')
|
adminNickname = get_config_param(base_dir, 'admin')
|
||||||
if (nickname == adminNickname or
|
if (nickname == adminNickname or
|
||||||
(isModerator(base_dir, nickname) and
|
(is_moderator(base_dir, nickname) and
|
||||||
not isModerator(base_dir, optionsNickname))):
|
not is_moderator(base_dir, optionsNickname))):
|
||||||
newswireBlockedFilename = \
|
newswireBlockedFilename = \
|
||||||
base_dir + '/accounts/' + \
|
base_dir + '/accounts/' + \
|
||||||
optionsNickname + '@' + optionsDomain + '/.nonewswire'
|
optionsNickname + '@' + optionsDomain + '/.nonewswire'
|
||||||
|
@ -332,8 +332,8 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
if news_instance and optionsDomainFull == domain_full:
|
if news_instance and optionsDomainFull == domain_full:
|
||||||
adminNickname = get_config_param(base_dir, 'admin')
|
adminNickname = get_config_param(base_dir, 'admin')
|
||||||
if (nickname == adminNickname or
|
if (nickname == adminNickname or
|
||||||
(isModerator(base_dir, nickname) and
|
(is_moderator(base_dir, nickname) and
|
||||||
not isModerator(base_dir, optionsNickname))):
|
not is_moderator(base_dir, optionsNickname))):
|
||||||
checkboxStr = \
|
checkboxStr = \
|
||||||
' <input type="checkbox" ' + \
|
' <input type="checkbox" ' + \
|
||||||
'class="profilecheckbox" ' + \
|
'class="profilecheckbox" ' + \
|
||||||
|
@ -396,7 +396,7 @@ def htmlPersonOptions(defaultTimeline: str,
|
||||||
accessKeys['reportButton'] + '">' + \
|
accessKeys['reportButton'] + '">' + \
|
||||||
translate['Report'] + '</button>\n'
|
translate['Report'] + '</button>\n'
|
||||||
|
|
||||||
if isModerator(base_dir, nickname):
|
if is_moderator(base_dir, nickname):
|
||||||
optionsStr += \
|
optionsStr += \
|
||||||
' <button type="submit" class="button" ' + \
|
' <button type="submit" class="button" ' + \
|
||||||
'name="submitPersonInfo" accesskey="' + \
|
'name="submitPersonInfo" accesskey="' + \
|
||||||
|
|
|
@ -22,7 +22,7 @@ from follow import isFollowingActor
|
||||||
from posts import postIsMuted
|
from posts import postIsMuted
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
from posts import downloadAnnounce
|
from posts import downloadAnnounce
|
||||||
from posts import populateRepliesJson
|
from posts import populate_replies_json
|
||||||
from utils import remove_hash_from_post_id
|
from utils import remove_hash_from_post_id
|
||||||
from utils import remove_html
|
from utils import remove_html
|
||||||
from utils import get_actor_languages_list
|
from utils import get_actor_languages_list
|
||||||
|
@ -2119,8 +2119,8 @@ def htmlIndividualPost(css_cache: {},
|
||||||
repliesJson = {
|
repliesJson = {
|
||||||
'orderedItems': []
|
'orderedItems': []
|
||||||
}
|
}
|
||||||
populateRepliesJson(base_dir, nickname, domain,
|
populate_replies_json(base_dir, nickname, domain,
|
||||||
repliesFilename, authorized, repliesJson)
|
repliesFilename, authorized, repliesJson)
|
||||||
# add items to the html output
|
# add items to the html output
|
||||||
for item in repliesJson['orderedItems']:
|
for item in repliesJson['orderedItems']:
|
||||||
postStr += \
|
postStr += \
|
||||||
|
|
|
@ -36,7 +36,7 @@ from person import person_box_json
|
||||||
from person import getActorJson
|
from person import getActorJson
|
||||||
from person import getPersonAvatarUrl
|
from person import getPersonAvatarUrl
|
||||||
from posts import getPersonBox
|
from posts import getPersonBox
|
||||||
from posts import isModerator
|
from posts import is_moderator
|
||||||
from posts import parseUserFeed
|
from posts import parseUserFeed
|
||||||
from posts import isCreateInsideAnnounce
|
from posts import isCreateInsideAnnounce
|
||||||
from donate import get_donation_url
|
from donate import get_donation_url
|
||||||
|
@ -1760,7 +1760,7 @@ def _htmlEditProfileFiltering(base_dir: str, nickname: str, domain: str,
|
||||||
'style="height:200px" spellcheck="false">' + \
|
'style="height:200px" spellcheck="false">' + \
|
||||||
allowedInstancesStr + '</textarea>\n'
|
allowedInstancesStr + '</textarea>\n'
|
||||||
|
|
||||||
if isModerator(base_dir, nickname):
|
if is_moderator(base_dir, nickname):
|
||||||
editProfileForm += \
|
editProfileForm += \
|
||||||
'<a href="/users/' + nickname + '/crawlers">' + \
|
'<a href="/users/' + nickname + '/crawlers">' + \
|
||||||
translate['Known Web Crawlers'] + '</a><br>\n'
|
translate['Known Web Crawlers'] + '</a><br>\n'
|
||||||
|
|
|
@ -35,7 +35,7 @@ from webapp_post import individualPostAsHtml
|
||||||
from webapp_column_left import getLeftColumnContent
|
from webapp_column_left import getLeftColumnContent
|
||||||
from webapp_column_right import getRightColumnContent
|
from webapp_column_right import getRightColumnContent
|
||||||
from webapp_headerbuttons import headerButtonsTimeline
|
from webapp_headerbuttons import headerButtonsTimeline
|
||||||
from posts import isModerator
|
from posts import is_moderator
|
||||||
from announce import isSelfAnnounce
|
from announce import isSelfAnnounce
|
||||||
|
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ def htmlTimeline(css_cache: {}, defaultTimeline: str,
|
||||||
|
|
||||||
# is the user a moderator?
|
# is the user a moderator?
|
||||||
if not moderator:
|
if not moderator:
|
||||||
moderator = isModerator(base_dir, nickname)
|
moderator = is_moderator(base_dir, nickname)
|
||||||
|
|
||||||
# is the user a site editor?
|
# is the user a site editor?
|
||||||
if not editor:
|
if not editor:
|
||||||
|
@ -1080,9 +1080,9 @@ def _htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int,
|
||||||
isAdminAccount = False
|
isAdminAccount = False
|
||||||
if adminActor and actor == adminActor:
|
if adminActor and actor == adminActor:
|
||||||
isAdminAccount = True
|
isAdminAccount = True
|
||||||
isModeratorAccount = False
|
is_moderatorAccount = False
|
||||||
if isModerator(base_dir, nickname):
|
if is_moderator(base_dir, nickname):
|
||||||
isModeratorAccount = True
|
is_moderatorAccount = True
|
||||||
|
|
||||||
for published, sharedItem in sharesJson.items():
|
for published, sharedItem in sharesJson.items():
|
||||||
showContactButton = False
|
showContactButton = False
|
||||||
|
@ -1091,7 +1091,7 @@ def _htmlSharesTimeline(translate: {}, pageNumber: int, itemsPerPage: int,
|
||||||
showRemoveButton = False
|
showRemoveButton = False
|
||||||
if '___' + domain in sharedItem['shareId']:
|
if '___' + domain in sharedItem['shareId']:
|
||||||
if sharedItem['actor'] == actor or \
|
if sharedItem['actor'] == actor or \
|
||||||
isAdminAccount or isModeratorAccount:
|
isAdminAccount or is_moderatorAccount:
|
||||||
showRemoveButton = True
|
showRemoveButton = True
|
||||||
timelineStr += \
|
timelineStr += \
|
||||||
htmlIndividualShare(domain, sharedItem['shareId'],
|
htmlIndividualShare(domain, sharedItem['shareId'],
|
||||||
|
|
|
@ -28,7 +28,7 @@ from cache import storePersonInCache
|
||||||
from content import addHtmlTags
|
from content import addHtmlTags
|
||||||
from content import replaceEmojiFromTags
|
from content import replaceEmojiFromTags
|
||||||
from person import getPersonAvatarUrl
|
from person import getPersonAvatarUrl
|
||||||
from posts import isModerator
|
from posts import is_moderator
|
||||||
from blocking import isBlocked
|
from blocking import isBlocked
|
||||||
|
|
||||||
|
|
||||||
|
@ -1469,7 +1469,7 @@ def htmlSearchResultShare(base_dir: str, sharedItem: {}, translate: {},
|
||||||
nickname = get_nickname_from_actor(actor)
|
nickname = get_nickname_from_actor(actor)
|
||||||
if actor.endswith('/users/' + contactNickname):
|
if actor.endswith('/users/' + contactNickname):
|
||||||
showRemoveButton = True
|
showRemoveButton = True
|
||||||
elif isModerator(base_dir, nickname):
|
elif is_moderator(base_dir, nickname):
|
||||||
showRemoveButton = True
|
showRemoveButton = True
|
||||||
else:
|
else:
|
||||||
adminNickname = get_config_param(base_dir, 'admin')
|
adminNickname = get_config_param(base_dir, 'admin')
|
||||||
|
|
Loading…
Reference in New Issue