Class: Collavre::PermissionCacheJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/collavre/permission_cache_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(operation, **args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/jobs/collavre/permission_cache_job.rb', line 8

def perform(operation, **args)
  if operation.nil?
    Rails.logger.error("[PermissionCacheJob] Received nil operation, args: #{args.inspect}")
    return
  end

  case operation.to_sym
  when :cache_owner
    cache_owner(args[:creative_id])
  when :update_owner
    update_owner(args[:creative_id], args[:old_user_id], args[:new_user_id])
  when :rebuild_for_creative
    rebuild_for_creative(args[:creative_id])
  when :propagate_share
    propagate_share(args[:creative_share_id])
  when :remove_share
    remove_share(args[:creative_share_id], args[:creative_id], args[:user_id])
  when :rebuild_user_cache_for_subtree
    rebuild_user_cache_for_subtree(args[:creative_id], args[:user_id])
  else
    Rails.logger.error("[PermissionCacheJob] Unknown operation: #{operation.inspect}, args: #{args.inspect}")
  end
end