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

Extract ActivityPubPayloadGeneration model concern #30072

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mjankowski
Copy link
Contributor

Pulls out same behavior from these 3 models into shared concern.

Side note, the method def they are calling is:

  def generate_uri_for(_target)
    URI.join(root_url, 'payloads', SecureRandom.uuid)
  end
  • The method just ignores the argument it's sent ... we could potentially change the signature and/or naming here to remove the ignored arg. Something like generate_payload_uri or whatever may be more accurate (my assumption before I looked at the def was that the passed in object had something to do with the generation, but it doesnt, its just a random string).
  • Is there a reason that payloads string is there? I don't think it ever contributes to the generated string...

@renchap renchap added refactoring Improving code quality ruby Pull requests that update Ruby code labels Apr 26, 2024
@ClearlyClaire
Copy link
Contributor

Is there a reason that payloads string is there? I don't think it ever contributes to the generated string...

I think it is intended to contribute but has not ever been verified to. This should probably be changed to URI.join(root_url, '/payloads/', SecureRandom.uuid).

@ClearlyClaire
Copy link
Contributor

I find the concern name confusing. This method is used to set a unique URI that does not directly correspond to database IDs, and the concern is only about that, and not to generate any kind of ActivityPub payload.

On a side note, I'm not sure how useful that whole approach is given activities cannot be looked up by such URLs in an efficient way. It might make more sense to have per-activity-type namespace and an easy-to-look-up internal ID. However, this cannot really be retroactively applied to existing activities…

@mjankowski
Copy link
Contributor Author

RE: the concern module name ... I think I named that prior to fully investigating what the method they were calling was doing. Open to better ideas there. Might make sense to rename/update that value-generating method first, then contemplate a module name.

Is it accurate that for all these use case the whole goal is just to get some unique uri value as a global identifier that never needs to be accessed/routed/etc, but does need to be unique across the universe of published AP objects by the instance?

@ClearlyClaire
Copy link
Contributor

Is it accurate that for all these use case the whole goal is just to get some unique uri value as a global identifier that never needs to be accessed/routed/etc, but does need to be unique across the universe of published AP objects by the instance?

Mostly accurate. There are edge cases where they need to be identified by URI, and those edge cases are slow due to the lack of indexes.

@mjankowski
Copy link
Contributor Author

Excellent. Thoughts on ...

  • Rename existing method to ActivityPub::TagManager#generate_activity_uri (and remove the unused arg) - can do this in separate PR
  • Rename the added concern here to ActivityPubActivityURI or similar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Improving code quality ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants