Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable published activities pooling #802

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jum-s
Copy link
Contributor

@jum-s jum-s commented Dec 9, 2024

This is an attempt to "unpool" recent activities.

While having to deal with past decisions (storing in db since and until inside one activity, seems rigid to our current needs...), this implementation is still relying on those stored activities, to avoid having to re-write/touch on the current activities stored in db.

Choosing this implementation has the advantages of fully reusing existing functions (refactoring for directly formatting items could be done later)

To-do later: delete any pooling possibilities, and stop storing since and then activities

Solves #574
Client PR #526
To be merged after #801

@jum-s jum-s requested a review from maxlath December 9, 2024 14:54
@jum-s jum-s force-pushed the disable-published-activities-pooling branch from e60e78d to e321ea0 Compare December 13, 2024 15:51
@maxlath maxlath force-pushed the disable-published-activities-pooling branch 2 times, most recently from 485fd6c to c77dfd1 Compare January 8, 2025 11:19
@maxlath
Copy link
Member

maxlath commented Jan 8, 2025

[non-blocking consideration]
I was wondering if user.poolActivities should rather be user.settings.activities.pool, to keep this kind of user-updatable parameters together, but there are other settings not following that convention (fediversable, summaryPeriodicity, etc) so maybe we are stuck with this inconsistency for now

@maxlath maxlath force-pushed the disable-published-activities-pooling branch from c77dfd1 to f0ef879 Compare January 8, 2025 11:45
@@ -42,11 +42,12 @@ const createDebouncedActivity = ({ userId, shelfId }: createActivityParams) => a
}

async function _createDebouncedActivity ({ userId, shelfId }: createActivityParams) {
Copy link
Member

@maxlath maxlath Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of debouncing was to pool activities, so if user.poolActivities === true [edited] user.poolActivities === false the activities shouldn't be debounced, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it, for me, your comment says:

debounce === pool
so if (pool === true)
then debounce should be false

Can you see the contradiction I see?

If we pool, activities are debounced, no? As it was the case before this PR. Or I don't understand at all what's going on here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I messed up the logic in my comment, sorry, see edited version

server/controllers/activitypub/lib/radio_hooks.ts Outdated Show resolved Hide resolved
@@ -68,12 +70,11 @@ async function _createDebouncedActivity ({ userId, shelfId }: createActivityPara
actor: { name },
object: { items: { since, until: Date.now() } },
Copy link
Member

@maxlath maxlath Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in your PR introductory comment, if user.poolActivities === true [edited] user.poolActivities === false , no need to create this activity doc: the item doc itself has all we need (just like entity activities are built from patch docs, without needing to store an activity doc). I would be in favor to try doing that in this PR, as having a single item activity with since and until is really weird

Copy link
Contributor Author

@jum-s jum-s Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I explored how to do what you suggest. After a few hours of refactoring, I think it's not worth it anymore.
Because poolActivities is used quite deeply in the current code: at the very formatting of the activity (formatUserItemsActivities) and it's used by the outbox endpoint, the activity endpoint and the postActivity function.
So extracting poolActivities (necessary to pass directly an items array to formatUserItemsActivities, what you say with "the item doc itself has all we need") leaves an early if which then have functions that almost look like each other (ie.

  • formatUserItemsActivities({ activitiesDocs, user }) and
  • formatUserItemsActivities({ items, user })

)

This duck typing is more difficult to read, and introduces different behaviours using different objects (items & activities), it feels it will be even harder to refactor later IMO. (Plus, all the refactoring have to be done with the shelves part too)

Your comment/diagnosis is legit, but the intervention is trickier than expected. The main reason behind is that we now want to keep both behaviours available (pooling and not pooling). The fact that it is now unpooled by default, makes it easy to check later is this pooling feature is actually activated by people. What about leave the PR like this, wait to see if the pooling feature is actually used, and then decide to remove or keeping it once we figured it out ?

Note: after the exploration, I ended up with the feeling that if the pooling feature is here to not spam other instances, what about only having pooling when sending create activities, but not on outbox and activity endpoints ? This would induce to remove the possibility to send request to the activity endpoint and directly build the link in the pooled activity only with the first item created.
Note2: The more I think about it, the more I think we should get rid of the complexity and remove pooling possibility all together.

@jum-s jum-s force-pushed the disable-published-activities-pooling branch from f0ef879 to c258dce Compare January 9, 2025 05:11
@jum-s jum-s force-pushed the main branch 2 times, most recently from d63e856 to f76df8e Compare January 19, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants