Get ssml for a post

main
Bob Mottram 2022-05-12 12:00:02 +01:00
parent 7ac43ab700
commit 3bc6d13022
1 changed files with 26 additions and 2 deletions

View File

@ -11381,7 +11381,7 @@ class PubServer(BaseHTTPRequestHandler):
self.server.getreq_busy = False
return True
def _show_individual_post(self, authorized: bool,
def _show_individual_post(self, ssml_getreq: bool, authorized: bool,
calling_domain: str, referer_domain: str,
path: str,
base_dir: str, http_prefix: str,
@ -11423,6 +11423,30 @@ class PubServer(BaseHTTPRequestHandler):
if len(status_number) <= 10 or (not status_number.isdigit()):
return False
if ssml_getreq:
ssml_filename = \
acct_dir(base_dir, nickname, domain) + '/postcache/' + \
http_prefix + ':##' + domain_full + '#users#' + nickname + \
'#statuses#' + status_number + '.ssml'
if not os.path.isfile(ssml_filename):
self._404()
return True
ssml_str = None
try:
with open(ssml_filename, 'r') as fp_ssml:
ssml_str = fp_ssml.read()
except OSError:
pass
if ssml_str:
msg = ssml_str.encode('utf-8')
msglen = len(msg)
self._set_headers('application/ssml+xml', msglen,
cookie, calling_domain, False)
self._write(msg)
return True
self._404()
return True
post_filename = \
acct_dir(base_dir, nickname, domain) + '/outbox/' + \
http_prefix + ':##' + domain_full + '#users#' + nickname + \
@ -17811,7 +17835,7 @@ class PubServer(BaseHTTPRequestHandler):
# get an individual post from the path
# /users/nickname/statuses/number
if '/statuses/' in self.path and users_in_path:
if self._show_individual_post(authorized,
if self._show_individual_post(ssml_getreq, authorized,
calling_domain, referer_domain,
self.path,
self.server.base_dir,