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