main
Bob Mottram 2023-12-20 18:22:28 +00:00
parent 4c1eccc628
commit 369a9f311f
4 changed files with 31 additions and 30 deletions

View File

@ -11,7 +11,6 @@ import os
import time
import random
from utils import get_full_domain
from utils import acct_dir
from utils import is_account_dir
from utils import get_nickname_from_actor
from utils import get_domain_from_actor
@ -20,6 +19,7 @@ from follow import send_follow_request
from session import create_session
from session import set_session_for_sender
from threads import begin_thread
from person import set_person_notes
def _establish_import_session(httpd,
@ -89,16 +89,8 @@ def _update_import_following(base_dir: str,
get_full_domain(following_domain, following_port)
if notes:
notes = notes.replace('<br>', '\n')
person_notes_filename = \
acct_dir(base_dir, nickname, domain) + \
'/notes/' + following_handle + '.txt'
try:
with open(person_notes_filename, 'w+',
encoding='utf-8') as fp_notes:
fp_notes.write(notes)
except OSError:
print('EX: Unable to import notes for ' +
following_handle)
set_person_notes(base_dir, nickname, domain,
following_handle, notes)
if is_following_actor(base_dir, nickname, domain,
following_handle_full):
# remove the followed handle from the import list

View File

@ -1600,6 +1600,21 @@ def set_person_notes(base_dir: str, nickname: str, domain: str,
return True
def get_person_notes(base_dir: str, nickname: str, domain: str,
handle: str) -> str:
"""Returns notes about a person
"""
person_notes = ''
person_notes_filename = \
acct_dir(base_dir, nickname, domain) + \
'/notes/' + handle + '.txt'
if os.path.isfile(person_notes_filename):
with open(person_notes_filename, 'r',
encoding='utf-8') as fp_notes:
person_notes = fp_notes.read()
return person_notes
def _detect_users_path(url: str) -> str:
"""Tries to detect the /users/ path
"""

View File

@ -27,6 +27,7 @@ from follow import is_follower_of_person
from follow import is_following_actor
from followingCalendar import receiving_calendar_events
from notifyOnPost import notify_when_person_posts
from person import get_person_notes
from webapp_utils import html_header_with_external_style
from webapp_utils import html_footer
from webapp_utils import get_broken_link_substitute
@ -628,13 +629,8 @@ def html_person_options(default_timeline: str,
person_notes = ''
if origin_path_str == '/users/' + nickname:
person_notes_filename = \
acct_dir(base_dir, nickname, domain) + \
'/notes/' + handle + '.txt'
if os.path.isfile(person_notes_filename):
with open(person_notes_filename, 'r',
encoding='utf-8') as fp_notes:
person_notes = fp_notes.read()
person_notes = \
get_person_notes(base_dir, nickname, domain, handle)
options_str += \
' <br><br>' + translate['Notes'] + ': \n'

View File

@ -43,6 +43,7 @@ from cache import store_person_in_cache
from content import add_html_tags
from content import replace_emoji_from_tags
from person import get_person_avatar_url
from person import get_person_notes
from posts import is_moderator
from blocking import is_blocked
from blocking import allowed_announce
@ -137,18 +138,15 @@ def csv_following_list(following_filename: str,
following_domain)
notify_on_new = 'false'
languages = ''
person_notes = ''
person_notes_filename = \
acct_dir(base_dir, nickname, domain) + \
'/notes/' + following_address + '.txt'
if os.path.isfile(person_notes_filename):
with open(person_notes_filename, 'r',
encoding='utf-8') as fp_notes:
person_notes = fp_notes.read()
person_notes = person_notes.replace(',', ' ')
person_notes = person_notes.replace('"', "'")
person_notes = person_notes.replace('\n', '<br>')
person_notes = person_notes.replace(' ', ' ')
person_notes = \
get_person_notes(base_dir, nickname, domain,
following_address)
if person_notes:
# make notes suitable for csv file
person_notes = person_notes.replace(',', ' ')
person_notes = person_notes.replace('"', "'")
person_notes = person_notes.replace('\n', '<br>')
person_notes = person_notes.replace(' ', ' ')
if not following_list_csv:
following_list_csv = \
'Account address,Show boosts,' + \