From a160a95e820e36f2b71475d71b4d987db7b21b5c Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 3 Jun 2018 22:44:19 +0200 Subject: [PATCH] Fixes replies, and hide them on the homepage --- activitypub.py | 8 ++++++++ app.py | 11 ++++++++--- templates/note.html | 1 - 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/activitypub.py b/activitypub.py index bb1ad48..1b2aed2 100644 --- a/activitypub.py +++ b/activitypub.py @@ -246,6 +246,9 @@ class BaseActivity(object): raise ValueError('Invalid actor') return actor['id'] + def reset_object_cache(self) -> None: + self.__obj = None + def get_object(self) -> 'BaseActivity': if self.__obj: return self.__obj @@ -824,6 +827,7 @@ class Create(BaseActivity): def _set_id(self, uri: str, obj_id: str) -> None: self._data['object']['id'] = uri + '/activity' self._data['object']['url'] = ID + '/' + self.get_object().type.lower() + '/' + obj_id + self.reset_object_cache() def _init(self, **kwargs): obj = self.get_object() @@ -857,6 +861,8 @@ class Create(BaseActivity): threads = [] reply = obj.get_local_reply() + print(f'initial_reply={reply}') + print(f'{obj}') logger.debug(f'initial_reply={reply}') reply_id = None direct_reply = 1 @@ -881,6 +887,8 @@ class Create(BaseActivity): reply = reply.get_local_reply() logger.debug(f'next_reply={reply}') threads.append(reply_id) + # FIXME(tsileo): obj.id is None!! + print(f'reply_id={reply_id} {obj.id} {obj._data} {self.id}') if reply_id: if not DB.inbox.find_one_and_update({'activity.object.id': obj.id}, { diff --git a/app.py b/app.py index b215a00..f0b6d9a 100644 --- a/app.py +++ b/app.py @@ -78,10 +78,14 @@ csrf = CSRFProtect(app) logger = logging.getLogger(__name__) # Hook up Flask logging with gunicorn -gunicorn_logger = logging.getLogger('gunicorn.error') root_logger = logging.getLogger() -root_logger.handlers = gunicorn_logger.handlers -root_logger.setLevel(gunicorn_logger.level) +if os.getenv('FLASK_DEBUG'): + logger.setLevel(logging.DEBUG) + root_logger.setLevel(logging.DEBUG) +else: + gunicorn_logger = logging.getLogger('gunicorn.error') + root_logger.handlers = gunicorn_logger.handlers + root_logger.setLevel(gunicorn_logger.level) SIG_AUTH = HTTPSigAuth(ID+'#main-key', KEY.privkey) @@ -378,6 +382,7 @@ def index(): q = { 'type': 'Create', 'activity.object.type': 'Note', + 'activity.object.inReplyTo': None, 'meta.deleted': False, } c = request.args.get('cursor') diff --git a/templates/note.html b/templates/note.html index b682238..c6b4ac7 100644 --- a/templates/note.html +++ b/templates/note.html @@ -16,7 +16,6 @@ {% block content %}
{% include "header.html" %} -{{ thread }} {{ utils.display_thread(thread) }}
{% endblock %}