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

Add support for limited Announce Activity #15776

Conversation

noellabo
Copy link
Contributor

For Announce Activity, we'll add support for Bearcaps dereference, limited visibility, and direct delivery of actors inbox.

Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

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

While the feature would be somewhat useful, this current implementation has several performance issues.

Furthermore, I'm uncomfortable with the whole audience processing logic being duplicated with Create.

Finally, I am not too sure mentions for reblogs are handled in a way that makes sense across the codebase.

@@ -2,28 +2,23 @@

class ActivityPub::Activity::Announce < ActivityPub::Activity
def perform
dereference_object!
Copy link
Contributor

Choose a reason for hiding this comment

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

dereference_object! unconditionally dereferences the object if it's an URL. This change will cause any cross-instance boost to re-fetch known Announced statuses.

Also, it would make sense to not dereference a status if it's not related to local activity (though the reblog_of_local_status? check would have to be changed to first check if the URI is possibly local and not do status_from_uri).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to check if url points to local before reblog_of_local_status? accesses the database. After passing these checks, I now run dereference_object!.

original_status = status_from_object

return reject_payload! if original_status.nil? || !announceable?(original_status)
@original_status = status_from_object
Copy link
Contributor

Choose a reason for hiding this comment

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

If the object is an URI, the earlier call to dereference_object! fails and the object isn't already known, a second (wasteful) attempt at dereferencing the status will be made by status_from_object.

If dereference_object! has been successful, status_from_object will perform a wasteful database query to find the status that is already loaded in @object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to record the success or failure of dereference and use the acquired object if the dereference is successful.

delivered_to_account = Account.find(@options[:delivered_to_account_id])

@status.mentions.create(account: delivered_to_account, silent: true)
@status.update(visibility: :limited) if @status.direct_visibility?
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big deal, but not useful here as reblogs can't have direct visibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved duplicate code for Create and Announce to one place.

@noellabo
Copy link
Contributor Author

This PR allows you to receive boosts for circle members in the circle function. The ability to deliver limited annouce will be implemented separately.

We have also made a change to allow dereferenced Announce Activities delivered by group actors.
https://github.com/tootsuite/mastodon/blob/23f219a1966485b4417ef42c4f7901bb45b2db25/app/lib/activitypub/activity/announce.rb#L66-L68

This allows the group server to deliver posts that are exclusive to group participants.

I haven't tested it enough yet, so I'll verify it over the weekend.

@noellabo noellabo force-pushed the add-support-for-limited-announce-activity branch from 23f219a to 6388cce Compare April 17, 2021 18:46
@noellabo noellabo marked this pull request as draft April 18, 2021 08:18
@noellabo noellabo force-pushed the add-support-for-limited-announce-activity branch from bb05b46 to c5aa094 Compare April 21, 2021 06:50
@noellabo noellabo marked this pull request as ready for review April 21, 2021 16:00
@noellabo
Copy link
Contributor Author

Changed to use the object fetched by dereference and solved the performance problem.

The code related to the group will be reverted and will be handled by another PR.

Please review.

Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

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

Not marked as accepted as I would like another set of eyes on this PR that might have subtle security implications.

I have not found anything fishy, though, and the change seems good to me.

I'm not too sure about process_audience and postprocess_audience_and_deliver being in ActivityPub::Activity because they rely on rely specific params, status and mentions instance variables and are really specific to status creation, but I still think it's better than duplicating them. Maybe a concern?

@@ -63,6 +71,6 @@ def requested_through_relay?
end

def reblog_of_local_status?
status_from_uri(object_uri)&.account&.local?
ActivityPub::TagManager.instance.local_uri?(object_uri) && status_from_uri(object_uri)&.account&.local?
Copy link
Contributor

Choose a reason for hiding this comment

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

Not directly related as far as I understand, but a good change nonetheless as it avoids a database query in the case the status isn't a local one.

@noellabo
Copy link
Contributor Author

I moved the methods related to process_audience to ProcessAudience concern.

Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

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

Again, not marked as accepted as I would really like another pair of eyes checking this PR for security implications, but it looks good to me and I have no further remarks at the moment!

@noellabo noellabo force-pushed the add-support-for-limited-announce-activity branch from a7caeb3 to 8866397 Compare May 7, 2021 23:35
@noellabo noellabo force-pushed the add-support-for-limited-announce-activity branch from 8866397 to 80f6e79 Compare May 8, 2021 00:26
@stale
Copy link

stale bot commented Sep 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status/wontfix This will not be worked on label Sep 6, 2021
@stale stale bot closed this Sep 19, 2021
@noellabo
Copy link
Contributor Author

The evaluation has not progressed, but I think that it will be reviewed when the group function is used. Stay open.

@noellabo noellabo reopened this Sep 21, 2021
@stale stale bot removed the status/wontfix This will not be worked on label Sep 21, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status/wontfix This will not be worked on label Apr 16, 2022
@stale stale bot closed this Apr 27, 2022
@noellabo
Copy link
Contributor Author

This pull request will remain closed and will be pulled again when the need arises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants