mirror of https://gitlab.com/bashrc2/epicyon
merge-requests/30/head
commit
f25874cd8f
3
blog.py
3
blog.py
|
@ -280,7 +280,8 @@ def _html_blog_post_content(debug: bool, session, authorized: bool,
|
|||
like_str, bookmark_str,
|
||||
delete_str, mute_str,
|
||||
json_content,
|
||||
minimize_all_images)
|
||||
minimize_all_images,
|
||||
system_language)
|
||||
if attachment_str:
|
||||
blog_str += '<br><center>' + attachment_str + '</center>'
|
||||
if json_content:
|
||||
|
|
96
daemon.py
96
daemon.py
|
@ -705,6 +705,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
self.server.content_license_url, '',
|
||||
languages_understood, False,
|
||||
self.server.translate, buy_url)
|
||||
if message_json:
|
||||
|
@ -20795,6 +20796,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
|
||||
media_license_url = self.server.content_license_url
|
||||
if fields.get('mediaLicense'):
|
||||
media_license_url = fields['mediaLicense']
|
||||
if '://' not in media_license_url:
|
||||
media_license_url = \
|
||||
license_link_from_name(media_license_url)
|
||||
media_creator = ''
|
||||
if fields.get('mediaCreator'):
|
||||
media_creator = fields['mediaCreator']
|
||||
message_json = \
|
||||
create_public_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -20817,6 +20827,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood,
|
||||
self.server.translate, buy_url)
|
||||
if message_json:
|
||||
|
@ -20936,6 +20947,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
media_license_url = self.server.content_license_url
|
||||
if fields.get('mediaLicense'):
|
||||
media_license_url = fields['mediaLicense']
|
||||
if '://' not in media_license_url:
|
||||
media_license_url = \
|
||||
license_link_from_name(media_license_url)
|
||||
media_creator = ''
|
||||
if fields.get('mediaCreator'):
|
||||
media_creator = fields['mediaCreator']
|
||||
message_json = \
|
||||
create_blog_post(self.server.base_dir, nickname,
|
||||
self.server.domain, self.server.port,
|
||||
|
@ -20957,6 +20977,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood,
|
||||
self.server.translate, buy_url)
|
||||
if message_json:
|
||||
|
@ -21043,6 +21064,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.base_dir,
|
||||
nickname,
|
||||
self.server.domain)
|
||||
license_url = self.server.content_license_url
|
||||
if fields.get('mediaLicense'):
|
||||
license_url = fields['mediaLicense']
|
||||
if '://' not in license_url:
|
||||
license_url = \
|
||||
license_link_from_name(license_url)
|
||||
creator = ''
|
||||
if fields.get('mediaCreator'):
|
||||
creator = fields['mediaCreator']
|
||||
post_json_object['object'] = \
|
||||
attach_media(self.server.base_dir,
|
||||
self.server.http_prefix,
|
||||
|
@ -21055,7 +21085,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
img_description,
|
||||
city,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url)
|
||||
license_url, creator)
|
||||
|
||||
replace_you_tube(post_json_object,
|
||||
self.server.yt_replace_domain,
|
||||
|
@ -21098,7 +21128,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
|
||||
media_license_url = self.server.content_license_url
|
||||
if fields.get('mediaLicense'):
|
||||
media_license_url = fields['mediaLicense']
|
||||
if '://' not in media_license_url:
|
||||
media_license_url = \
|
||||
license_link_from_name(media_license_url)
|
||||
media_creator = ''
|
||||
if fields.get('mediaCreator'):
|
||||
media_creator = fields['mediaCreator']
|
||||
message_json = \
|
||||
create_unlisted_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -21122,6 +21160,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood,
|
||||
self.server.translate, buy_url)
|
||||
if message_json:
|
||||
|
@ -21208,6 +21247,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
media_license_url = self.server.content_license_url
|
||||
if fields.get('mediaLicense'):
|
||||
media_license_url = fields['mediaLicense']
|
||||
if '://' not in media_license_url:
|
||||
media_license_url = \
|
||||
license_link_from_name(media_license_url)
|
||||
media_creator = ''
|
||||
if fields.get('mediaCreator'):
|
||||
media_creator = fields['mediaCreator']
|
||||
message_json = \
|
||||
create_followers_only_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -21233,6 +21281,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
media_license_url,
|
||||
media_creator,
|
||||
languages_understood,
|
||||
self.server.translate,
|
||||
buy_url)
|
||||
|
@ -21328,6 +21378,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if fields.get('replychatmsg'):
|
||||
reply_is_chat = fields['replychatmsg']
|
||||
|
||||
media_license_url = content_license_url
|
||||
if fields.get('mediaLicense'):
|
||||
media_license_url = fields['mediaLicense']
|
||||
if '://' not in media_license_url:
|
||||
media_license_url = \
|
||||
license_link_from_name(media_license_url)
|
||||
media_creator = ''
|
||||
if fields.get('mediaCreator'):
|
||||
media_creator = fields['mediaCreator']
|
||||
message_json = \
|
||||
create_direct_message_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -21356,6 +21415,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
content_license_url,
|
||||
media_license_url,
|
||||
media_creator,
|
||||
languages_understood,
|
||||
reply_is_chat,
|
||||
self.server.translate,
|
||||
|
@ -21450,6 +21511,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
media_license_url = self.server.content_license_url
|
||||
if fields.get('mediaLicense'):
|
||||
media_license_url = fields['mediaLicense']
|
||||
if '://' not in media_license_url:
|
||||
media_license_url = \
|
||||
license_link_from_name(media_license_url)
|
||||
media_creator = ''
|
||||
if fields.get('mediaCreator'):
|
||||
media_creator = fields['mediaCreator']
|
||||
message_json = \
|
||||
create_direct_message_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -21474,6 +21544,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
conversation_id,
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
media_license_url,
|
||||
media_creator,
|
||||
languages_understood,
|
||||
False, self.server.translate,
|
||||
buy_url)
|
||||
|
@ -21556,6 +21628,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
media_license_url = self.server.content_license_url
|
||||
if fields.get('mediaLicense'):
|
||||
media_license_url = fields['mediaLicense']
|
||||
if '://' not in media_license_url:
|
||||
media_license_url = \
|
||||
license_link_from_name(media_license_url)
|
||||
media_creator = ''
|
||||
if fields.get('mediaCreator'):
|
||||
media_creator = fields['mediaCreator']
|
||||
message_json = \
|
||||
create_report_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -21570,6 +21651,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
fields['languagesDropdown'],
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood,
|
||||
self.server.translate)
|
||||
if message_json:
|
||||
|
@ -21606,6 +21688,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
nickname,
|
||||
self.server.domain_full,
|
||||
self.server.person_cache)
|
||||
media_license_url = self.server.content_license_url
|
||||
if fields.get('mediaLicense'):
|
||||
media_license_url = fields['mediaLicense']
|
||||
if '://' not in media_license_url:
|
||||
media_license_url = \
|
||||
license_link_from_name(media_license_url)
|
||||
media_creator = ''
|
||||
if fields.get('mediaCreator'):
|
||||
media_creator = fields['mediaCreator']
|
||||
message_json = \
|
||||
create_question_post(self.server.base_dir,
|
||||
nickname,
|
||||
|
@ -21623,6 +21714,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
fields['languagesDropdown'],
|
||||
self.server.low_bandwidth,
|
||||
self.server.content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood,
|
||||
self.server.translate)
|
||||
if message_json:
|
||||
|
|
|
@ -480,6 +480,7 @@ def _desktop_reply_to_post(session, post_id: str,
|
|||
espeak, conversation_id: str,
|
||||
low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
signing_priv_key_pem: str,
|
||||
translate: {}) -> None:
|
||||
"""Use the desktop client to send a reply to the most recent post
|
||||
|
@ -540,6 +541,7 @@ def _desktop_reply_to_post(session, post_id: str,
|
|||
cached_webfingers, person_cache, is_article,
|
||||
system_language, languages_understood,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
event_date, event_time, event_end_time, location,
|
||||
translate, buy_url, debug, post_id, post_id,
|
||||
conversation_id, subject) == 0:
|
||||
|
@ -558,6 +560,7 @@ def _desktop_new_post(session,
|
|||
languages_understood: [],
|
||||
espeak, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
signing_priv_key_pem: str,
|
||||
translate: {}) -> None:
|
||||
"""Use the desktop client to create a new post
|
||||
|
@ -615,6 +618,7 @@ def _desktop_new_post(session,
|
|||
cached_webfingers, person_cache, is_article,
|
||||
system_language, languages_understood,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
event_date, event_time, event_end_time, location,
|
||||
translate, buy_url, debug, None, None,
|
||||
conversation_id, subject) == 0:
|
||||
|
@ -1224,6 +1228,7 @@ def _desktop_new_dm(session, to_handle: str,
|
|||
languages_understood: [],
|
||||
espeak, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
signing_priv_key_pem: str,
|
||||
translate: {}) -> None:
|
||||
"""Use the desktop client to create a new direct message
|
||||
|
@ -1249,6 +1254,7 @@ def _desktop_new_dm(session, to_handle: str,
|
|||
languages_understood,
|
||||
espeak, low_bandwidth,
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
signing_priv_key_pem, translate)
|
||||
|
||||
|
||||
|
@ -1261,6 +1267,7 @@ def _desktop_new_dm_base(session, to_handle: str,
|
|||
languages_understood: [],
|
||||
espeak, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
signing_priv_key_pem: str,
|
||||
translate: {}) -> None:
|
||||
"""Use the desktop client to create a new direct message
|
||||
|
@ -1361,6 +1368,7 @@ def _desktop_new_dm_base(session, to_handle: str,
|
|||
cached_webfingers, person_cache, is_article,
|
||||
system_language, languages_understood,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
event_date, event_time, event_end_time, location,
|
||||
translate, buy_url, debug, None, None,
|
||||
conversation_id, subject) == 0:
|
||||
|
@ -1447,6 +1455,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
signing_priv_key_pem = None
|
||||
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = ''
|
||||
|
||||
blocked_cache = {}
|
||||
languages_understood = []
|
||||
|
@ -1853,6 +1863,8 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
espeak, conversation_id,
|
||||
low_bandwidth,
|
||||
content_license_url,
|
||||
media_license_url,
|
||||
media_creator,
|
||||
signing_priv_key_pem,
|
||||
translate)
|
||||
refresh_timeline = True
|
||||
|
@ -1891,6 +1903,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
languages_understood,
|
||||
espeak, low_bandwidth,
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
signing_priv_key_pem, translate)
|
||||
refresh_timeline = True
|
||||
else:
|
||||
|
@ -1904,6 +1917,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
|
|||
languages_understood,
|
||||
espeak, low_bandwidth,
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
signing_priv_key_pem, translate)
|
||||
refresh_timeline = True
|
||||
print('')
|
||||
|
|
15
epicyon.py
15
epicyon.py
|
@ -157,6 +157,12 @@ def _command_options() -> None:
|
|||
'licenses/by-nc/4.0',
|
||||
help='Url of the license used for the ' +
|
||||
'instance content')
|
||||
parser.add_argument('--media_license_url', type=str,
|
||||
default='https://creativecommons.org/' +
|
||||
'licenses/by-nc/4.0',
|
||||
help='Url of the license used for attached media')
|
||||
parser.add_argument('--media_creator', type=str, default='',
|
||||
help="Attached media creator's name")
|
||||
parser.add_argument('--import_emoji', type=str,
|
||||
default='',
|
||||
help='Import emoji dict from the given filename')
|
||||
|
@ -1704,6 +1710,7 @@ def _command_options() -> None:
|
|||
argb.language, languages_understood,
|
||||
argb.low_bandwidth,
|
||||
argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
argb.eventDate, argb.eventTime, argb.eventEndTime,
|
||||
argb.eventLocation, translate, argb.buyUrl,
|
||||
argb.debug,
|
||||
|
@ -3393,6 +3400,7 @@ def _command_options() -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, argb.language, conversation_id,
|
||||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||
"Zoiks!!!",
|
||||
|
@ -3407,6 +3415,7 @@ def _command_options() -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, argb.language, conversation_id,
|
||||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||
"Hey scoob we need like a hundred more #milkshakes",
|
||||
|
@ -3421,6 +3430,7 @@ def _command_options() -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, argb.language, conversation_id,
|
||||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||
"Getting kinda spooky around here",
|
||||
|
@ -3435,6 +3445,7 @@ def _command_options() -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, argb.language, conversation_id,
|
||||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||
"And they would have gotten away with it too" +
|
||||
|
@ -3450,6 +3461,7 @@ def _command_options() -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, argb.language, conversation_id,
|
||||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||
"man these centralized sites are like the worst!",
|
||||
|
@ -3464,6 +3476,7 @@ def _command_options() -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, argb.language, conversation_id,
|
||||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||
"another mystery solved #test",
|
||||
|
@ -3478,6 +3491,7 @@ def _command_options() -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, argb.language, conversation_id,
|
||||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(base_dir, nickname, domain, port, http_prefix,
|
||||
"let's go bowling",
|
||||
|
@ -3492,6 +3506,7 @@ def _command_options() -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, argb.language, conversation_id,
|
||||
low_bandwidth, argb.content_license_url,
|
||||
argb.media_license_url, argb.media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
domain_full = domain + ':' + str(port)
|
||||
clear_follows(base_dir, nickname, domain)
|
||||
|
|
4
inbox.py
4
inbox.py
|
@ -3780,8 +3780,8 @@ def _bounce_dm(sender_post_id: str, session, http_prefix: str,
|
|||
subject, debug, schedule_post,
|
||||
event_date, event_time, event_end_time,
|
||||
location, system_language, conversation_id,
|
||||
low_bandwidth,
|
||||
content_license_url,
|
||||
low_bandwidth, content_license_url,
|
||||
content_license_url, '',
|
||||
languages_understood, bounce_is_chat,
|
||||
translate, buy_url)
|
||||
if not post_json_object:
|
||||
|
|
12
media.py
12
media.py
|
@ -554,7 +554,8 @@ def attach_media(base_dir: str, http_prefix: str,
|
|||
post_json: {}, image_filename: str,
|
||||
media_type: str, description: str,
|
||||
city: str, low_bandwidth: bool,
|
||||
content_license_url: str) -> {}:
|
||||
content_license_url: str,
|
||||
creator: str) -> {}:
|
||||
"""Attaches media to a json object post
|
||||
The description can be None
|
||||
"""
|
||||
|
@ -599,6 +600,15 @@ def attach_media(base_dir: str, http_prefix: str,
|
|||
'type': 'Document',
|
||||
'url': http_prefix + '://' + domain + '/' + media_path
|
||||
}
|
||||
if content_license_url or creator:
|
||||
attachment_json['@context'] = [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
{'schema': 'https://schema.org#'}
|
||||
]
|
||||
if content_license_url:
|
||||
attachment_json['schema:license'] = content_license_url
|
||||
if creator:
|
||||
attachment_json['schema:creator'] = creator
|
||||
if media_type.startswith('image/'):
|
||||
attachment_json['blurhash'] = _get_blur_hash()
|
||||
# find the dimensions of the image and add them as metadata
|
||||
|
|
|
@ -547,7 +547,9 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
|
|||
allow_local_network_access: bool,
|
||||
system_language: str,
|
||||
low_bandwidth: bool,
|
||||
content_license_url: str) -> None:
|
||||
content_license_url: str,
|
||||
media_license_url: str,
|
||||
media_creator: str) -> None:
|
||||
"""Converts rss items in a newswire into posts
|
||||
"""
|
||||
if not newswire:
|
||||
|
@ -646,6 +648,7 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str,
|
|||
rss_title, system_language,
|
||||
conversation_id, low_bandwidth,
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate,
|
||||
buy_url)
|
||||
if not blog:
|
||||
|
@ -836,7 +839,8 @@ def run_newswire_daemon(base_dir: str, httpd,
|
|||
httpd.allow_local_network_access,
|
||||
httpd.system_language,
|
||||
httpd.low_bandwidth,
|
||||
httpd.content_license_url)
|
||||
httpd.content_license_url,
|
||||
httpd.content_license_url, '')
|
||||
print('Newswire feed converted to ActivityPub')
|
||||
|
||||
if httpd.max_news_posts > 0:
|
||||
|
|
59
posts.py
59
posts.py
|
@ -1108,6 +1108,7 @@ def _attach_post_license(post_json_object: {},
|
|||
"name": "license",
|
||||
"value": content_license_url
|
||||
})
|
||||
post_json_object['schema:license'] = content_license_url
|
||||
|
||||
|
||||
def _attach_buy_link(post_json_object: {},
|
||||
|
@ -1143,8 +1144,9 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
|
|||
post_object_type: str, summary: str,
|
||||
in_reply_to_atom_uri: str, system_language: str,
|
||||
conversation_id: str, low_bandwidth: bool,
|
||||
content_license_url: str, buy_url: str,
|
||||
translate: {}) -> {}:
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
buy_url: str, translate: {}) -> {}:
|
||||
"""Creates a new server-to-server post
|
||||
"""
|
||||
actor_url = local_actor_url(http_prefix, nickname, domain)
|
||||
|
@ -1206,7 +1208,7 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
|
|||
attach_media(base_dir, http_prefix, nickname, domain, port,
|
||||
new_post['object'], attach_image_filename,
|
||||
media_type, image_description, city, low_bandwidth,
|
||||
content_license_url)
|
||||
media_license_url, media_creator)
|
||||
_attach_post_license(new_post['object'], content_license_url)
|
||||
_attach_buy_link(new_post['object'], buy_url, translate)
|
||||
return new_post
|
||||
|
@ -1222,8 +1224,8 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int,
|
|||
post_object_type: str, summary: str,
|
||||
in_reply_to_atom_uri: str, system_language: str,
|
||||
conversation_id: str, low_bandwidth: str,
|
||||
content_license_url: str, buy_url: str,
|
||||
translate: {}) -> {}:
|
||||
content_license_url: str, media_license_url: str,
|
||||
media_creator: str, buy_url: str, translate: {}) -> {}:
|
||||
"""Creates a new client-to-server post
|
||||
"""
|
||||
domain_full = get_full_domain(domain, port)
|
||||
|
@ -1275,7 +1277,7 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int,
|
|||
attach_media(base_dir, http_prefix, nickname, domain, port,
|
||||
new_post, attach_image_filename,
|
||||
media_type, image_description, city, low_bandwidth,
|
||||
content_license_url)
|
||||
media_license_url, media_creator)
|
||||
_attach_post_license(new_post, content_license_url)
|
||||
_attach_buy_link(new_post, buy_url, translate)
|
||||
return new_post
|
||||
|
@ -1486,6 +1488,7 @@ def _create_post_base(base_dir: str,
|
|||
system_language: str,
|
||||
conversation_id: str, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {},
|
||||
buy_url: str) -> {}:
|
||||
"""Creates a message
|
||||
|
@ -1645,7 +1648,8 @@ def _create_post_base(base_dir: str,
|
|||
post_object_type, summary,
|
||||
in_reply_to_atom_uri, system_language,
|
||||
conversation_id, low_bandwidth,
|
||||
content_license_url, buy_url, translate)
|
||||
content_license_url, media_license_url,
|
||||
media_creator, buy_url, translate)
|
||||
else:
|
||||
new_post = \
|
||||
_create_post_c2s(base_dir, nickname, domain, port,
|
||||
|
@ -1658,7 +1662,8 @@ def _create_post_base(base_dir: str,
|
|||
post_object_type, summary,
|
||||
in_reply_to_atom_uri, system_language,
|
||||
conversation_id, low_bandwidth,
|
||||
content_license_url, buy_url, translate)
|
||||
content_license_url, media_license_url,
|
||||
media_creator, buy_url, translate)
|
||||
|
||||
_create_post_mentions(cc_url, new_post, to_recipients, tags)
|
||||
|
||||
|
@ -1899,6 +1904,7 @@ def create_public_post(base_dir: str,
|
|||
location: str, is_article: bool, system_language: str,
|
||||
conversation_id: str, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {},
|
||||
buy_url: str) -> {}:
|
||||
"""Public post
|
||||
|
@ -1934,6 +1940,7 @@ def create_public_post(base_dir: str,
|
|||
event_status, ticket_url, system_language,
|
||||
conversation_id, low_bandwidth,
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
|
||||
|
||||
|
@ -1979,6 +1986,7 @@ def create_blog_post(base_dir: str,
|
|||
location: str, system_language: str,
|
||||
conversation_id: str, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {},
|
||||
buy_url: str) -> {}:
|
||||
blog_json = \
|
||||
|
@ -1993,6 +2001,7 @@ def create_blog_post(base_dir: str,
|
|||
event_date, event_time, event_end_time, location,
|
||||
True, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
blog_json['object']['url'] = \
|
||||
blog_json['object']['url'].replace('/@', '/users/')
|
||||
|
@ -2009,6 +2018,7 @@ def create_news_post(base_dir: str,
|
|||
subject: str, system_language: str,
|
||||
conversation_id: str, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {},
|
||||
buy_url: str) -> {}:
|
||||
client_to_server = False
|
||||
|
@ -2031,6 +2041,7 @@ def create_news_post(base_dir: str,
|
|||
event_date, event_time, event_end_time, location,
|
||||
True, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
blog['object']['type'] = 'Article'
|
||||
return blog
|
||||
|
@ -2047,6 +2058,7 @@ def create_question_post(base_dir: str,
|
|||
subject: str, duration_days: int,
|
||||
system_language: str, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {}) -> {}:
|
||||
"""Question post with multiple choice options
|
||||
"""
|
||||
|
@ -2066,6 +2078,7 @@ def create_question_post(base_dir: str,
|
|||
None, None, None,
|
||||
None, None, None, None, None, system_language,
|
||||
None, low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
message_json['object']['type'] = 'Question'
|
||||
message_json['object']['oneOf'] = []
|
||||
|
@ -2101,6 +2114,7 @@ def create_unlisted_post(base_dir: str,
|
|||
location: str, system_language: str,
|
||||
conversation_id: str, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {},
|
||||
buy_url: str) -> {}:
|
||||
"""Unlisted post. This has the #Public and followers links inverted.
|
||||
|
@ -2121,8 +2135,9 @@ def create_unlisted_post(base_dir: str,
|
|||
None, None, None, event_date, event_end_time,
|
||||
None, None, None, None, None, system_language,
|
||||
conversation_id, low_bandwidth,
|
||||
content_license_url, languages_understood,
|
||||
translate, buy_url)
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
|
||||
|
||||
def create_followers_only_post(base_dir: str,
|
||||
|
@ -2140,6 +2155,7 @@ def create_followers_only_post(base_dir: str,
|
|||
location: str, system_language: str,
|
||||
conversation_id: str, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [],
|
||||
translate: {}, buy_url: str) -> {}:
|
||||
"""Followers only post
|
||||
|
@ -2158,8 +2174,9 @@ def create_followers_only_post(base_dir: str,
|
|||
None, None, None, event_date, event_end_time,
|
||||
None, None, None, None, None, system_language,
|
||||
conversation_id, low_bandwidth,
|
||||
content_license_url, languages_understood,
|
||||
translate, buy_url)
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
|
||||
|
||||
def get_mentioned_people(base_dir: str, http_prefix: str,
|
||||
|
@ -2215,6 +2232,7 @@ def create_direct_message_post(base_dir: str,
|
|||
location: str, system_language: str,
|
||||
conversation_id: str, low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [],
|
||||
dm_is_chat: bool, translate: {},
|
||||
buy_url: str) -> {}:
|
||||
|
@ -2242,8 +2260,9 @@ def create_direct_message_post(base_dir: str,
|
|||
None, None, None, event_date, event_end_time,
|
||||
None, None, None, None, None, system_language,
|
||||
conversation_id, low_bandwidth,
|
||||
content_license_url, languages_understood,
|
||||
translate, buy_url)
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
# mentioned recipients go into To rather than Cc
|
||||
message_json['to'] = message_json['object']['cc']
|
||||
message_json['object']['to'] = message_json['to']
|
||||
|
@ -2267,6 +2286,7 @@ def create_report_post(base_dir: str,
|
|||
debug: bool, subject: str, system_language: str,
|
||||
low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
languages_understood: [], translate: {}) -> {}:
|
||||
"""Send a report to moderators
|
||||
"""
|
||||
|
@ -2346,6 +2366,7 @@ def create_report_post(base_dir: str,
|
|||
None, None, None,
|
||||
None, None, None, None, None, system_language,
|
||||
None, low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
if not post_json_object:
|
||||
continue
|
||||
|
@ -2471,6 +2492,7 @@ def send_post(signing_priv_key_pem: str, project_version: str,
|
|||
shared_items_federated_domains: [],
|
||||
shared_item_federation_tokens: {},
|
||||
low_bandwidth: bool, content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
translate: {}, buy_url: str,
|
||||
debug: bool = False, in_reply_to: str = None,
|
||||
in_reply_to_atom_uri: str = None, subject: str = None) -> int:
|
||||
|
@ -2538,7 +2560,9 @@ def send_post(signing_priv_key_pem: str, project_version: str,
|
|||
None, None, None,
|
||||
None, None, None, None, None, system_language,
|
||||
conversation_id, low_bandwidth,
|
||||
content_license_url, languages_understood,
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood,
|
||||
translate, buy_url)
|
||||
|
||||
# get the senders private key
|
||||
|
@ -2635,6 +2659,7 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
|
|||
languages_understood: [],
|
||||
low_bandwidth: bool,
|
||||
content_license_url: str,
|
||||
media_license_url: str, media_creator: str,
|
||||
event_date: str, event_time: str, event_end_time: str,
|
||||
location: str, translate: {}, buy_url: str,
|
||||
debug: bool = False,
|
||||
|
@ -2727,7 +2752,9 @@ def send_post_via_server(signing_priv_key_pem: str, project_version: str,
|
|||
None, None, None, event_date, event_end_time,
|
||||
None, None, None, None, None, system_language,
|
||||
conversation_id, low_bandwidth,
|
||||
content_license_url, languages_understood,
|
||||
content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood,
|
||||
translate, buy_url)
|
||||
|
||||
auth_header = create_basic_auth_header(from_nickname, password)
|
||||
|
|
47
tests.py
47
tests.py
|
@ -774,6 +774,8 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
conversation_id = None
|
||||
translate = {}
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Mr Blobby'
|
||||
buy_url = ''
|
||||
create_public_post(path, nickname, domain, port, http_prefix,
|
||||
"No wise fish would go anywhere without a porpoise",
|
||||
|
@ -789,6 +791,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(path, nickname, domain, port, http_prefix,
|
||||
"Curiouser and curiouser!",
|
||||
|
@ -804,6 +807,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(path, nickname, domain, port, http_prefix,
|
||||
"In the gardens of memory, in the palace " +
|
||||
|
@ -820,6 +824,7 @@ def create_server_alice(path: str, domain: str, port: int,
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
regenerate_index_for_box(path, nickname, domain, 'outbox')
|
||||
global TEST_SERVER_ALICE_RUNNING
|
||||
|
@ -938,6 +943,8 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
test_is_article = False
|
||||
conversation_id = None
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Hamster'
|
||||
translate = {}
|
||||
buy_url = ''
|
||||
create_public_post(path, nickname, domain, port, http_prefix,
|
||||
|
@ -954,6 +961,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(path, nickname, domain, port, http_prefix,
|
||||
"One of the things I've realised is that " +
|
||||
|
@ -970,6 +978,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
create_public_post(path, nickname, domain, port, http_prefix,
|
||||
"Quantum physics is a bit of a passion of mine",
|
||||
|
@ -985,6 +994,7 @@ def create_server_bob(path: str, domain: str, port: int,
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
regenerate_index_for_box(path, nickname, domain, 'outbox')
|
||||
global TEST_SERVER_BOB_RUNNING
|
||||
|
@ -1235,6 +1245,8 @@ def test_post_message_between_servers(base_dir: str) -> None:
|
|||
http_prefix = 'http'
|
||||
proxy_type = None
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Secret Squirrel'
|
||||
|
||||
if os.path.isdir(base_dir + '/.tests'):
|
||||
shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None)
|
||||
|
@ -1339,7 +1351,8 @@ def test_post_message_between_servers(base_dir: str) -> None:
|
|||
languages_understood,
|
||||
alice_shared_items_federated_domains,
|
||||
alice_shared_item_federation_tokens, low_bandwidth,
|
||||
content_license_url, translate, buy_url,
|
||||
content_license_url, media_license_url, media_creator,
|
||||
translate, buy_url,
|
||||
in_reply_to, in_reply_to_atom_uri, subject)
|
||||
print('send_result: ' + str(send_result))
|
||||
|
||||
|
@ -1568,6 +1581,8 @@ def test_follow_between_servers(base_dir: str) -> None:
|
|||
proxy_type = None
|
||||
federation_list = []
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Penfold'
|
||||
|
||||
if os.path.isdir(base_dir + '/.tests'):
|
||||
shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None)
|
||||
|
@ -1712,7 +1727,8 @@ def test_follow_between_servers(base_dir: str) -> None:
|
|||
languages_understood,
|
||||
alice_shared_items_federated_domains,
|
||||
alice_shared_item_federation_tokens, low_bandwidth,
|
||||
content_license_url, translate, buy_url,
|
||||
content_license_url, media_license_url, media_creator,
|
||||
translate, buy_url,
|
||||
in_reply_to, in_reply_to_atom_uri, subject)
|
||||
print('send_result: ' + str(send_result))
|
||||
|
||||
|
@ -1763,6 +1779,8 @@ def test_shared_items_federation(base_dir: str) -> None:
|
|||
proxy_type = None
|
||||
federation_list = []
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Dr Drokk'
|
||||
|
||||
if os.path.isdir(base_dir + '/.tests'):
|
||||
shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None)
|
||||
|
@ -2080,7 +2098,8 @@ def test_shared_items_federation(base_dir: str) -> None:
|
|||
languages_understood,
|
||||
alice_shared_items_federated_domains,
|
||||
alice_shared_item_federation_tokens, low_bandwidth,
|
||||
content_license_url, translate, buy_url, True,
|
||||
content_license_url, media_license_url, media_creator,
|
||||
translate, buy_url, True,
|
||||
in_reply_to, in_reply_to_atom_uri, subject)
|
||||
print('send_result: ' + str(send_result))
|
||||
|
||||
|
@ -2186,6 +2205,8 @@ def test_group_follow(base_dir: str) -> None:
|
|||
proxy_type = None
|
||||
federation_list = []
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Bumble'
|
||||
|
||||
if os.path.isdir(base_dir + '/.tests'):
|
||||
shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None)
|
||||
|
@ -2511,7 +2532,8 @@ def test_group_follow(base_dir: str) -> None:
|
|||
languages_understood,
|
||||
alice_shared_items_federated_domains,
|
||||
alice_shared_item_federation_tokens, low_bandwidth,
|
||||
content_license_url, translate, buy_url,
|
||||
content_license_url, media_license_url, media_creator,
|
||||
translate, buy_url,
|
||||
in_reply_to, in_reply_to_atom_uri, subject)
|
||||
print('send_result: ' + str(send_result))
|
||||
|
||||
|
@ -2881,6 +2903,8 @@ def _test_create_person_account(base_dir: str):
|
|||
low_bandwidth = True
|
||||
translate = {}
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Hissing Sid'
|
||||
content = \
|
||||
"If your \"independent organization\" is government funded...\n\n" + \
|
||||
"(yawn)\n\n...then it's not really independent.\n\n" + \
|
||||
|
@ -2899,6 +2923,7 @@ def _test_create_person_account(base_dir: str):
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
assert test_post_json
|
||||
assert test_post_json.get('object')
|
||||
|
@ -2925,6 +2950,7 @@ def _test_create_person_account(base_dir: str):
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
assert test_post_json
|
||||
assert test_post_json.get('object')
|
||||
|
@ -3005,6 +3031,8 @@ def test_client_to_server(base_dir: str):
|
|||
global TEST_SERVER_ALICE_RUNNING
|
||||
global TEST_SERVER_BOB_RUNNING
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'King Tut'
|
||||
TEST_SERVER_ALICE_RUNNING = False
|
||||
TEST_SERVER_BOB_RUNNING = False
|
||||
|
||||
|
@ -3138,6 +3166,7 @@ def test_client_to_server(base_dir: str):
|
|||
cached_webfingers, person_cache, is_article,
|
||||
system_language, languages_understood,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
event_date, event_time, event_end_time, location,
|
||||
translate, buy_url, True, None, None,
|
||||
conversation_id, None)
|
||||
|
@ -4738,6 +4767,8 @@ def _test_reply_to_public_post(base_dir: str) -> None:
|
|||
conversation_id = None
|
||||
low_bandwidth = True
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Skeletor'
|
||||
translate = {}
|
||||
buy_url = ''
|
||||
reply = \
|
||||
|
@ -4752,6 +4783,7 @@ def _test_reply_to_public_post(base_dir: str) -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
# print(str(reply))
|
||||
expected_str = \
|
||||
|
@ -5689,6 +5721,8 @@ def _test_links_within_post(base_dir: str) -> None:
|
|||
conversation_id = None
|
||||
low_bandwidth = True
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'Dr No'
|
||||
translate = {}
|
||||
buy_url = ''
|
||||
|
||||
|
@ -5704,6 +5738,7 @@ def _test_links_within_post(base_dir: str) -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
|
||||
expected_str = \
|
||||
|
@ -5748,6 +5783,7 @@ def _test_links_within_post(base_dir: str) -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
assert post_json_object['object']['content'] == content
|
||||
assert post_json_object['object']['contentMap'][system_language] == content
|
||||
|
@ -6799,6 +6835,8 @@ def _test_can_replyto(base_dir: str) -> None:
|
|||
conversation_id = None
|
||||
low_bandwidth = True
|
||||
content_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_license_url = 'https://creativecommons.org/licenses/by-nc/4.0'
|
||||
media_creator = 'The Penguin'
|
||||
translate = {}
|
||||
buy_url = ''
|
||||
|
||||
|
@ -6814,6 +6852,7 @@ def _test_can_replyto(base_dir: str) -> None:
|
|||
test_event_end_time, test_location,
|
||||
test_is_article, system_language, conversation_id,
|
||||
low_bandwidth, content_license_url,
|
||||
media_license_url, media_creator,
|
||||
languages_understood, translate, buy_url)
|
||||
# set the date on the post
|
||||
curr_date_str = "2021-09-08T20:45:00Z"
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "شراء",
|
||||
"Subscribe": "الإشتراك",
|
||||
"Buy link": "رابط شراء",
|
||||
"Buy links are allowed from the following domains": "روابط الشراء مسموح بها من المجالات التالية"
|
||||
"Buy links are allowed from the following domains": "روابط الشراء مسموح بها من المجالات التالية",
|
||||
"Media license": "رخصة وسائل الإعلام",
|
||||
"Media creator": "صانع الوسائط"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "ক্রয়",
|
||||
"Subscribe": "সাবস্ক্রাইব",
|
||||
"Buy link": "সংযোগ কেনা",
|
||||
"Buy links are allowed from the following domains": "নিম্নলিখিত ডোমেনগুলি থেকে লিঙ্কগুলি কেনার অনুমতি দেওয়া হয়েছে"
|
||||
"Buy links are allowed from the following domains": "নিম্নলিখিত ডোমেনগুলি থেকে লিঙ্কগুলি কেনার অনুমতি দেওয়া হয়েছে",
|
||||
"Media license": "মিডিয়া লাইসেন্স",
|
||||
"Media creator": "মিডিয়া নির্মাতা"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Compra",
|
||||
"Subscribe": "Subscriu-te",
|
||||
"Buy link": "Enllaç de compra",
|
||||
"Buy links are allowed from the following domains": "Els enllaços de compra es permeten des dels dominis següents"
|
||||
"Buy links are allowed from the following domains": "Els enllaços de compra es permeten des dels dominis següents",
|
||||
"Media license": "Llicència de mitjans",
|
||||
"Media creator": "Creador de mitjans"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Prynu",
|
||||
"Subscribe": "Tanysgrifio",
|
||||
"Buy link": "Prynu dolen",
|
||||
"Buy links are allowed from the following domains": "Caniateir dolenni prynu o'r parthau canlynol"
|
||||
"Buy links are allowed from the following domains": "Caniateir dolenni prynu o'r parthau canlynol",
|
||||
"Media license": "Trwydded cyfryngau",
|
||||
"Media creator": "Crëwr cyfryngau"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Kaufen",
|
||||
"Subscribe": "Abonnieren",
|
||||
"Buy link": "Link kaufen",
|
||||
"Buy links are allowed from the following domains": "Kauflinks sind von den folgenden Domains erlaubt"
|
||||
"Buy links are allowed from the following domains": "Kauflinks sind von den folgenden Domains erlaubt",
|
||||
"Media license": "Medienlizenz",
|
||||
"Media creator": "Mediengestalter"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Αγορά",
|
||||
"Subscribe": "Εγγραφείτε",
|
||||
"Buy link": "Σύνδεσμος αγοράς",
|
||||
"Buy links are allowed from the following domains": "Οι σύνδεσμοι αγοράς επιτρέπονται από τους παρακάτω τομείς"
|
||||
"Buy links are allowed from the following domains": "Οι σύνδεσμοι αγοράς επιτρέπονται από τους παρακάτω τομείς",
|
||||
"Media license": "Άδεια ΜΜΕ",
|
||||
"Media creator": "Δημιουργός πολυμέσων"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Purchase",
|
||||
"Subscribe": "Subscribe",
|
||||
"Buy link": "Buy link",
|
||||
"Buy links are allowed from the following domains": "Buy links are allowed from the following domains"
|
||||
"Buy links are allowed from the following domains": "Buy links are allowed from the following domains",
|
||||
"Media license": "Media license",
|
||||
"Media creator": "Media creator"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Compra",
|
||||
"Subscribe": "Suscribir",
|
||||
"Buy link": "Enlace de compra",
|
||||
"Buy links are allowed from the following domains": "Se permiten enlaces de compra de los siguientes dominios"
|
||||
"Buy links are allowed from the following domains": "Se permiten enlaces de compra de los siguientes dominios",
|
||||
"Media license": "Licencia de medios",
|
||||
"Media creator": "Creadora de medios"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "خرید",
|
||||
"Subscribe": "اشتراک در",
|
||||
"Buy link": "لینک خرید",
|
||||
"Buy links are allowed from the following domains": "لینک خرید از دامنه های زیر مجاز است"
|
||||
"Buy links are allowed from the following domains": "لینک خرید از دامنه های زیر مجاز است",
|
||||
"Media license": "مجوز رسانه",
|
||||
"Media creator": "سازنده رسانه"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Acheter",
|
||||
"Subscribe": "S'abonner",
|
||||
"Buy link": "Acheter un lien",
|
||||
"Buy links are allowed from the following domains": "Les liens d'achat sont autorisés à partir des domaines suivants"
|
||||
"Buy links are allowed from the following domains": "Les liens d'achat sont autorisés à partir des domaines suivants",
|
||||
"Media license": "Licence média",
|
||||
"Media creator": "Créateur de médias"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Ceannach",
|
||||
"Subscribe": "Liostáil",
|
||||
"Buy link": "Ceannaigh nasc",
|
||||
"Buy links are allowed from the following domains": "Ceadaítear naisc cheannaigh ó na fearainn seo a leanas"
|
||||
"Buy links are allowed from the following domains": "Ceadaítear naisc cheannaigh ó na fearainn seo a leanas",
|
||||
"Media license": "Ceadúnas meáin",
|
||||
"Media creator": "Cruthaitheoir meáin"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "खरीदना",
|
||||
"Subscribe": "सदस्यता लेने के",
|
||||
"Buy link": "लिंक खरीदें",
|
||||
"Buy links are allowed from the following domains": "निम्नलिखित डोमेन से खरीदें लिंक की अनुमति है"
|
||||
"Buy links are allowed from the following domains": "निम्नलिखित डोमेन से खरीदें लिंक की अनुमति है",
|
||||
"Media license": "मीडिया लाइसेंस",
|
||||
"Media creator": "मीडिया निर्माता"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Acquistare",
|
||||
"Subscribe": "Sottoscrivi",
|
||||
"Buy link": "Link per l'acquisto",
|
||||
"Buy links are allowed from the following domains": "I link di acquisto sono consentiti dai seguenti domini"
|
||||
"Buy links are allowed from the following domains": "I link di acquisto sono consentiti dai seguenti domini",
|
||||
"Media license": "Licenza multimediale",
|
||||
"Media creator": "Creatore multimediale"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "購入",
|
||||
"Subscribe": "申し込む",
|
||||
"Buy link": "購入リンク",
|
||||
"Buy links are allowed from the following domains": "次のドメインからの購入リンクが許可されています"
|
||||
"Buy links are allowed from the following domains": "次のドメインからの購入リンクが許可されています",
|
||||
"Media license": "メディアライセンス",
|
||||
"Media creator": "メディアクリエーター"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "구입",
|
||||
"Subscribe": "구독하다",
|
||||
"Buy link": "구매 링크",
|
||||
"Buy links are allowed from the following domains": "다음 도메인에서 구매 링크가 허용됩니다."
|
||||
"Buy links are allowed from the following domains": "다음 도메인에서 구매 링크가 허용됩니다.",
|
||||
"Media license": "미디어 라이센스",
|
||||
"Media creator": "미디어 크리에이터"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Kirrîn",
|
||||
"Subscribe": "Subscribe",
|
||||
"Buy link": "Girêdanê bikirin",
|
||||
"Buy links are allowed from the following domains": "Zencîreyên kirînê ji domên jêrîn têne destûr kirin"
|
||||
"Buy links are allowed from the following domains": "Zencîreyên kirînê ji domên jêrîn têne destûr kirin",
|
||||
"Media license": "Lîsansa medyayê",
|
||||
"Media creator": "Afirînerê medyayê"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Aankoop",
|
||||
"Subscribe": "Abonneren",
|
||||
"Buy link": "koop link",
|
||||
"Buy links are allowed from the following domains": "Kooplinks zijn toegestaan vanaf de volgende domeinen"
|
||||
"Buy links are allowed from the following domains": "Kooplinks zijn toegestaan vanaf de volgende domeinen",
|
||||
"Media license": "Media licentie",
|
||||
"Media creator": "Media-maker"
|
||||
}
|
||||
|
|
|
@ -608,5 +608,7 @@
|
|||
"Purchase": "Purchase",
|
||||
"Subscribe": "Subscribe",
|
||||
"Buy link": "Buy link",
|
||||
"Buy links are allowed from the following domains": "Buy links are allowed from the following domains"
|
||||
"Buy links are allowed from the following domains": "Buy links are allowed from the following domains",
|
||||
"Media license": "Media license",
|
||||
"Media creator": "Media creator"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Zakup",
|
||||
"Subscribe": "Subskrybuj",
|
||||
"Buy link": "Kup Link",
|
||||
"Buy links are allowed from the following domains": "Kupuj linki są dozwolone z następujących domen"
|
||||
"Buy links are allowed from the following domains": "Kupuj linki są dozwolone z następujących domen",
|
||||
"Media license": "Licencja medialna",
|
||||
"Media creator": "Kreator mediów"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Comprar",
|
||||
"Subscribe": "Se inscrever",
|
||||
"Buy link": "Link de compra",
|
||||
"Buy links are allowed from the following domains": "Links de compra são permitidos nos seguintes domínios"
|
||||
"Buy links are allowed from the following domains": "Links de compra são permitidos nos seguintes domínios",
|
||||
"Media license": "Licença de mídia",
|
||||
"Media creator": "Criador de mídia"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Покупка",
|
||||
"Subscribe": "Подписаться",
|
||||
"Buy link": "Купить ссылку",
|
||||
"Buy links are allowed from the following domains": "Ссылки на покупку разрешены со следующих доменов"
|
||||
"Buy links are allowed from the following domains": "Ссылки на покупку разрешены со следующих доменов",
|
||||
"Media license": "Медиа лицензия",
|
||||
"Media creator": "Создатель медиа"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Nunua",
|
||||
"Subscribe": "Jisajili",
|
||||
"Buy link": "Nunua kiungo",
|
||||
"Buy links are allowed from the following domains": "Viungo vya kununua vinaruhusiwa kutoka kwa vikoa vifuatavyo"
|
||||
"Buy links are allowed from the following domains": "Viungo vya kununua vinaruhusiwa kutoka kwa vikoa vifuatavyo",
|
||||
"Media license": "Leseni ya media",
|
||||
"Media creator": "Muundaji wa media"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Satın alma",
|
||||
"Subscribe": "Abone",
|
||||
"Buy link": "Bağlantı satın al",
|
||||
"Buy links are allowed from the following domains": "Aşağıdaki alanlardan satın alma bağlantılarına izin verilir"
|
||||
"Buy links are allowed from the following domains": "Aşağıdaki alanlardan satın alma bağlantılarına izin verilir",
|
||||
"Media license": "Medya lisansı",
|
||||
"Media creator": "Medya yaratıcısı"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "Купівля",
|
||||
"Subscribe": "Підпишіться",
|
||||
"Buy link": "Купити посилання",
|
||||
"Buy links are allowed from the following domains": "Посилання на купівлю дозволено з таких доменів"
|
||||
"Buy links are allowed from the following domains": "Посилання на купівлю дозволено з таких доменів",
|
||||
"Media license": "Медіа ліцензія",
|
||||
"Media creator": "Творець медіа"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "קויפן",
|
||||
"Subscribe": "אַבאָנירן",
|
||||
"Buy link": "קויפן לינק",
|
||||
"Buy links are allowed from the following domains": "קויפן פֿאַרבינדונגען זענען ערלויבט פֿון די פאלגענדע דאָומיינז"
|
||||
"Buy links are allowed from the following domains": "קויפן פֿאַרבינדונגען זענען ערלויבט פֿון די פאלגענדע דאָומיינז",
|
||||
"Media license": "מעדיע דערלויבעניש",
|
||||
"Media creator": "מעדיע באשעפער"
|
||||
}
|
||||
|
|
|
@ -612,5 +612,7 @@
|
|||
"Purchase": "购买",
|
||||
"Subscribe": "订阅",
|
||||
"Buy link": "购买链接",
|
||||
"Buy links are allowed from the following domains": "允许来自以下域的购买链接"
|
||||
"Buy links are allowed from the following domains": "允许来自以下域的购买链接",
|
||||
"Media license": "媒体许可证",
|
||||
"Media creator": "媒体创作者"
|
||||
}
|
||||
|
|
|
@ -489,6 +489,13 @@ def html_new_post(edit_post_params: {},
|
|||
' <textarea id="imageDescription" name="imageDescription" ' + \
|
||||
'style="height:' + str(image_description_height) + \
|
||||
'px" spellcheck="true" autocomplete="on"></textarea>\n'
|
||||
media_creator_str = translate['Media creator']
|
||||
new_post_image_section += \
|
||||
edit_text_field(media_creator_str, 'mediaCreator', '', '')
|
||||
media_license_str = translate['Media license']
|
||||
new_post_image_section += \
|
||||
edit_text_field(media_license_str, 'mediaLicense',
|
||||
'', 'CC-BY-NC')
|
||||
new_post_image_section += end_edit_section()
|
||||
|
||||
new_post_emoji_section = ''
|
||||
|
|
|
@ -1795,7 +1795,15 @@ def _get_content_license(post_json_object: {}) -> str:
|
|||
"""Returns the content license for the given post
|
||||
"""
|
||||
if not post_json_object['object'].get('attachment'):
|
||||
return None
|
||||
if not post_json_object['object'].get('schema:license'):
|
||||
return None
|
||||
|
||||
if post_json_object['object'].get('schema:license'):
|
||||
value = post_json_object['object']['schema:license']
|
||||
if '://' not in value:
|
||||
value = license_link_from_name(value)
|
||||
return value
|
||||
|
||||
for item in post_json_object['object']['attachment']:
|
||||
if not item.get('name'):
|
||||
continue
|
||||
|
@ -2387,7 +2395,8 @@ def individual_post_as_html(signing_priv_key_pem: str,
|
|||
reply_str, announce_str, like_str,
|
||||
bookmark_str, delete_str, mute_str,
|
||||
content_str,
|
||||
minimize_all_images)
|
||||
minimize_all_images,
|
||||
system_language)
|
||||
|
||||
published_str = \
|
||||
_get_published_date_str(post_json_object, show_published_date_only,
|
||||
|
|
|
@ -11,6 +11,7 @@ import os
|
|||
from shutil import copyfile
|
||||
from collections import OrderedDict
|
||||
from session import get_json
|
||||
from utils import dangerous_markup
|
||||
from utils import acct_handle_dir
|
||||
from utils import remove_id_ending
|
||||
from utils import get_attachment_property_value
|
||||
|
@ -30,6 +31,7 @@ from utils import get_image_extensions
|
|||
from utils import local_actor_url
|
||||
from utils import text_in_file
|
||||
from utils import remove_eol
|
||||
from filters import is_filtered
|
||||
from cache import store_person_in_cache
|
||||
from content import add_html_tags
|
||||
from content import replace_emoji_from_tags
|
||||
|
@ -1212,7 +1214,8 @@ def get_post_attachments_as_html(base_dir: str,
|
|||
bookmark_str: str, delete_str: str,
|
||||
mute_str: str,
|
||||
content: str,
|
||||
minimize_all_images: bool) -> (str, str):
|
||||
minimize_all_images: bool,
|
||||
system_language: str) -> (str, str):
|
||||
"""Returns a string representing any attachments
|
||||
"""
|
||||
attachment_str = ''
|
||||
|
@ -1233,6 +1236,25 @@ def get_post_attachments_as_html(base_dir: str,
|
|||
for attach in post_json_object['object']['attachment']:
|
||||
if not (attach.get('mediaType') and attach.get('url')):
|
||||
continue
|
||||
media_license = ''
|
||||
if attach.get('schema:license'):
|
||||
if not dangerous_markup(attach['schema:license'], False):
|
||||
if not is_filtered(base_dir, nickname, domain,
|
||||
attach['schema:license'],
|
||||
system_language):
|
||||
if '://' not in attach['schema:license']:
|
||||
if len(attach['schema:license']) < 60:
|
||||
media_license = attach['schema:license']
|
||||
else:
|
||||
media_license = attach['schema:license']
|
||||
media_creator = ''
|
||||
if attach.get('schema:creator'):
|
||||
if len(attach['schema:creator']) < 60:
|
||||
if not dangerous_markup(attach['schema:creator'], False):
|
||||
if not is_filtered(base_dir, nickname, domain,
|
||||
attach['schema:creator'],
|
||||
system_language):
|
||||
media_creator = attach['schema:creator']
|
||||
|
||||
media_type = attach['mediaType']
|
||||
image_description = ''
|
||||
|
@ -1270,11 +1292,30 @@ def get_post_attachments_as_html(base_dir: str,
|
|||
gallery_str += '<div class="gallery">\n'
|
||||
if not is_muted:
|
||||
gallery_str += ' <a href="' + image_url + '">\n'
|
||||
if media_license or media_creator:
|
||||
gallery_str += ' <figure>\n'
|
||||
gallery_str += \
|
||||
' <img loading="lazy" ' + \
|
||||
'decoding="async" src="' + \
|
||||
image_url + '" alt="" title="">\n'
|
||||
gallery_str += ' </a>\n'
|
||||
license_str = ''
|
||||
if media_license:
|
||||
if '://' in media_license:
|
||||
license_str += \
|
||||
'<a href="' + media_license + \
|
||||
'" target="_blank" ' + \
|
||||
'rel="nofollow noopener noreferrer">©</a>'
|
||||
else:
|
||||
license_str += media_license
|
||||
if media_creator:
|
||||
if license_str:
|
||||
license_str += ' '
|
||||
license_str += media_creator
|
||||
if media_license or media_creator:
|
||||
gallery_str += \
|
||||
' ' + license_str + \
|
||||
'</figcaption></figure>\n'
|
||||
if post_json_object['object'].get('url'):
|
||||
image_post_url = post_json_object['object']['url']
|
||||
else:
|
||||
|
@ -1337,11 +1378,30 @@ def get_post_attachments_as_html(base_dir: str,
|
|||
'<div id="' + post_id + '">\n'
|
||||
|
||||
attachment_str += '<a href="' + image_url + '" tabindex="10">'
|
||||
if media_license or media_creator:
|
||||
attachment_str += '<figure>'
|
||||
attachment_str += \
|
||||
'<img loading="lazy" decoding="async" ' + \
|
||||
'src="' + image_url + \
|
||||
'" alt="' + image_description + '" title="' + \
|
||||
image_description + '" class="attachment"></a>\n'
|
||||
if media_license or media_creator:
|
||||
attachment_str += '<figcaption>'
|
||||
license_str = ''
|
||||
if media_license:
|
||||
if '://' in media_license:
|
||||
license_str += \
|
||||
'<a href="' + media_license + \
|
||||
'" target="_blank" ' + \
|
||||
'rel="nofollow noopener noreferrer">©</a>'
|
||||
else:
|
||||
license_str += media_license
|
||||
if media_creator:
|
||||
if license_str:
|
||||
license_str += ' '
|
||||
license_str += media_creator
|
||||
if media_license or media_creator:
|
||||
attachment_str += license_str + '</figcaption></figure>'
|
||||
|
||||
if minimize_images:
|
||||
attachment_str += '</div></details>\n'
|
||||
|
|
Loading…
Reference in New Issue