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