base_controller.rb 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class ChannelsAdmin::BaseController < ApplicationController
  3. prepend_before_action :authenticate_and_authorize!
  4. def area
  5. raise NotImplementedError
  6. end
  7. def index
  8. channels = Service::Channel::Admin::List.new(area: area).execute
  9. assets = {}
  10. channel_ids = []
  11. channels.each do |channel|
  12. assets = channel.assets(assets)
  13. channel_ids.push channel.id
  14. end
  15. render json: {
  16. assets: assets,
  17. channel_ids: channel_ids
  18. }
  19. end
  20. def enable
  21. Service::Channel::Admin::Enable
  22. .new(area: area, channel_id: params[:id])
  23. .execute
  24. render json: { status: :ok }
  25. end
  26. def disable
  27. Service::Channel::Admin::Disable
  28. .new(area: area, channel_id: params[:id])
  29. .execute
  30. render json: { status: :ok }
  31. end
  32. def destroy
  33. Service::Channel::Admin::Destroy
  34. .new(area: area, channel_id: params[:id])
  35. .execute
  36. render json: { status: :ok }
  37. end
  38. end