forked from forks/microblog.pub
Improve actor-level blocking
This commit is contained in:
parent
4f98ff6bbf
commit
d381bb3fec
2 changed files with 29 additions and 23 deletions
50
app/boxes.py
50
app/boxes.py
|
@ -1219,10 +1219,11 @@ async def _handle_read_activity(
|
||||||
wrapped_object_actor = await fetch_actor(
|
wrapped_object_actor = await fetch_actor(
|
||||||
db_session, ap.get_actor_id(wrapped_object)
|
db_session, ap.get_actor_id(wrapped_object)
|
||||||
)
|
)
|
||||||
ro = RemoteObject(wrapped_object, actor=wrapped_object_actor)
|
if not wrapped_object_actor.is_blocked:
|
||||||
|
ro = RemoteObject(wrapped_object, actor=wrapped_object_actor)
|
||||||
|
|
||||||
# Then process it likes it's coming from a forwarded activity
|
# Then process it likes it's coming from a forwarded activity
|
||||||
await _process_note_object(db_session, read_activity, wrapped_object_actor, ro)
|
await _process_note_object(db_session, read_activity, wrapped_object_actor, ro)
|
||||||
|
|
||||||
|
|
||||||
async def _process_note_object(
|
async def _process_note_object(
|
||||||
|
@ -1666,26 +1667,29 @@ async def save_to_inbox(
|
||||||
announced_actor = await fetch_actor(
|
announced_actor = await fetch_actor(
|
||||||
db_session, ap.get_actor_id(announced_raw_object)
|
db_session, ap.get_actor_id(announced_raw_object)
|
||||||
)
|
)
|
||||||
announced_object = RemoteObject(announced_raw_object, announced_actor)
|
if not announced_actor.is_blocked:
|
||||||
announced_inbox_object = models.InboxObject(
|
announced_object = RemoteObject(
|
||||||
server=urlparse(announced_object.ap_id).hostname,
|
announced_raw_object, announced_actor
|
||||||
actor_id=announced_actor.id,
|
)
|
||||||
ap_actor_id=announced_actor.ap_id,
|
announced_inbox_object = models.InboxObject(
|
||||||
ap_type=announced_object.ap_type,
|
server=urlparse(announced_object.ap_id).hostname,
|
||||||
ap_id=announced_object.ap_id,
|
actor_id=announced_actor.id,
|
||||||
ap_context=announced_object.ap_context,
|
ap_actor_id=announced_actor.ap_id,
|
||||||
ap_published_at=announced_object.ap_published_at,
|
ap_type=announced_object.ap_type,
|
||||||
ap_object=announced_object.ap_object,
|
ap_id=announced_object.ap_id,
|
||||||
visibility=announced_object.visibility,
|
ap_context=announced_object.ap_context,
|
||||||
og_meta=await opengraph.og_meta_from_note(
|
ap_published_at=announced_object.ap_published_at,
|
||||||
db_session, announced_object
|
ap_object=announced_object.ap_object,
|
||||||
),
|
visibility=announced_object.visibility,
|
||||||
is_hidden_from_stream=True,
|
og_meta=await opengraph.og_meta_from_note(
|
||||||
)
|
db_session, announced_object
|
||||||
db_session.add(announced_inbox_object)
|
),
|
||||||
await db_session.flush()
|
is_hidden_from_stream=True,
|
||||||
inbox_object.relates_to_inbox_object_id = announced_inbox_object.id
|
)
|
||||||
inbox_object.is_hidden_from_stream = not is_from_following
|
db_session.add(announced_inbox_object)
|
||||||
|
await db_session.flush()
|
||||||
|
inbox_object.relates_to_inbox_object_id = announced_inbox_object.id
|
||||||
|
inbox_object.is_hidden_from_stream = not is_from_following
|
||||||
|
|
||||||
elif activity_ro.ap_type in ["Like", "Announce"]:
|
elif activity_ro.ap_type in ["Like", "Announce"]:
|
||||||
if not relates_to_outbox_object:
|
if not relates_to_outbox_object:
|
||||||
|
|
|
@ -76,6 +76,8 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac
|
||||||
# TODO(ts):
|
# TODO(ts):
|
||||||
#
|
#
|
||||||
# Next:
|
# Next:
|
||||||
|
# - support Move
|
||||||
|
# - support actor delete
|
||||||
# - allow to share old notes
|
# - allow to share old notes
|
||||||
# - allow to interact with object not in anybox (i.e. like from a lookup)
|
# - allow to interact with object not in anybox (i.e. like from a lookup)
|
||||||
# - only show 10 most recent threads in DMs
|
# - only show 10 most recent threads in DMs
|
||||||
|
|
Loading…
Reference in a new issue