Include notes in csv export

merge-requests/30/head
Bob Mottram 2022-11-07 18:00:06 +00:00
parent 874357c87f
commit a6d90d0ae6
2 changed files with 20 additions and 5 deletions

View File

@ -16518,7 +16518,10 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html', msglen, calling_domain)
self._write(msg.encode('utf-8'))
elif csv_getreq:
msg = csv_following_list(following_filename)
msg = csv_following_list(following_filename,
self.server.base_dir,
nickname,
self.server.domain)
msglen = len(msg)
self._login_headers('text/csv', msglen, calling_domain)
self._write(msg.encode('utf-8'))
@ -16553,7 +16556,10 @@ class PubServer(BaseHTTPRequestHandler):
self._login_headers('text/html', msglen, calling_domain)
self._write(msg.encode('utf-8'))
elif csv_getreq:
msg = csv_following_list(followers_filename)
msg = csv_following_list(followers_filename,
self.server.base_dir,
nickname,
self.server.domain)
msglen = len(msg)
self._login_headers('text/csv', msglen, calling_domain)
self._write(msg.encode('utf-8'))

View File

@ -99,7 +99,8 @@ def html_following_list(base_dir: str, following_filename: str) -> str:
return ''
def csv_following_list(following_filename: str) -> str:
def csv_following_list(following_filename: str,
base_dir: str, nickname: str, domain: str) -> str:
"""Returns a csv of handles being followed
"""
with open(following_filename, 'r', encoding='utf-8') as following_file:
@ -113,8 +114,16 @@ def csv_following_list(following_filename: str) -> str:
continue
if following_list_csv:
following_list_csv += '\n'
following_list_csv += following_address + ',true'
msg = 'Account address,Show boosts\n' + following_list_csv
following_list_csv += following_address + ',true,'
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()
following_list_csv += person_notes
msg = 'Account address,Show boosts,Notes\n' + following_list_csv
return msg
return ''