channels_twitter_controller.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class ChannelsTwitterController < ApplicationController
  3. prepend_before_action { authentication_check(permission: 'admin.channel_twitter') }
  4. def index
  5. assets = {}
  6. ExternalCredential.where(name: 'twitter').each { |external_credential|
  7. assets = external_credential.assets(assets)
  8. }
  9. channel_ids = []
  10. Channel.where(area: 'Twitter::Account').order(:id).each { |channel|
  11. assets = channel.assets(assets)
  12. channel_ids.push channel.id
  13. }
  14. render json: {
  15. assets: assets,
  16. channel_ids: channel_ids,
  17. callback_url: ExternalCredential.callback_url('twitter'),
  18. }
  19. end
  20. def update
  21. model_update_render(Channel, params)
  22. end
  23. def enable
  24. channel = Channel.find_by(id: params[:id], area: 'Twitter::Account')
  25. channel.active = true
  26. channel.save!
  27. render json: {}
  28. end
  29. def disable
  30. channel = Channel.find_by(id: params[:id], area: 'Twitter::Account')
  31. channel.active = false
  32. channel.save!
  33. render json: {}
  34. end
  35. def destroy
  36. channel = Channel.find_by(id: params[:id], area: 'Twitter::Account')
  37. channel.destroy
  38. render json: {}
  39. end
  40. end