Fixes replies, and hide them on the homepage

This commit is contained in:
Thomas Sileo 2018-06-03 22:44:19 +02:00
parent 63b2d2870a
commit a160a95e82
3 changed files with 16 additions and 4 deletions

View file

@ -246,6 +246,9 @@ class BaseActivity(object):
raise ValueError('Invalid actor') raise ValueError('Invalid actor')
return actor['id'] return actor['id']
def reset_object_cache(self) -> None:
self.__obj = None
def get_object(self) -> 'BaseActivity': def get_object(self) -> 'BaseActivity':
if self.__obj: if self.__obj:
return self.__obj return self.__obj
@ -824,6 +827,7 @@ class Create(BaseActivity):
def _set_id(self, uri: str, obj_id: str) -> None: def _set_id(self, uri: str, obj_id: str) -> None:
self._data['object']['id'] = uri + '/activity' self._data['object']['id'] = uri + '/activity'
self._data['object']['url'] = ID + '/' + self.get_object().type.lower() + '/' + obj_id self._data['object']['url'] = ID + '/' + self.get_object().type.lower() + '/' + obj_id
self.reset_object_cache()
def _init(self, **kwargs): def _init(self, **kwargs):
obj = self.get_object() obj = self.get_object()
@ -857,6 +861,8 @@ class Create(BaseActivity):
threads = [] threads = []
reply = obj.get_local_reply() reply = obj.get_local_reply()
print(f'initial_reply={reply}')
print(f'{obj}')
logger.debug(f'initial_reply={reply}') logger.debug(f'initial_reply={reply}')
reply_id = None reply_id = None
direct_reply = 1 direct_reply = 1
@ -881,6 +887,8 @@ class Create(BaseActivity):
reply = reply.get_local_reply() reply = reply.get_local_reply()
logger.debug(f'next_reply={reply}') logger.debug(f'next_reply={reply}')
threads.append(reply_id) 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 reply_id:
if not DB.inbox.find_one_and_update({'activity.object.id': obj.id}, { if not DB.inbox.find_one_and_update({'activity.object.id': obj.id}, {

11
app.py
View file

@ -78,10 +78,14 @@ csrf = CSRFProtect(app)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# Hook up Flask logging with gunicorn # Hook up Flask logging with gunicorn
gunicorn_logger = logging.getLogger('gunicorn.error')
root_logger = logging.getLogger() root_logger = logging.getLogger()
root_logger.handlers = gunicorn_logger.handlers if os.getenv('FLASK_DEBUG'):
root_logger.setLevel(gunicorn_logger.level) 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) SIG_AUTH = HTTPSigAuth(ID+'#main-key', KEY.privkey)
@ -378,6 +382,7 @@ def index():
q = { q = {
'type': 'Create', 'type': 'Create',
'activity.object.type': 'Note', 'activity.object.type': 'Note',
'activity.object.inReplyTo': None,
'meta.deleted': False, 'meta.deleted': False,
} }
c = request.args.get('cursor') c = request.args.get('cursor')

View file

@ -16,7 +16,6 @@
{% block content %} {% block content %}
<div id="container"> <div id="container">
{% include "header.html" %} {% include "header.html" %}
{{ thread }}
{{ utils.display_thread(thread) }} {{ utils.display_thread(thread) }}
</div> </div>
{% endblock %} {% endblock %}