From 5dd6385fe6ce9a37d95bcc41a62c48c24c135c67 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Thu, 22 Aug 2019 00:45:49 +0200 Subject: [PATCH] Fix the published flag for outbox activities --- blueprints/tasks.py | 10 ++-------- core/activitypub.py | 21 ++++++++++++--------- core/meta.py | 4 ++++ 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/blueprints/tasks.py b/blueprints/tasks.py index 880bf0e..d2545dc 100644 --- a/blueprints/tasks.py +++ b/blueprints/tasks.py @@ -32,9 +32,9 @@ from core.meta import MetaKey from core.meta import by_object_id from core.meta import by_remote_id from core.meta import by_type -from core.meta import flag from core.meta import inc from core.meta import upsert +from core.notifications import _NewMeta from core.notifications import set_inbox_flags from core.outbox import process_outbox from core.remote import track_failed_send @@ -44,7 +44,6 @@ from core.shared import _Response from core.shared import back from core.shared import p from core.tasks import Tasks -from utils import now from utils import opengraph from utils.media import is_video @@ -643,12 +642,7 @@ def task_process_new_activity() -> _Response: activity = ap.fetch_remote_activity(iri) app.logger.info(f"activity={activity!r}") - flags = {} - - if not activity.published: - flags.update(flag(MetaKey.PUBLISHED, now())) - else: - flags.update(flag(MetaKey.PUBLISHED, activity.published)) + flags: _NewMeta = {} set_inbox_flags(activity, flags) app.logger.info(f"a={activity}, flags={flags!r}") diff --git a/core/activitypub.py b/core/activitypub.py index e43653c..2559f71 100644 --- a/core/activitypub.py +++ b/core/activitypub.py @@ -123,15 +123,18 @@ def save(box: Box, activity: ap.BaseActivity) -> None: "type": _to_list(activity.type), "remote_id": activity.id, "meta": { - "undo": False, - "deleted": False, - "public": is_public, - "server": urlparse(activity.id).netloc, - "visibility": visibility.name, - "actor_id": actor_id, - "object_id": object_id, - "object_visibility": object_visibility, - "poll_answer": False, + MetaKey.UNDO.value: False, + MetaKey.DELETED.value: False, + MetaKey.PUBLIC.value: is_public, + MetaKey.SERVER.value: urlparse(activity.id).netloc, + MetaKey.VISIBILITY.value: visibility.name, + MetaKey.ACTOR_ID.value: actor_id, + MetaKey.OBJECT_ID.value: object_id, + MetaKey.OBJECT_VISIBILITY.value: object_visibility, + MetaKey.POLL_ANSWER.value: False, + MetaKey.PUBLISHED.value: activity.published + if activity.published + else now(), }, } ) diff --git a/core/meta.py b/core/meta.py index 2b51346..6a6ccef 100644 --- a/core/meta.py +++ b/core/meta.py @@ -39,6 +39,10 @@ class MetaKey(Enum): PUBLIC = "public" THREAD_ROOT_PARENT = "thread_root_parent" + SERVER = "server" + VISIBILITY = "visibility" + OBJECT_VISIBILITY = "object_visibility" + DELETED = "deleted" BOOSTED = "boosted" LIKED = "liked"