From ec704d6afe4514244ff41a04cd35f29672604ca6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 22 Jan 2023 22:43:55 +0000 Subject: [PATCH 01/14] Attach license to images --- media.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/media.py b/media.py index 645701318..586f77930 100644 --- a/media.py +++ b/media.py @@ -599,6 +599,12 @@ def attach_media(base_dir: str, http_prefix: str, 'type': 'Document', 'url': http_prefix + '://' + domain + '/' + media_path } + if content_license_url: + attachment_json['@context'] = [ + 'https://www.w3.org/ns/activitystreams', + {'schema': 'https://schema.org#'} + ] + attachment_json['schema:license'] = content_license_url if media_type.startswith('image/'): attachment_json['blurhash'] = _get_blur_hash() # find the dimensions of the image and add them as metadata From 6ed1d3166eae07e6ef2db8725540cb6c19c006b0 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 22 Jan 2023 22:56:15 +0000 Subject: [PATCH 02/14] Check for media license --- daemon.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemon.py b/daemon.py index a719a8e04..f21661355 100644 --- a/daemon.py +++ b/daemon.py @@ -21043,6 +21043,9 @@ 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'] post_json_object['object'] = \ attach_media(self.server.base_dir, self.server.http_prefix, @@ -21055,7 +21058,7 @@ class PubServer(BaseHTTPRequestHandler): img_description, city, self.server.low_bandwidth, - self.server.content_license_url) + license_url) replace_you_tube(post_json_object, self.server.yt_replace_domain, From bdde4450c1589e3a2a117e19040f92055c2624f4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 22 Jan 2023 23:47:13 +0000 Subject: [PATCH 03/14] Add arguments for media license --- daemon.py | 34 +++++++++++++++++++++++++++++- desktop_client.py | 12 +++++++++++ epicyon.py | 13 ++++++++++++ inbox.py | 2 +- newsdaemon.py | 5 ++++- posts.py | 53 +++++++++++++++++++++++++++++++++-------------- tests.py | 34 ++++++++++++++++++++++++++---- 7 files changed, 130 insertions(+), 23 deletions(-) diff --git a/daemon.py b/daemon.py index f21661355..4150924a9 100644 --- a/daemon.py +++ b/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,9 @@ 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'] message_json = \ create_public_post(self.server.base_dir, nickname, @@ -20817,6 +20821,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, + media_license_url, languages_understood, self.server.translate, buy_url) if message_json: @@ -20936,6 +20941,9 @@ 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'] message_json = \ create_blog_post(self.server.base_dir, nickname, self.server.domain, self.server.port, @@ -20957,6 +20965,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, + media_license_url, languages_understood, self.server.translate, buy_url) if message_json: @@ -21101,7 +21110,9 @@ 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'] message_json = \ create_unlisted_post(self.server.base_dir, nickname, @@ -21125,6 +21136,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, + media_license_url, languages_understood, self.server.translate, buy_url) if message_json: @@ -21211,6 +21223,9 @@ 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'] message_json = \ create_followers_only_post(self.server.base_dir, nickname, @@ -21236,6 +21251,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, + media_license_url, languages_understood, self.server.translate, buy_url) @@ -21331,6 +21347,9 @@ 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'] message_json = \ create_direct_message_post(self.server.base_dir, nickname, @@ -21359,6 +21378,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, content_license_url, + media_license_url, languages_understood, reply_is_chat, self.server.translate, @@ -21453,6 +21473,9 @@ 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'] message_json = \ create_direct_message_post(self.server.base_dir, nickname, @@ -21477,6 +21500,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, + media_license_url, languages_understood, False, self.server.translate, buy_url) @@ -21559,6 +21583,9 @@ 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'] message_json = \ create_report_post(self.server.base_dir, nickname, @@ -21573,6 +21600,7 @@ class PubServer(BaseHTTPRequestHandler): fields['languagesDropdown'], self.server.low_bandwidth, self.server.content_license_url, + media_license_url, languages_understood, self.server.translate) if message_json: @@ -21609,6 +21637,9 @@ 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'] message_json = \ create_question_post(self.server.base_dir, nickname, @@ -21626,6 +21657,7 @@ class PubServer(BaseHTTPRequestHandler): fields['languagesDropdown'], self.server.low_bandwidth, self.server.content_license_url, + media_license_url, languages_understood, self.server.translate) if message_json: diff --git a/desktop_client.py b/desktop_client.py index 3a860768d..653136b82 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -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, 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, 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, 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, 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, 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, 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, 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, event_date, event_time, event_end_time, location, translate, buy_url, debug, None, None, conversation_id, subject) == 0: @@ -1447,6 +1455,7 @@ 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' blocked_cache = {} languages_understood = [] @@ -1853,6 +1862,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, espeak, conversation_id, low_bandwidth, content_license_url, + media_license_url, signing_priv_key_pem, translate) refresh_timeline = True @@ -1891,6 +1901,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, signing_priv_key_pem, translate) refresh_timeline = True else: @@ -1904,6 +1915,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, signing_priv_key_pem, translate) refresh_timeline = True print('') diff --git a/epicyon.py b/epicyon.py index f3b917553..5c30c9055 100644 --- a/epicyon.py +++ b/epicyon.py @@ -157,6 +157,10 @@ 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('--import_emoji', type=str, default='', help='Import emoji dict from the given filename') @@ -1704,6 +1708,7 @@ def _command_options() -> None: argb.language, languages_understood, argb.low_bandwidth, argb.content_license_url, + argb.media_license_url, argb.eventDate, argb.eventTime, argb.eventEndTime, argb.eventLocation, translate, argb.buyUrl, argb.debug, @@ -3393,6 +3398,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, languages_understood, translate, buy_url) create_public_post(base_dir, nickname, domain, port, http_prefix, "Zoiks!!!", @@ -3407,6 +3413,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, 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 +3428,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, languages_understood, translate, buy_url) create_public_post(base_dir, nickname, domain, port, http_prefix, "Getting kinda spooky around here", @@ -3435,6 +3443,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, 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 +3459,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, 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 +3474,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, languages_understood, translate, buy_url) create_public_post(base_dir, nickname, domain, port, http_prefix, "another mystery solved #test", @@ -3478,6 +3489,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, languages_understood, translate, buy_url) create_public_post(base_dir, nickname, domain, port, http_prefix, "let's go bowling", @@ -3492,6 +3504,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, languages_understood, translate, buy_url) domain_full = domain + ':' + str(port) clear_follows(base_dir, nickname, domain) diff --git a/inbox.py b/inbox.py index a6bb4fba8..ea02f57f3 100644 --- a/inbox.py +++ b/inbox.py @@ -3781,7 +3781,7 @@ def _bounce_dm(sender_post_id: str, session, http_prefix: str, event_date, event_time, event_end_time, location, system_language, conversation_id, low_bandwidth, - content_license_url, + content_license_url, content_license_url, languages_understood, bounce_is_chat, translate, buy_url) if not post_json_object: diff --git a/newsdaemon.py b/newsdaemon.py index a12d983db..541e0c1ec 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -547,7 +547,8 @@ 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) -> None: """Converts rss items in a newswire into posts """ if not newswire: @@ -646,6 +647,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, languages_understood, translate, buy_url) if not blog: @@ -836,6 +838,7 @@ 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) print('Newswire feed converted to ActivityPub') diff --git a/posts.py b/posts.py index 47a394659..821e4e843 100644 --- a/posts.py +++ b/posts.py @@ -1143,8 +1143,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, + buy_url: str, translate: {}) -> {}: """Creates a new server-to-server post """ actor_url = local_actor_url(http_prefix, nickname, domain) @@ -1206,7 +1207,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) _attach_post_license(new_post['object'], content_license_url) _attach_buy_link(new_post['object'], buy_url, translate) return new_post @@ -1222,8 +1223,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, + buy_url: str, translate: {}) -> {}: """Creates a new client-to-server post """ domain_full = get_full_domain(domain, port) @@ -1275,7 +1276,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) _attach_post_license(new_post, content_license_url) _attach_buy_link(new_post, buy_url, translate) return new_post @@ -1486,6 +1487,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, languages_understood: [], translate: {}, buy_url: str) -> {}: """Creates a message @@ -1645,7 +1647,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, + buy_url, translate) else: new_post = \ _create_post_c2s(base_dir, nickname, domain, port, @@ -1658,7 +1661,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, + buy_url, translate) _create_post_mentions(cc_url, new_post, to_recipients, tags) @@ -1899,6 +1903,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, languages_understood: [], translate: {}, buy_url: str) -> {}: """Public post @@ -1934,6 +1939,7 @@ def create_public_post(base_dir: str, event_status, ticket_url, system_language, conversation_id, low_bandwidth, content_license_url, + media_license_url, languages_understood, translate, buy_url) @@ -1979,6 +1985,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, languages_understood: [], translate: {}, buy_url: str) -> {}: blog_json = \ @@ -1993,6 +2000,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, languages_understood, translate, buy_url) blog_json['object']['url'] = \ blog_json['object']['url'].replace('/@', '/users/') @@ -2009,6 +2017,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, languages_understood: [], translate: {}, buy_url: str) -> {}: client_to_server = False @@ -2031,6 +2040,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, languages_understood, translate, buy_url) blog['object']['type'] = 'Article' return blog @@ -2047,6 +2057,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, languages_understood: [], translate: {}) -> {}: """Question post with multiple choice options """ @@ -2066,6 +2077,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, languages_understood, translate, buy_url) message_json['object']['type'] = 'Question' message_json['object']['oneOf'] = [] @@ -2101,6 +2113,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, languages_understood: [], translate: {}, buy_url: str) -> {}: """Unlisted post. This has the #Public and followers links inverted. @@ -2121,8 +2134,8 @@ 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, + languages_understood, translate, buy_url) def create_followers_only_post(base_dir: str, @@ -2140,6 +2153,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, languages_understood: [], translate: {}, buy_url: str) -> {}: """Followers only post @@ -2158,8 +2172,8 @@ 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, + languages_understood, translate, buy_url) def get_mentioned_people(base_dir: str, http_prefix: str, @@ -2215,6 +2229,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, languages_understood: [], dm_is_chat: bool, translate: {}, buy_url: str) -> {}: @@ -2242,8 +2257,8 @@ 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, + 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 +2282,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, languages_understood: [], translate: {}) -> {}: """Send a report to moderators """ @@ -2346,6 +2362,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, languages_understood, translate, buy_url) if not post_json_object: continue @@ -2471,6 +2488,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, 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 +2556,8 @@ 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, + languages_understood, translate, buy_url) # get the senders private key @@ -2635,6 +2654,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, event_date: str, event_time: str, event_end_time: str, location: str, translate: {}, buy_url: str, debug: bool = False, @@ -2727,7 +2747,8 @@ 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, + languages_understood, translate, buy_url) auth_header = create_basic_auth_header(from_nickname, password) diff --git a/tests.py b/tests.py index ecabfaed1..c7509994c 100644 --- a/tests.py +++ b/tests.py @@ -774,6 +774,7 @@ 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' buy_url = '' create_public_post(path, nickname, domain, port, http_prefix, "No wise fish would go anywhere without a porpoise", @@ -789,6 +790,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, languages_understood, translate, buy_url) create_public_post(path, nickname, domain, port, http_prefix, "Curiouser and curiouser!", @@ -804,6 +806,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, languages_understood, translate, buy_url) create_public_post(path, nickname, domain, port, http_prefix, "In the gardens of memory, in the palace " + @@ -820,6 +823,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, languages_understood, translate, buy_url) regenerate_index_for_box(path, nickname, domain, 'outbox') global TEST_SERVER_ALICE_RUNNING @@ -938,6 +942,7 @@ 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' translate = {} buy_url = '' create_public_post(path, nickname, domain, port, http_prefix, @@ -954,6 +959,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, 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 +976,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, 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 +992,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, languages_understood, translate, buy_url) regenerate_index_for_box(path, nickname, domain, 'outbox') global TEST_SERVER_BOB_RUNNING @@ -1235,6 +1243,7 @@ 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' if os.path.isdir(base_dir + '/.tests'): shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None) @@ -1339,7 +1348,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, + translate, buy_url, in_reply_to, in_reply_to_atom_uri, subject) print('send_result: ' + str(send_result)) @@ -1568,6 +1578,7 @@ 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' if os.path.isdir(base_dir + '/.tests'): shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None) @@ -1712,7 +1723,7 @@ 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, translate, buy_url, in_reply_to, in_reply_to_atom_uri, subject) print('send_result: ' + str(send_result)) @@ -1763,6 +1774,7 @@ 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' if os.path.isdir(base_dir + '/.tests'): shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None) @@ -2080,7 +2092,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, + translate, buy_url, True, in_reply_to, in_reply_to_atom_uri, subject) print('send_result: ' + str(send_result)) @@ -2186,6 +2199,7 @@ 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' if os.path.isdir(base_dir + '/.tests'): shutil.rmtree(base_dir + '/.tests', ignore_errors=False, onerror=None) @@ -2511,7 +2525,7 @@ 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, translate, buy_url, in_reply_to, in_reply_to_atom_uri, subject) print('send_result: ' + str(send_result)) @@ -2881,6 +2895,7 @@ 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' content = \ "If your \"independent organization\" is government funded...\n\n" + \ "(yawn)\n\n...then it's not really independent.\n\n" + \ @@ -2899,6 +2914,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, languages_understood, translate, buy_url) assert test_post_json assert test_post_json.get('object') @@ -2925,6 +2941,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, languages_understood, translate, buy_url) assert test_post_json assert test_post_json.get('object') @@ -3005,6 +3022,7 @@ 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' TEST_SERVER_ALICE_RUNNING = False TEST_SERVER_BOB_RUNNING = False @@ -3138,6 +3156,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, event_date, event_time, event_end_time, location, translate, buy_url, True, None, None, conversation_id, None) @@ -4738,6 +4757,7 @@ 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' translate = {} buy_url = '' reply = \ @@ -4752,6 +4772,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, languages_understood, translate, buy_url) # print(str(reply)) expected_str = \ @@ -5689,6 +5710,7 @@ 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' translate = {} buy_url = '' @@ -5704,6 +5726,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, languages_understood, translate, buy_url) expected_str = \ @@ -5748,6 +5771,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, languages_understood, translate, buy_url) assert post_json_object['object']['content'] == content assert post_json_object['object']['contentMap'][system_language] == content @@ -6799,6 +6823,7 @@ 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' translate = {} buy_url = '' @@ -6814,6 +6839,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, languages_understood, translate, buy_url) # set the date on the post curr_date_str = "2021-09-08T20:45:00Z" From 56f1c276cba33f45d7f6f6be975c3741233444e1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 09:52:06 +0000 Subject: [PATCH 04/14] Convert license names to links --- daemon.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/daemon.py b/daemon.py index 4150924a9..49a9479fc 100644 --- a/daemon.py +++ b/daemon.py @@ -20799,6 +20799,9 @@ class PubServer(BaseHTTPRequestHandler): 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) message_json = \ create_public_post(self.server.base_dir, nickname, @@ -20944,6 +20947,9 @@ class PubServer(BaseHTTPRequestHandler): 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) message_json = \ create_blog_post(self.server.base_dir, nickname, self.server.domain, self.server.port, @@ -21055,6 +21061,9 @@ class PubServer(BaseHTTPRequestHandler): 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) post_json_object['object'] = \ attach_media(self.server.base_dir, self.server.http_prefix, @@ -21113,6 +21122,9 @@ class PubServer(BaseHTTPRequestHandler): 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) message_json = \ create_unlisted_post(self.server.base_dir, nickname, @@ -21226,6 +21238,9 @@ class PubServer(BaseHTTPRequestHandler): 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) message_json = \ create_followers_only_post(self.server.base_dir, nickname, @@ -21350,6 +21365,9 @@ class PubServer(BaseHTTPRequestHandler): 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) message_json = \ create_direct_message_post(self.server.base_dir, nickname, @@ -21476,6 +21494,9 @@ class PubServer(BaseHTTPRequestHandler): 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) message_json = \ create_direct_message_post(self.server.base_dir, nickname, @@ -21586,6 +21607,9 @@ class PubServer(BaseHTTPRequestHandler): 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) message_json = \ create_report_post(self.server.base_dir, nickname, @@ -21640,6 +21664,9 @@ class PubServer(BaseHTTPRequestHandler): 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) message_json = \ create_question_post(self.server.base_dir, nickname, From 858a1f719318cde6252200ae322707d340d8d8b1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 10:39:49 +0000 Subject: [PATCH 05/14] New post fields for media license and creator --- translations/ar.json | 4 +++- translations/bn.json | 4 +++- translations/ca.json | 4 +++- translations/cy.json | 4 +++- translations/de.json | 4 +++- translations/el.json | 4 +++- translations/en.json | 4 +++- translations/es.json | 4 +++- translations/fa.json | 4 +++- translations/fr.json | 4 +++- translations/ga.json | 4 +++- translations/hi.json | 4 +++- translations/it.json | 4 +++- translations/ja.json | 4 +++- translations/ko.json | 4 +++- translations/ku.json | 4 +++- translations/nl.json | 4 +++- translations/oc.json | 4 +++- translations/pl.json | 4 +++- translations/pt.json | 4 +++- translations/ru.json | 4 +++- translations/sw.json | 4 +++- translations/tr.json | 4 +++- translations/uk.json | 4 +++- translations/yi.json | 4 +++- translations/zh.json | 4 +++- webapp_create_post.py | 7 +++++++ 27 files changed, 85 insertions(+), 26 deletions(-) diff --git a/translations/ar.json b/translations/ar.json index d0e871237..570d9b293 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -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": "صانع الوسائط" } diff --git a/translations/bn.json b/translations/bn.json index 75629536b..a57409ba2 100644 --- a/translations/bn.json +++ b/translations/bn.json @@ -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": "মিডিয়া নির্মাতা" } diff --git a/translations/ca.json b/translations/ca.json index 85b5bb3f1..df18f6d9b 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -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" } diff --git a/translations/cy.json b/translations/cy.json index 56dcee7d0..956057202 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -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" } diff --git a/translations/de.json b/translations/de.json index 8126e5514..17f2c2578 100644 --- a/translations/de.json +++ b/translations/de.json @@ -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" } diff --git a/translations/el.json b/translations/el.json index 700da97fa..b75a9fa98 100644 --- a/translations/el.json +++ b/translations/el.json @@ -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": "Δημιουργός πολυμέσων" } diff --git a/translations/en.json b/translations/en.json index 4cfd16b63..32d3ab839 100644 --- a/translations/en.json +++ b/translations/en.json @@ -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" } diff --git a/translations/es.json b/translations/es.json index 484fc52a8..94141790e 100644 --- a/translations/es.json +++ b/translations/es.json @@ -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" } diff --git a/translations/fa.json b/translations/fa.json index 61755dfbe..faf8dd892 100644 --- a/translations/fa.json +++ b/translations/fa.json @@ -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": "سازنده رسانه" } diff --git a/translations/fr.json b/translations/fr.json index cb8020e82..20839a64e 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -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" } diff --git a/translations/ga.json b/translations/ga.json index 9416cc13b..04afa73e7 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -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" } diff --git a/translations/hi.json b/translations/hi.json index 3f1c5fd6e..9af4f702e 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -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": "मीडिया निर्माता" } diff --git a/translations/it.json b/translations/it.json index f9bd2df67..22e062f91 100644 --- a/translations/it.json +++ b/translations/it.json @@ -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" } diff --git a/translations/ja.json b/translations/ja.json index f274f6bcf..4054e0884 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -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": "メディアクリエーター" } diff --git a/translations/ko.json b/translations/ko.json index 71e437519..5fdf0ed48 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -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": "미디어 크리에이터" } diff --git a/translations/ku.json b/translations/ku.json index 29a310e21..5c00f8f7f 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -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ê" } diff --git a/translations/nl.json b/translations/nl.json index d8eb2d268..874a65237 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -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" } diff --git a/translations/oc.json b/translations/oc.json index bad9e02dd..0d074e655 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -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" } diff --git a/translations/pl.json b/translations/pl.json index b85fe67e9..f8a83eb3e 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -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" } diff --git a/translations/pt.json b/translations/pt.json index 9df0cdff5..7ecb23cf8 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -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" } diff --git a/translations/ru.json b/translations/ru.json index bd3f0ce13..f7f18fe56 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -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": "Создатель медиа" } diff --git a/translations/sw.json b/translations/sw.json index 7bbf34f89..a758cc03d 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -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" } diff --git a/translations/tr.json b/translations/tr.json index 1606176b8..fb182a42d 100644 --- a/translations/tr.json +++ b/translations/tr.json @@ -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ı" } diff --git a/translations/uk.json b/translations/uk.json index 590a799a1..248b59826 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -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": "Творець медіа" } diff --git a/translations/yi.json b/translations/yi.json index c3d62bf14..44571dab9 100644 --- a/translations/yi.json +++ b/translations/yi.json @@ -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": "מעדיע באשעפער" } diff --git a/translations/zh.json b/translations/zh.json index d7c5fb673..8a2cc9f86 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -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": "媒体创作者" } diff --git a/webapp_create_post.py b/webapp_create_post.py index e859b9e26..75c0e9428 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -489,6 +489,13 @@ def html_new_post(edit_post_params: {}, ' \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 = '' From d9143403fe8620a93540bbe76c7a5c32723965c1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 11:33:07 +0000 Subject: [PATCH 06/14] Add media creator for attachments --- daemon.py | 44 +++++++++++++++++++++++++++++------ desktop_client.py | 22 ++++++++++-------- epicyon.py | 20 ++++++++-------- inbox.py | 4 ++-- media.py | 8 +++++-- newsdaemon.py | 7 +++--- posts.py | 59 +++++++++++++++++++++++++---------------------- tests.py | 47 +++++++++++++++++++++++-------------- 8 files changed, 134 insertions(+), 77 deletions(-) diff --git a/daemon.py b/daemon.py index 49a9479fc..5202e73e4 100644 --- a/daemon.py +++ b/daemon.py @@ -705,7 +705,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, - self.server.content_license_url, + self.server.content_license_url, '', languages_understood, False, self.server.translate, buy_url) if message_json: @@ -20802,6 +20802,9 @@ class PubServer(BaseHTTPRequestHandler): 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, @@ -20824,7 +20827,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, - media_license_url, + media_license_url, media_creator, languages_understood, self.server.translate, buy_url) if message_json: @@ -20950,6 +20953,9 @@ class PubServer(BaseHTTPRequestHandler): 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, @@ -20971,7 +20977,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, - media_license_url, + media_license_url, media_creator, languages_understood, self.server.translate, buy_url) if message_json: @@ -21064,6 +21070,9 @@ class PubServer(BaseHTTPRequestHandler): 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, @@ -21076,7 +21085,7 @@ class PubServer(BaseHTTPRequestHandler): img_description, city, self.server.low_bandwidth, - license_url) + license_url, creator) replace_you_tube(post_json_object, self.server.yt_replace_domain, @@ -21125,6 +21134,9 @@ class PubServer(BaseHTTPRequestHandler): 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, @@ -21148,7 +21160,7 @@ class PubServer(BaseHTTPRequestHandler): conversation_id, self.server.low_bandwidth, self.server.content_license_url, - media_license_url, + media_license_url, media_creator, languages_understood, self.server.translate, buy_url) if message_json: @@ -21241,6 +21253,9 @@ class PubServer(BaseHTTPRequestHandler): 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, @@ -21267,6 +21282,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.low_bandwidth, self.server.content_license_url, media_license_url, + media_creator, languages_understood, self.server.translate, buy_url) @@ -21368,6 +21384,9 @@ class PubServer(BaseHTTPRequestHandler): 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, @@ -21397,6 +21416,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.low_bandwidth, content_license_url, media_license_url, + media_creator, languages_understood, reply_is_chat, self.server.translate, @@ -21497,6 +21517,9 @@ class PubServer(BaseHTTPRequestHandler): 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, @@ -21522,6 +21545,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.low_bandwidth, self.server.content_license_url, media_license_url, + media_creator, languages_understood, False, self.server.translate, buy_url) @@ -21610,6 +21634,9 @@ class PubServer(BaseHTTPRequestHandler): 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, @@ -21624,7 +21651,7 @@ class PubServer(BaseHTTPRequestHandler): fields['languagesDropdown'], self.server.low_bandwidth, self.server.content_license_url, - media_license_url, + media_license_url, media_creator, languages_understood, self.server.translate) if message_json: @@ -21667,6 +21694,9 @@ class PubServer(BaseHTTPRequestHandler): 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, @@ -21684,7 +21714,7 @@ class PubServer(BaseHTTPRequestHandler): fields['languagesDropdown'], self.server.low_bandwidth, self.server.content_license_url, - media_license_url, + media_license_url, media_creator, languages_understood, self.server.translate) if message_json: diff --git a/desktop_client.py b/desktop_client.py index 653136b82..f78305bd5 100644 --- a/desktop_client.py +++ b/desktop_client.py @@ -480,7 +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_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 @@ -541,7 +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_license_url, media_creator, event_date, event_time, event_end_time, location, translate, buy_url, debug, post_id, post_id, conversation_id, subject) == 0: @@ -560,7 +560,7 @@ def _desktop_new_post(session, languages_understood: [], espeak, low_bandwidth: bool, content_license_url: str, - media_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 @@ -618,7 +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_license_url, media_creator, event_date, event_time, event_end_time, location, translate, buy_url, debug, None, None, conversation_id, subject) == 0: @@ -1228,7 +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_license_url: str, media_creator: str, signing_priv_key_pem: str, translate: {}) -> None: """Use the desktop client to create a new direct message @@ -1254,7 +1254,7 @@ def _desktop_new_dm(session, to_handle: str, languages_understood, espeak, low_bandwidth, content_license_url, - media_license_url, + media_license_url, media_creator, signing_priv_key_pem, translate) @@ -1267,7 +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_license_url: str, media_creator: str, signing_priv_key_pem: str, translate: {}) -> None: """Use the desktop client to create a new direct message @@ -1368,7 +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_license_url, media_creator, event_date, event_time, event_end_time, location, translate, buy_url, debug, None, None, conversation_id, subject) == 0: @@ -1456,6 +1456,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, 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 = [] @@ -1863,6 +1864,7 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str, low_bandwidth, content_license_url, media_license_url, + media_creator, signing_priv_key_pem, translate) refresh_timeline = True @@ -1901,7 +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_license_url, media_creator, signing_priv_key_pem, translate) refresh_timeline = True else: @@ -1915,7 +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_license_url, media_creator, signing_priv_key_pem, translate) refresh_timeline = True print('') diff --git a/epicyon.py b/epicyon.py index 5c30c9055..4594e3ed0 100644 --- a/epicyon.py +++ b/epicyon.py @@ -161,6 +161,8 @@ def _command_options() -> None: 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') @@ -1708,7 +1710,7 @@ def _command_options() -> None: argb.language, languages_understood, argb.low_bandwidth, argb.content_license_url, - argb.media_license_url, + argb.media_license_url, argb.media_creator, argb.eventDate, argb.eventTime, argb.eventEndTime, argb.eventLocation, translate, argb.buyUrl, argb.debug, @@ -3398,7 +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_license_url, argb.media_creator, languages_understood, translate, buy_url) create_public_post(base_dir, nickname, domain, port, http_prefix, "Zoiks!!!", @@ -3413,7 +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_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", @@ -3428,7 +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_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", @@ -3443,7 +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_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" + @@ -3459,7 +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_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!", @@ -3474,7 +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_license_url, argb.media_creator, languages_understood, translate, buy_url) create_public_post(base_dir, nickname, domain, port, http_prefix, "another mystery solved #test", @@ -3489,7 +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_license_url, argb.media_creator, languages_understood, translate, buy_url) create_public_post(base_dir, nickname, domain, port, http_prefix, "let's go bowling", @@ -3504,7 +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_license_url, argb.media_creator, languages_understood, translate, buy_url) domain_full = domain + ':' + str(port) clear_follows(base_dir, nickname, domain) diff --git a/inbox.py b/inbox.py index ea02f57f3..58c55f902 100644 --- a/inbox.py +++ b/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, content_license_url, + low_bandwidth, content_license_url, + content_license_url, '', languages_understood, bounce_is_chat, translate, buy_url) if not post_json_object: diff --git a/media.py b/media.py index 586f77930..fb73af5ac 100644 --- a/media.py +++ b/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,12 +600,15 @@ def attach_media(base_dir: str, http_prefix: str, 'type': 'Document', 'url': http_prefix + '://' + domain + '/' + media_path } - if content_license_url: + 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 diff --git a/newsdaemon.py b/newsdaemon.py index 541e0c1ec..995294b24 100644 --- a/newsdaemon.py +++ b/newsdaemon.py @@ -548,7 +548,8 @@ def _convert_rss_to_activitypub(base_dir: str, http_prefix: str, system_language: str, low_bandwidth: bool, content_license_url: str, - media_license_url: str) -> None: + media_license_url: str, + media_creator: str) -> None: """Converts rss items in a newswire into posts """ if not newswire: @@ -647,7 +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_license_url, media_creator, languages_understood, translate, buy_url) if not blog: @@ -839,7 +840,7 @@ def run_newswire_daemon(base_dir: str, httpd, 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: diff --git a/posts.py b/posts.py index 821e4e843..54fb44d19 100644 --- a/posts.py +++ b/posts.py @@ -1144,7 +1144,7 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int, in_reply_to_atom_uri: str, system_language: str, conversation_id: str, low_bandwidth: bool, content_license_url: str, - media_license_url: str, + media_license_url: str, media_creator: str, buy_url: str, translate: {}) -> {}: """Creates a new server-to-server post """ @@ -1207,7 +1207,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, - media_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 @@ -1224,7 +1224,7 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int, in_reply_to_atom_uri: str, system_language: str, conversation_id: str, low_bandwidth: str, content_license_url: str, media_license_url: str, - buy_url: str, translate: {}) -> {}: + media_creator: str, buy_url: str, translate: {}) -> {}: """Creates a new client-to-server post """ domain_full = get_full_domain(domain, port) @@ -1276,7 +1276,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, - media_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 @@ -1487,7 +1487,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_license_url: str, media_creator: str, languages_understood: [], translate: {}, buy_url: str) -> {}: """Creates a message @@ -1648,7 +1648,7 @@ def _create_post_base(base_dir: str, in_reply_to_atom_uri, system_language, conversation_id, low_bandwidth, content_license_url, media_license_url, - buy_url, translate) + media_creator, buy_url, translate) else: new_post = \ _create_post_c2s(base_dir, nickname, domain, port, @@ -1662,7 +1662,7 @@ def _create_post_base(base_dir: str, in_reply_to_atom_uri, system_language, conversation_id, low_bandwidth, content_license_url, media_license_url, - buy_url, translate) + media_creator, buy_url, translate) _create_post_mentions(cc_url, new_post, to_recipients, tags) @@ -1903,7 +1903,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_license_url: str, media_creator: str, languages_understood: [], translate: {}, buy_url: str) -> {}: """Public post @@ -1939,7 +1939,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_license_url, media_creator, languages_understood, translate, buy_url) @@ -1985,7 +1985,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_license_url: str, media_creator: str, languages_understood: [], translate: {}, buy_url: str) -> {}: blog_json = \ @@ -2000,7 +2000,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_license_url, media_creator, languages_understood, translate, buy_url) blog_json['object']['url'] = \ blog_json['object']['url'].replace('/@', '/users/') @@ -2017,7 +2017,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_license_url: str, media_creator: str, languages_understood: [], translate: {}, buy_url: str) -> {}: client_to_server = False @@ -2040,7 +2040,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_license_url, media_creator, languages_understood, translate, buy_url) blog['object']['type'] = 'Article' return blog @@ -2057,7 +2057,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_license_url: str, media_creator: str, languages_understood: [], translate: {}) -> {}: """Question post with multiple choice options """ @@ -2077,7 +2077,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_license_url, media_creator, languages_understood, translate, buy_url) message_json['object']['type'] = 'Question' message_json['object']['oneOf'] = [] @@ -2113,7 +2113,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_license_url: str, media_creator: str, languages_understood: [], translate: {}, buy_url: str) -> {}: """Unlisted post. This has the #Public and followers links inverted. @@ -2134,7 +2134,8 @@ 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, media_license_url, + content_license_url, + media_license_url, media_creator, languages_understood, translate, buy_url) @@ -2153,7 +2154,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_license_url: str, media_creator: str, languages_understood: [], translate: {}, buy_url: str) -> {}: """Followers only post @@ -2172,7 +2173,8 @@ 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, media_license_url, + content_license_url, + media_license_url, media_creator, languages_understood, translate, buy_url) @@ -2229,7 +2231,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_license_url: str, media_creator: str, languages_understood: [], dm_is_chat: bool, translate: {}, buy_url: str) -> {}: @@ -2257,7 +2259,8 @@ 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, media_license_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'] @@ -2282,7 +2285,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_license_url: str, media_creator: str, languages_understood: [], translate: {}) -> {}: """Send a report to moderators """ @@ -2362,7 +2365,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_license_url, media_creator, languages_understood, translate, buy_url) if not post_json_object: continue @@ -2488,7 +2491,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_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: @@ -2556,7 +2559,8 @@ 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, media_license_url, + content_license_url, + media_license_url, media_creator, languages_understood, translate, buy_url) @@ -2654,7 +2658,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_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, @@ -2747,7 +2751,8 @@ 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, media_license_url, + content_license_url, + media_license_url, media_creator, languages_understood, translate, buy_url) diff --git a/tests.py b/tests.py index c7509994c..2d1446edd 100644 --- a/tests.py +++ b/tests.py @@ -775,6 +775,7 @@ def create_server_alice(path: str, domain: str, port: int, 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", @@ -790,7 +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_license_url, media_creator, languages_understood, translate, buy_url) create_public_post(path, nickname, domain, port, http_prefix, "Curiouser and curiouser!", @@ -806,7 +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_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 " + @@ -823,7 +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_license_url, media_creator, languages_understood, translate, buy_url) regenerate_index_for_box(path, nickname, domain, 'outbox') global TEST_SERVER_ALICE_RUNNING @@ -943,6 +944,7 @@ def create_server_bob(path: str, domain: str, port: int, 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, @@ -959,7 +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_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 " + @@ -976,7 +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_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", @@ -992,7 +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_license_url, media_creator, languages_understood, translate, buy_url) regenerate_index_for_box(path, nickname, domain, 'outbox') global TEST_SERVER_BOB_RUNNING @@ -1244,6 +1246,7 @@ def test_post_message_between_servers(base_dir: str) -> None: 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) @@ -1348,7 +1351,7 @@ 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, media_license_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)) @@ -1579,6 +1582,7 @@ def test_follow_between_servers(base_dir: str) -> 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) @@ -1723,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, media_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)) @@ -1775,6 +1780,7 @@ def test_shared_items_federation(base_dir: str) -> 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) @@ -2092,7 +2098,7 @@ 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, media_license_url, + 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)) @@ -2200,6 +2206,7 @@ def test_group_follow(base_dir: str) -> 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) @@ -2525,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, media_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)) @@ -2896,6 +2904,7 @@ def _test_create_person_account(base_dir: str): 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" + \ @@ -2914,7 +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_license_url, media_creator, languages_understood, translate, buy_url) assert test_post_json assert test_post_json.get('object') @@ -2941,7 +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_license_url, media_creator, languages_understood, translate, buy_url) assert test_post_json assert test_post_json.get('object') @@ -3023,6 +3032,7 @@ def test_client_to_server(base_dir: str): 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 @@ -3156,7 +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_license_url, media_creator, event_date, event_time, event_end_time, location, translate, buy_url, True, None, None, conversation_id, None) @@ -4758,6 +4768,7 @@ def _test_reply_to_public_post(base_dir: str) -> 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 = \ @@ -4772,7 +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_license_url, media_creator, languages_understood, translate, buy_url) # print(str(reply)) expected_str = \ @@ -5711,6 +5722,7 @@ def _test_links_within_post(base_dir: str) -> 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 = '' @@ -5726,7 +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_license_url, media_creator, languages_understood, translate, buy_url) expected_str = \ @@ -5771,7 +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_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 @@ -6824,6 +6836,7 @@ def _test_can_replyto(base_dir: str) -> 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 = '' @@ -6839,7 +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_license_url, media_creator, languages_understood, translate, buy_url) # set the date on the post curr_date_str = "2021-09-08T20:45:00Z" From 6053d3b7252fac5c428abb6b8cfea77b7ec241d1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 14:35:54 +0000 Subject: [PATCH 07/14] Add creator details to images, if available --- webapp_utils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/webapp_utils.py b/webapp_utils.py index 4300c7db0..43f41f96e 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -1233,6 +1233,12 @@ 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'): + media_license = attach['schema:license'] + media_creator = '' + if attach.get('schema:creator'): + media_creator = attach['schema:creator'] media_type = attach['mediaType'] image_description = '' @@ -1337,11 +1343,24 @@ def get_post_attachments_as_html(base_dir: str, '
\n' attachment_str += '' + if media_license or media_creator: + attachment_str += '
' attachment_str += \ '' + image_description + '\n' + if media_license or media_creator: + attachment_str += '
' + license_str = '' + if media_license: + license_str += '©' + if media_creator: + if license_str: + license_str += ' ' + license_str += media_creator + if media_license or media_creator: + attachment_str += license_str + '
' if minimize_images: attachment_str += '
\n' From b93a8b799f43bb378fa7c528f4f734d53f4af642 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 14:45:53 +0000 Subject: [PATCH 08/14] Apply filtering to image creator details --- blog.py | 3 ++- webapp_post.py | 3 ++- webapp_utils.py | 14 +++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/blog.py b/blog.py index a52fb9564..e4ec1af61 100644 --- a/blog.py +++ b/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 += '
' + attachment_str + '
' if json_content: diff --git a/webapp_post.py b/webapp_post.py index fab56f241..65d387ba3 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -2387,7 +2387,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, diff --git a/webapp_utils.py b/webapp_utils.py index 43f41f96e..93d10c4c8 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -30,6 +30,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 +1213,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 = '' @@ -1235,10 +1237,16 @@ def get_post_attachments_as_html(base_dir: str, continue media_license = '' if attach.get('schema:license'): - media_license = attach['schema:license'] + if not is_filtered(base_dir, nickname, domain, + attach['schema:license'], + system_language): + media_license = attach['schema:license'] media_creator = '' if attach.get('schema:creator'): - media_creator = attach['schema:creator'] + if not is_filtered(base_dir, nickname, domain, + attach['schema:creator'], + system_language): + media_creator = attach['schema:creator'] media_type = attach['mediaType'] image_description = '' From aacab099099f7267e931f0ddc4e7315d73cb0ce7 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 14:50:09 +0000 Subject: [PATCH 09/14] Check that the license is a link --- webapp_utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webapp_utils.py b/webapp_utils.py index 93d10c4c8..e5446dc93 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -1362,7 +1362,13 @@ def get_post_attachments_as_html(base_dir: str, attachment_str += '
' license_str = '' if media_license: - license_str += '©' + if '://' in media_license: + license_str += \ + '©' + else: + license_str += media_license if media_creator: if license_str: license_str += ' ' From 997dc511a70e4f8334ba4859ab1ea7e58ea2b56d Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 14:56:17 +0000 Subject: [PATCH 10/14] Support alternative license representation --- posts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/posts.py b/posts.py index 54fb44d19..d2ab8977a 100644 --- a/posts.py +++ b/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: {}, From 7daa8812aa522252f4959f47511dbd3be86ed60e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 15:09:40 +0000 Subject: [PATCH 11/14] Support alternative license representation --- webapp_post.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/webapp_post.py b/webapp_post.py index 65d387ba3..6f332ca61 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -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 From dcb5fcf4c03a2c0606fa1bc8530e80d305009dcb Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 17:11:27 +0000 Subject: [PATCH 12/14] Add license and creator to media timeline images --- webapp_utils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/webapp_utils.py b/webapp_utils.py index e5446dc93..fe68816a0 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -1284,11 +1284,30 @@ def get_post_attachments_as_html(base_dir: str, gallery_str += '
\n' if post_json_object['object'].get('url'): image_post_url = post_json_object['object']['url'] else: From f0354a101a7d9b7116a14321eabaac322142c0dd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 17:15:19 +0000 Subject: [PATCH 13/14] Ensure that license and creator text is not too long --- webapp_utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webapp_utils.py b/webapp_utils.py index fe68816a0..fdea01ef0 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -1240,13 +1240,18 @@ def get_post_attachments_as_html(base_dir: str, if not is_filtered(base_dir, nickname, domain, attach['schema:license'], system_language): - media_license = attach['schema:license'] + 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 not is_filtered(base_dir, nickname, domain, attach['schema:creator'], system_language): - media_creator = attach['schema:creator'] + if len(attach['schema:creator']) < 60: + media_creator = attach['schema:creator'] media_type = attach['mediaType'] image_description = '' From f6d44107d35e4ccbea67617d707bbd01f4df1615 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 23 Jan 2023 17:54:18 +0000 Subject: [PATCH 14/14] Check for dangerous markup within image license and creator --- webapp_utils.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/webapp_utils.py b/webapp_utils.py index fdea01ef0..e3548ad25 100644 --- a/webapp_utils.py +++ b/webapp_utils.py @@ -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 @@ -1237,21 +1238,23 @@ def get_post_attachments_as_html(base_dir: str, continue media_license = '' if attach.get('schema:license'): - 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: + 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'] - else: - media_license = attach['schema:license'] media_creator = '' if attach.get('schema:creator'): - if not is_filtered(base_dir, nickname, domain, - attach['schema:creator'], - system_language): - if len(attach['schema:creator']) < 60: - media_creator = attach['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 = ''