mirror of https://gitlab.com/bashrc2/epicyon
Add support for peertube channel within profile
parent
723759066a
commit
72518caa38
|
@ -83,6 +83,8 @@ from pronouns import get_pronouns
|
|||
from pronouns import set_pronouns
|
||||
from youtube import get_youtube
|
||||
from youtube import set_youtube
|
||||
from peertube import get_peertube
|
||||
from peertube import set_peertube
|
||||
from xmpp import get_xmpp_address
|
||||
from xmpp import set_xmpp_address
|
||||
from matrix import get_matrix_address
|
||||
|
@ -2001,6 +2003,23 @@ def _profile_post_youtube(actor_json: {}, fields: {},
|
|||
return actor_changed
|
||||
|
||||
|
||||
def _profile_post_peertube(actor_json: {}, fields: {},
|
||||
actor_changed: bool) -> bool:
|
||||
""" HTTP POST change peertube channel address
|
||||
"""
|
||||
current_peertube = get_peertube(actor_json)
|
||||
if fields.get('peertubeChannel'):
|
||||
if fields['peertubeChannel'] != current_peertube:
|
||||
set_youtube(actor_json,
|
||||
fields['peertubeChannel'])
|
||||
actor_changed = True
|
||||
else:
|
||||
if current_peertube:
|
||||
set_peertube(actor_json, '')
|
||||
actor_changed = True
|
||||
return actor_changed
|
||||
|
||||
|
||||
def _profile_post_pronouns(actor_json: {}, fields: {},
|
||||
actor_changed: bool) -> bool:
|
||||
""" HTTP POST change pronouns
|
||||
|
@ -2872,6 +2891,10 @@ def profile_edit(self, calling_domain: str, cookie: str,
|
|||
_profile_post_youtube(actor_json, fields,
|
||||
actor_changed)
|
||||
|
||||
actor_changed = \
|
||||
_profile_post_peertube(actor_json, fields,
|
||||
actor_changed)
|
||||
|
||||
actor_changed = \
|
||||
_profile_post_pronouns(actor_json, fields,
|
||||
actor_changed)
|
||||
|
|
|
@ -46,6 +46,7 @@ from donate import get_website
|
|||
from donate import get_gemini_link
|
||||
from pronouns import get_pronouns
|
||||
from youtube import get_youtube
|
||||
from peertube import get_peertube
|
||||
from xmpp import get_xmpp_address
|
||||
from matrix import get_matrix_address
|
||||
from ssb import get_ssb_address
|
||||
|
@ -658,6 +659,7 @@ def show_person_options(self, calling_domain: str, path: str,
|
|||
pgp_fingerprint = None
|
||||
pronouns = None
|
||||
youtube = None
|
||||
peertube = None
|
||||
xmpp_address = None
|
||||
matrix_address = None
|
||||
blog_address = None
|
||||
|
@ -688,6 +690,7 @@ def show_person_options(self, calling_domain: str, path: str,
|
|||
gemini_link = get_gemini_link(actor_json)
|
||||
pronouns = get_pronouns(actor_json)
|
||||
youtube = get_youtube(actor_json)
|
||||
peertube = get_peertube(actor_json)
|
||||
xmpp_address = get_xmpp_address(actor_json)
|
||||
matrix_address = get_matrix_address(actor_json)
|
||||
ssb_address = get_ssb_address(actor_json)
|
||||
|
@ -761,7 +764,7 @@ def show_person_options(self, calling_domain: str, path: str,
|
|||
self.server.blocked_cache,
|
||||
repo_url,
|
||||
self.server.sites_unavailable,
|
||||
youtube)
|
||||
youtube, peertube)
|
||||
if msg:
|
||||
msg = msg.encode('utf-8')
|
||||
msglen = len(msg)
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
__filename__ = "peertube.py"
|
||||
__author__ = "Bob Mottram"
|
||||
__license__ = "AGPL3+"
|
||||
__version__ = "1.5.0"
|
||||
__maintainer__ = "Bob Mottram"
|
||||
__email__ = "bob@libreserver.org"
|
||||
__status__ = "Production"
|
||||
__module_group__ = "Profile Metadata"
|
||||
|
||||
|
||||
from utils import get_attachment_property_value
|
||||
from utils import remove_html
|
||||
from utils import string_contains
|
||||
|
||||
peertube_fieldnames = ['peertube']
|
||||
|
||||
|
||||
def get_peertube(actor_json: {}) -> str:
|
||||
"""Returns peertube for the given actor
|
||||
"""
|
||||
if not actor_json.get('attachment'):
|
||||
return ''
|
||||
if not isinstance(actor_json['attachment'], list):
|
||||
return ''
|
||||
for property_value in actor_json['attachment']:
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not string_contains(name_value, peertube_fieldnames):
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
continue
|
||||
prop_value_name, _ = \
|
||||
get_attachment_property_value(property_value)
|
||||
if not prop_value_name:
|
||||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
peertube_text = property_value[prop_value_name]
|
||||
return remove_html(peertube_text)
|
||||
return ''
|
||||
|
||||
|
||||
def set_peertube(actor_json: {}, peertube: str) -> None:
|
||||
"""Sets peertube for the given actor
|
||||
"""
|
||||
if not actor_json.get('attachment'):
|
||||
actor_json['attachment'] = []
|
||||
|
||||
# remove any existing value
|
||||
property_found = None
|
||||
for property_value in actor_json['attachment']:
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name'].lower()
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name'].lower()
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
continue
|
||||
if not string_contains(name_value, peertube_fieldnames):
|
||||
continue
|
||||
property_found = property_value
|
||||
break
|
||||
|
||||
if property_found:
|
||||
actor_json['attachment'].remove(property_found)
|
||||
|
||||
for property_value in actor_json['attachment']:
|
||||
name_value = None
|
||||
if property_value.get('name'):
|
||||
name_value = property_value['name']
|
||||
elif property_value.get('schema:name'):
|
||||
name_value = property_value['schema:name']
|
||||
if not name_value:
|
||||
continue
|
||||
if not property_value.get('type'):
|
||||
continue
|
||||
name_value = name_value.lower()
|
||||
if not string_contains(name_value, peertube_fieldnames):
|
||||
continue
|
||||
if not property_value['type'].endswith('PropertyValue'):
|
||||
continue
|
||||
prop_value_name, _ = \
|
||||
get_attachment_property_value(property_value)
|
||||
if not prop_value_name:
|
||||
continue
|
||||
property_value[prop_value_name] = remove_html(peertube)
|
||||
return
|
||||
|
||||
new_peertube = {
|
||||
"type": "PropertyValue",
|
||||
"name": "Peertube",
|
||||
"value": remove_html(peertube)
|
||||
}
|
||||
actor_json['attachment'].append(new_peertube)
|
9
pgp.py
9
pgp.py
|
@ -28,6 +28,7 @@ from auth import create_basic_auth_header
|
|||
from session import post_json
|
||||
from pronouns import get_pronouns
|
||||
from youtube import get_youtube
|
||||
from peertube import get_peertube
|
||||
from xmpp import get_xmpp_address
|
||||
from matrix import get_matrix_address
|
||||
from briar import get_briar_address
|
||||
|
@ -745,6 +746,9 @@ def actor_to_vcard(actor: {}, domain: str) -> str:
|
|||
youtube = get_youtube(actor)
|
||||
if youtube:
|
||||
vcard_str += 'SOCIALPROFILE;SERVICE-TYPE=YouTube:' + youtube + '\n'
|
||||
peertube = get_peertube(actor)
|
||||
if peertube:
|
||||
vcard_str += 'SOCIALPROFILE;SERVICE-TYPE=PeerTube:' + peertube + '\n'
|
||||
xmpp_address = get_xmpp_address(actor)
|
||||
if xmpp_address:
|
||||
vcard_str += 'IMPP:xmpp:' + xmpp_address + '\n'
|
||||
|
@ -822,6 +826,11 @@ def actor_to_vcard_xml(actor: {}, domain: str) -> str:
|
|||
vcard_str += ' <url>' + \
|
||||
'<parameters><type><text>youtube</text></type></parameters>' + \
|
||||
'<uri>' + youtube + '</uri></url>\n'
|
||||
peertube = get_peertube(actor)
|
||||
if peertube:
|
||||
vcard_str += ' <url>' + \
|
||||
'<parameters><type><text>peertube</text></type></parameters>' + \
|
||||
'<uri>' + peertube + '</uri></url>\n'
|
||||
xmpp_address = get_xmpp_address(actor)
|
||||
if xmpp_address:
|
||||
vcard_str += ' <impp>' + \
|
||||
|
|
|
@ -171,7 +171,7 @@ def html_person_options(default_timeline: str,
|
|||
blocked_cache: [],
|
||||
repo_url: str,
|
||||
sites_unavailable: [],
|
||||
youtube: str) -> str:
|
||||
youtube: str, peertube: str) -> str:
|
||||
"""Show options for a person: view/follow/block/report
|
||||
"""
|
||||
options_link_str = ''
|
||||
|
@ -442,6 +442,11 @@ def html_person_options(default_timeline: str,
|
|||
' <p class="imText">YouTube' + \
|
||||
': <a href="' + remove_html(youtube) + '">' + \
|
||||
youtube + '</a></p>\n'
|
||||
if peertube:
|
||||
options_str += \
|
||||
' <p class="imText">PeerTube' + \
|
||||
': <a href="' + remove_html(peertube) + '">' + \
|
||||
peertube + '</a></p>\n'
|
||||
if tox_address:
|
||||
options_str += \
|
||||
' <p class="imText">Tox: ' + remove_html(tox_address) + '</p>\n'
|
||||
|
|
|
@ -68,6 +68,7 @@ from donate import get_website
|
|||
from donate import get_gemini_link
|
||||
from pronouns import get_pronouns
|
||||
from youtube import get_youtube
|
||||
from peertube import get_peertube
|
||||
from xmpp import get_xmpp_address
|
||||
from matrix import get_matrix_address
|
||||
from ssb import get_ssb_address
|
||||
|
@ -1097,6 +1098,7 @@ def html_profile(signing_priv_key_pem: str,
|
|||
email_address = get_email_address(profile_json)
|
||||
pronouns = get_pronouns(profile_json)
|
||||
youtube = get_youtube(profile_json)
|
||||
peertube = get_peertube(profile_json)
|
||||
xmpp_address = get_xmpp_address(profile_json)
|
||||
matrix_address = get_matrix_address(profile_json)
|
||||
ssb_address = get_ssb_address(profile_json)
|
||||
|
@ -2721,7 +2723,8 @@ def _html_edit_profile_contact_info(email_address: str,
|
|||
briar_address: str,
|
||||
cwtch_address: str,
|
||||
translate: {},
|
||||
youtube: str) -> str:
|
||||
youtube: str,
|
||||
peertube: str) -> str:
|
||||
"""Contact Information section of edit profile screen
|
||||
"""
|
||||
edit_profile_form = begin_edit_section(translate['Contact Details'])
|
||||
|
@ -2739,6 +2742,8 @@ def _html_edit_profile_contact_info(email_address: str,
|
|||
cwtch_address)
|
||||
edit_profile_form += edit_text_field('YouTube', 'youtubeChannel',
|
||||
youtube)
|
||||
edit_profile_form += edit_text_field('PeerTube', 'peertubeChannel',
|
||||
youtube)
|
||||
edit_profile_form += end_edit_section()
|
||||
return edit_profile_form
|
||||
|
||||
|
@ -3184,8 +3189,8 @@ def html_edit_profile(server, translate: {},
|
|||
blogs_instance_str = news_instance_str = moved_to = twitter_str = ''
|
||||
bio_str = donate_url = website_url = gemini_link = ''
|
||||
email_address = featured_hashtags = pgp_pub_key = enigma_pub_key = ''
|
||||
pgp_fingerprint = pronouns = youtube = xmpp_address = matrix_address = ''
|
||||
ssb_address = blog_address = tox_address = ''
|
||||
pgp_fingerprint = pronouns = peertube = youtube = xmpp_address = ''
|
||||
ssb_address = blog_address = matrix_address = tox_address = ''
|
||||
cwtch_address = briar_address = ''
|
||||
manually_approves_followers = reject_spam_actors = ''
|
||||
|
||||
|
@ -3199,6 +3204,7 @@ def html_edit_profile(server, translate: {},
|
|||
gemini_link = get_gemini_link(actor_json)
|
||||
pronouns = get_pronouns(actor_json)
|
||||
youtube = get_youtube(actor_json)
|
||||
peertube = get_peertube(actor_json)
|
||||
xmpp_address = get_xmpp_address(actor_json)
|
||||
matrix_address = get_matrix_address(actor_json)
|
||||
ssb_address = get_ssb_address(actor_json)
|
||||
|
@ -3418,7 +3424,7 @@ def html_edit_profile(server, translate: {},
|
|||
ssb_address, tox_address,
|
||||
briar_address,
|
||||
cwtch_address, translate,
|
||||
youtube)
|
||||
youtube, peertube)
|
||||
|
||||
# notification settings
|
||||
edit_profile_form += \
|
||||
|
|
Loading…
Reference in New Issue