2017-02-15 02:35:22 +00:00
|
|
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
|
|
|
class ChannelsTwitterController < ApplicationController
|
2017-02-15 12:29:25 +00:00
|
|
|
prepend_before_action { authentication_check(permission: 'admin.channel_twitter') }
|
2017-02-15 02:35:22 +00:00
|
|
|
|
|
|
|
def index
|
|
|
|
assets = {}
|
2017-10-01 12:25:52 +00:00
|
|
|
ExternalCredential.where(name: 'twitter').each do |external_credential|
|
2017-02-15 02:35:22 +00:00
|
|
|
assets = external_credential.assets(assets)
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2017-02-15 02:35:22 +00:00
|
|
|
channel_ids = []
|
2017-10-01 12:25:52 +00:00
|
|
|
Channel.where(area: 'Twitter::Account').order(:id).each do |channel|
|
2017-02-15 02:35:22 +00:00
|
|
|
assets = channel.assets(assets)
|
|
|
|
channel_ids.push channel.id
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2017-02-15 02:35:22 +00:00
|
|
|
render json: {
|
|
|
|
assets: assets,
|
|
|
|
channel_ids: channel_ids,
|
|
|
|
callback_url: ExternalCredential.callback_url('twitter'),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
model_update_render(Channel, params)
|
|
|
|
end
|
|
|
|
|
|
|
|
def enable
|
|
|
|
channel = Channel.find_by(id: params[:id], area: 'Twitter::Account')
|
|
|
|
channel.active = true
|
|
|
|
channel.save!
|
|
|
|
render json: {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def disable
|
|
|
|
channel = Channel.find_by(id: params[:id], area: 'Twitter::Account')
|
|
|
|
channel.active = false
|
|
|
|
channel.save!
|
|
|
|
render json: {}
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
channel = Channel.find_by(id: params[:id], area: 'Twitter::Account')
|
|
|
|
channel.destroy
|
|
|
|
render json: {}
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|