add ReceiveLocal worker
This commit is contained in:
parent
481431ea0a
commit
53e14dd2d6
3 changed files with 46 additions and 27 deletions
12
app/workers/receive_local.rb
Normal file
12
app/workers/receive_local.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
module Workers
|
||||
class ReceiveLocal < Base
|
||||
sidekiq_options queue: :receive_local
|
||||
|
||||
def perform(object_class_string, object_id, recipient_user_ids)
|
||||
object = object_class_string.constantize.find(object_id)
|
||||
# TODO: create visibilities
|
||||
# TODO: send notifications
|
||||
rescue ActiveRecord::RecordNotFound # Already deleted before the job could run
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -94,6 +94,10 @@ DiasporaFederation.configure do |config|
|
|||
case entity
|
||||
when DiasporaFederation::Entities::AccountDeletion
|
||||
Diaspora::Federation::Receive.account_deletion(entity)
|
||||
when DiasporaFederation::Entities::Retraction
|
||||
# TODO
|
||||
else
|
||||
persisted = case entity
|
||||
when DiasporaFederation::Entities::Comment
|
||||
Diaspora::Federation::Receive.comment(entity)
|
||||
when DiasporaFederation::Entities::Contact
|
||||
|
|
@ -115,13 +119,14 @@ DiasporaFederation.configure do |config|
|
|||
# TODO: update profile
|
||||
when DiasporaFederation::Entities::Reshare
|
||||
Diaspora::Federation::Receive.reshare(entity)
|
||||
when DiasporaFederation::Entities::Retraction
|
||||
# TODO
|
||||
when DiasporaFederation::Entities::StatusMessage
|
||||
Diaspora::Federation::Receive.status_message(entity)
|
||||
else
|
||||
raise DiasporaFederation::Entity::UnknownEntity, "unknown entity: #{entity.class}"
|
||||
end
|
||||
|
||||
Workers::ReceiveLocal.perform_async(persisted.class.to_s, persisted.id, [recipient_id].compact) if persisted
|
||||
end
|
||||
end
|
||||
|
||||
on :fetch_public_entity do |entity_type, guid|
|
||||
|
|
|
|||
|
|
@ -63,13 +63,15 @@ module Diaspora
|
|||
end
|
||||
|
||||
def self.participation(entity)
|
||||
parent = entity.parent_type.constantize.find_by(guid: entity.parent_guid)
|
||||
|
||||
return unless parent.author.local?
|
||||
|
||||
Participation.new(
|
||||
author: author_of(entity),
|
||||
guid: entity.guid,
|
||||
target: entity.parent_type.constantize.find_by(guid: entity.parent_guid)
|
||||
).tap do |participation|
|
||||
participation.save! if participation.parent.author.local?
|
||||
end
|
||||
).tap(&:save!)
|
||||
end
|
||||
|
||||
def self.photo(entity)
|
||||
|
|
|
|||
Loading…
Reference in a new issue