mirror of https://gitlab.com/bashrc2/epicyon
Merge branch 'main' of gitlab.com:bashrc2/epicyon
commit
adae2a8b19
60
inbox.py
60
inbox.py
|
@ -18,6 +18,7 @@ from languages import understood_post_language
|
||||||
from like import update_likes_collection
|
from like import update_likes_collection
|
||||||
from reaction import update_reaction_collection
|
from reaction import update_reaction_collection
|
||||||
from reaction import valid_emoji_content
|
from reaction import valid_emoji_content
|
||||||
|
from utils import is_account_dir
|
||||||
from utils import remove_eol
|
from utils import remove_eol
|
||||||
from utils import text_in_file
|
from utils import text_in_file
|
||||||
from utils import get_media_descriptions_from_post
|
from utils import get_media_descriptions_from_post
|
||||||
|
@ -131,6 +132,7 @@ from notifyOnPost import notify_when_person_posts
|
||||||
from conversation import update_conversation
|
from conversation import update_conversation
|
||||||
from webapp_hashtagswarm import html_hash_tag_swarm
|
from webapp_hashtagswarm import html_hash_tag_swarm
|
||||||
from person import valid_sending_actor
|
from person import valid_sending_actor
|
||||||
|
from person import get_person_avatar_url
|
||||||
from fitnessFunctions import fitness_performance
|
from fitnessFunctions import fitness_performance
|
||||||
from content import reject_twitter_summary
|
from content import reject_twitter_summary
|
||||||
from content import load_dogwhistles
|
from content import load_dogwhistles
|
||||||
|
@ -1020,12 +1022,57 @@ def _receive_undo(base_dir: str, message_json: {}, debug: bool,
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _notify_moved(base_dir: str, domain_full: str,
|
||||||
|
prev_actor_handle: str, new_actor_handle: str,
|
||||||
|
prev_actor: str, prev_avatar_image_url: str,
|
||||||
|
http_prefix: str) -> None:
|
||||||
|
"""Notify that an actor has moved
|
||||||
|
"""
|
||||||
|
for _, dirs, _ in os.walk(base_dir + '/accounts'):
|
||||||
|
for account in dirs:
|
||||||
|
if not is_account_dir(account):
|
||||||
|
continue
|
||||||
|
account_dir = base_dir + '/accounts/' + account
|
||||||
|
following_filename = account_dir + '/following.txt'
|
||||||
|
if not os.path.isfile(following_filename):
|
||||||
|
continue
|
||||||
|
if not text_in_file(prev_actor_handle + '\n', following_filename):
|
||||||
|
continue
|
||||||
|
if text_in_file(new_actor_handle + '\n', following_filename):
|
||||||
|
continue
|
||||||
|
# notify
|
||||||
|
moved_file = account_dir + '/.newMoved'
|
||||||
|
if os.path.isfile(moved_file):
|
||||||
|
if not text_in_file('##sent##', moved_file):
|
||||||
|
continue
|
||||||
|
|
||||||
|
nickname = account.split('@')[0]
|
||||||
|
url = \
|
||||||
|
http_prefix + '://' + domain_full + '/users/' + nickname + \
|
||||||
|
'?options=' + prev_actor + ';1;' + prev_avatar_image_url
|
||||||
|
moved_str = \
|
||||||
|
prev_actor_handle + ' ' + new_actor_handle + ' ' + url
|
||||||
|
|
||||||
|
if os.path.isfile(moved_file):
|
||||||
|
with open(moved_file, 'r',
|
||||||
|
encoding='utf-8') as fp_move:
|
||||||
|
prev_moved_str = fp_move.read()
|
||||||
|
if prev_moved_str == moved_str:
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
with open(moved_file, 'w+', encoding='utf-8') as fp_move:
|
||||||
|
fp_move.write(moved_str)
|
||||||
|
except OSError:
|
||||||
|
print('EX: ERROR: unable to save moved notification ' +
|
||||||
|
moved_file)
|
||||||
|
|
||||||
|
|
||||||
def _person_receive_update(base_dir: str,
|
def _person_receive_update(base_dir: str,
|
||||||
domain: str, port: int,
|
domain: str, port: int,
|
||||||
update_nickname: str, update_domain: str,
|
update_nickname: str, update_domain: str,
|
||||||
update_port: int,
|
update_port: int,
|
||||||
person_json: {}, person_cache: {},
|
person_json: {}, person_cache: {},
|
||||||
debug: bool) -> bool:
|
debug: bool, http_prefix: str) -> bool:
|
||||||
"""Changes an actor. eg: avatar or display name change
|
"""Changes an actor. eg: avatar or display name change
|
||||||
"""
|
"""
|
||||||
if debug:
|
if debug:
|
||||||
|
@ -1120,6 +1167,15 @@ def _person_receive_update(base_dir: str,
|
||||||
except OSError:
|
except OSError:
|
||||||
print('EX: unable to write to ' +
|
print('EX: unable to write to ' +
|
||||||
refollow_filename)
|
refollow_filename)
|
||||||
|
prev_avatar_url = \
|
||||||
|
get_person_avatar_url(base_dir, person_json['id'],
|
||||||
|
person_cache)
|
||||||
|
if prev_avatar_url is None:
|
||||||
|
prev_avatar_url = ''
|
||||||
|
_notify_moved(base_dir, domain_full,
|
||||||
|
prev_nickname + '@' + prev_domain_full,
|
||||||
|
new_nickname + '@' + new_domain_full,
|
||||||
|
person_json['id'], prev_avatar_url, http_prefix)
|
||||||
|
|
||||||
# remove avatar if it exists so that it will be refreshed later
|
# remove avatar if it exists so that it will be refreshed later
|
||||||
# when a timeline is constructed
|
# when a timeline is constructed
|
||||||
|
@ -1406,7 +1462,7 @@ def _receive_update_activity(recent_posts_cache: {}, session, base_dir: str,
|
||||||
update_nickname, update_domain,
|
update_nickname, update_domain,
|
||||||
update_port,
|
update_port,
|
||||||
message_json['object'],
|
message_json['object'],
|
||||||
person_cache, debug):
|
person_cache, debug, http_prefix):
|
||||||
print('Person Update: ' + str(message_json))
|
print('Person Update: ' + str(message_json))
|
||||||
if debug:
|
if debug:
|
||||||
print('DEBUG: Profile update was received for ' +
|
print('DEBUG: Profile update was received for ' +
|
||||||
|
|
|
@ -259,6 +259,25 @@ function notifications {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# send notifications for moved accounts to XMPP/email users
|
||||||
|
epicyonMovedFile="$epicyonDir/.newMoved"
|
||||||
|
if [ -f "$epicyonMovedFile" ]; then
|
||||||
|
if ! grep -q "##sent##" "$epicyonMovedFile"; then
|
||||||
|
epicyonMovedMessage=$(notification_translate_text 'has moved to')
|
||||||
|
epicyonMovedFrom=$(cat "$epicyonMovedFile" | awk -F ' ' '{print $1}')
|
||||||
|
epicyonMovedTo=$(cat "$epicyonMovedFile" | awk -F ' ' '{print $2}')
|
||||||
|
epicyonMovedUrl=$(cat "$epicyonMovedFile" | awk -F ' ' '{print $3}')
|
||||||
|
epicyonMovedLink="<a href=\"${epicyonMovedUrl}\">${epicyonMovedTo}</a>"
|
||||||
|
epicyonMovedFileContent=$("$(echo "$epicyonMovedFrom")" "$(echo "$epicyonMovedMessage")" "$(echo "$epicyonMovedLink")")
|
||||||
|
if [[ "$epicyonMovedFileContent" == *':'* ]]; then
|
||||||
|
epicyonMovedMessage="Epicyon: $epicyonMovedFileContent"
|
||||||
|
fi
|
||||||
|
sendNotification "$USERNAME" "Epicyon" "$epicyonMovedMessage"
|
||||||
|
echo "##sent##" > "$epicyonMovedFile"
|
||||||
|
chown ${PROJECT_NAME}:${PROJECT_NAME} "$epicyonMovedFile"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# send notifications for emoji reactions to XMPP/email users
|
# send notifications for emoji reactions to XMPP/email users
|
||||||
epicyonReactionFile="$epicyonDir/.newReaction"
|
epicyonReactionFile="$epicyonDir/.newReaction"
|
||||||
if [ -f "$epicyonReactionFile" ]; then
|
if [ -f "$epicyonReactionFile" ]; then
|
||||||
|
|
3
tests.py
3
tests.py
|
@ -5848,7 +5848,8 @@ def _test_markdown_to_html():
|
||||||
assert markdown_to_html(markdown) == 'This is <b>just</b> plain text'
|
assert markdown_to_html(markdown) == 'This is <b>just</b> plain text'
|
||||||
|
|
||||||
markdown = '# Title1\n### Title3\n## Title2\n'
|
markdown = '# Title1\n### Title3\n## Title2\n'
|
||||||
expected = '<h1>Title1</h1>\n<h3>Title3</h3>\n<h2>Title2</h2>\n'
|
expected = '<h1 id="title1">Title1</h1>\n' + \
|
||||||
|
'<h3 id="title3">Title3</h3>\n<h2 id="title2">Title2</h2>\n'
|
||||||
result = markdown_to_html(markdown)
|
result = markdown_to_html(markdown)
|
||||||
if result != expected:
|
if result != expected:
|
||||||
print(result)
|
print(result)
|
||||||
|
|
Loading…
Reference in New Issue