~tsileo/microblog.pub-devel

microblog.pub: fix unshare v1 APPLIED

Hi,

I unshared a message that I had accidentally shared.
Although it was effectively unshared on my profile, it was still present
on federated instances.

I found no errors in logs, but the list of recipients was empty (unlike
the list of recipients in the "Announce" activity):

2022-11-25 21:23:23.044 | INFO     | app.main:__call__:168 |
2c6af0f7f96af82e - xxx.xxx.xxx.xxx:0 - POST
https://xxx.xxx.xxx.xxx:8000/admin/actions/undo - "Mozilla/5.0 (Android
10; Mobile; rv:105.0) Gecko/105.0 Firefox/105.0"
2022-11-25 21:23:23.160 | INFO     | app.boxes:_compute_recipients:891 |
2c6af0f7f96af82e - []
INFO:     xxx.xxx.xxx.xxx:0 - "POST /admin/actions/undo HTTP/1.0" 302
Found

Recipients were retrieved directly from the "Undo" activity
(outbox_object) instead of the "Announce" activity.

Sam (1):
  fix unshare by getting recipients from Announce activity instead of
    Undo

 app/boxes.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.34.5
#891868 running .build.yml
Hey, I believe this change introduced another issue: now "unshare" events
are sent to followers of author of the _original_ post - while I believe
they should be sent to _my_ followers (but please correct me if I'm wrong
here).

What I saw was:

When I tried to share and (immediately) unshare a post by a popular user
(see, for example, latest post shared by https://microblog.pub/), I got a
server error.

data/uvicorn.log file shows that microblog.pub tried to fetch all
followers of the author of original post (in this case it was
https://social.wake.st/@liaizon with 3.7k followers), and after it fetched
300 pages(!!) from remote server - they responded with '429 Too Many
Requests'.

This doesn't look right :)

I think if we didn't preserve list of people who received original
"announce" event - then the best we can do is to send the "undo announce"
event to all our _current_ followers.
Oops, that's a good catch, I just pushed a fix.

It should re-use the recipients on the `Announce`: https://git.sr.ht/~tsileo/microblog.pub/commit/34c7cdb5fb9c5b681f91fd52c6323bb22c46a4ad

Thanks!
Hi,

sorry for the bug, I was just about to push a fix.

thanks for the patch.


------- Original Message -------
~tsileo: Thanks for the quick fix, as always!

~samr1: No problem, happens to all of us!
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~tsileo/microblog.pub-devel/patches/37154/mbox | git am -3
Learn more about email & git

[PATCH microblog.pub 1/1] fix unshare by getting recipients from Announce activity instead of Undo Export this patch

From: Sam <samr1.dev@pm.me>

---
 app/boxes.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/boxes.py b/app/boxes.py
index 8ebd7e2..d162fc5 100644
--- a/app/boxes.py
+++ b/app/boxes.py
@@ -427,7 +427,7 @@ async def _send_undo(db_session: AsyncSession, ap_object_id: str) -> None:
        announced_object.announced_via_outbox_object_ap_id = None

        # Send the Undo to the original recipients
        recipients = await _compute_recipients(db_session, outbox_object.ap_object)
        recipients = await _compute_recipients(db_session, announced_object.ap_object)
        for rcp in recipients:
            await new_outgoing_activity(db_session, rcp, outbox_object.id)
    elif outbox_object_to_undo.ap_type == "Block":
-- 
2.34.5