Skip to content

ActivityPub delivery#4566

Merged
Gargron merged 18 commits intomasterfrom
feature-activitypub-delivery
Aug 12, 2017
Merged

ActivityPub delivery#4566
Gargron merged 18 commits intomasterfrom
feature-activitypub-delivery

Conversation

@Gargron
Copy link
Copy Markdown
Member

@Gargron Gargron commented Aug 9, 2017

TODO:

  • Delivery worker
  • FavouriteService
  • UnfavouriteService
  • ReblogService
  • PostStatusService
  • RemoveStatusService
  • BatchedRemoveStatusService
  • FollowService
  • UnfollowService
  • BlockService
  • UnblockService
  • ProcessMentionsService
  • AuthorizeFollowService
  • RejectFollowService
  • Distribution worker
  • Update account

@Gargron Gargron added activitypub Protocol-related changes, federation work in progress Not to be merged, currently being worked on labels Aug 9, 2017
@Gargron Gargron force-pushed the feature-activitypub-delivery branch 2 times, most recently from 9408a6b to 798f967 Compare August 9, 2017 17:21
@Gargron Gargron removed the work in progress Not to be merged, currently being worked on label Aug 10, 2017
@Gargron Gargron force-pushed the feature-activitypub-delivery branch from e35c6d1 to 3ce4a0b Compare August 11, 2017 23:15
current_account.update!(account_params)
@account = current_account
@account.update!(account_params)
ActivityPub::UpdateDistributionWorker.perform_async(@account.id)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this feels like it should either be in a model callback or a service

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

  • Can't be in a callback, callbacks execute in-transaction (queued job might get old data)
  • Can't be a service because while this controller uses update!, the preferences controller uses if update (different usage)

With only two usages, it's easier to just have this one extra line in both places.

end

def inboxes
reorder(nil).where(protocol: :activitypub).pluck('distinct coalesce(nullif(accounts.shared_inbox_url, \'\'), accounts.inbox_url)')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

minor, but seems like using double quotes here would make it so you don't have to escape the sql single quotes?

end

def inboxes
reorder(nil).where(protocol: :activitypub).pluck('distinct coalesce(nullif(accounts.shared_inbox_url, \'\'), accounts.inbox_url)')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we need an index on this?

end

def batch_activity_json(account, statuses)
account.followers.inboxes.each do |inbox_url|
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Delete isn't an addressed activity, and publicInbox is only for activities that are addressed to the Public collection. this feels like it should maybe be addressed by w3c/activitypub#242 although that hasn't been spec'd yet.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sharedInbox does not have any limitations.

def remove_from_mentioned(stream_entry)
salmon_xml = stream_entry_to_xml(stream_entry)
target_accounts = @mentions.map(&:account).reject(&:local?).uniq(&:domain)
def remove_from_remote_mentioned
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remote_mentioned should either be renamed to remote_reblogged_or_mentioned or this should be split into two methods.

# send it to them

target_accounts = (@mentions.map(&:account).reject(&:local?) + @reblogs.map(&:account).reject(&:local?)).uniq(&:id)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If I have a status because someone I follow reblogged it, but I didn't reblog it myself, I wouldn't receive a delete.

ActivityPub does not specify how to federate a Delete activity. tagging @cwebber because that feels like something the group should address.


sidekiq_options queue: 'push', retry: 5, dead: false

HEADERS = { 'Content-Type' => 'application/activity+json' }.freeze
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ActivityPub does not specify the content type for Server-to-Server interactions, but https://w3c.github.io/activitypub/#client-to-server-interactions implies that the primary content type of ActivityPub is application/ld+json; profile="https://www.w3.org/ns/activitystreams", and that all clients need to use that content type and that's the only one that's a must in the spec (activity+json is a should)

@nightpool
Copy link
Copy Markdown
Member

Looks good! some specific stuff i'm not super sure about, and I didn't read the tests super throughly but the rest of it looks great

@Gargron Gargron merged commit b7370ac into master Aug 12, 2017
@Gargron Gargron deleted the feature-activitypub-delivery branch August 12, 2017 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

activitypub Protocol-related changes, federation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants