2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
2017-02-15 02:35:22 +00:00
|
|
|
|
|
|
|
class ChannelsFacebookController < ApplicationController
|
2020-03-19 09:39:51 +00:00
|
|
|
prepend_before_action { authentication_check && authorize! }
|
2017-02-15 02:35:22 +00:00
|
|
|
|
|
|
|
def index
|
|
|
|
assets = {}
|
2017-10-01 12:25:52 +00:00
|
|
|
ExternalCredential.where(name: 'facebook').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: 'Facebook::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: {
|
2018-12-19 17:31:51 +00:00
|
|
|
assets: assets,
|
|
|
|
channel_ids: channel_ids,
|
2017-02-15 02:35:22 +00:00
|
|
|
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
|