2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2015-06-26 12:00:10 +00:00
|
|
|
class CalendarSubscriptionsController < ApplicationController
|
2020-03-19 09:39:51 +00:00
|
|
|
prepend_before_action { authentication_check(basic_auth_promt: true) && authorize! }
|
2015-06-25 14:17:57 +00:00
|
|
|
|
2015-06-26 12:00:10 +00:00
|
|
|
# @path [GET] /calendar_subscriptions
|
2015-06-25 14:17:57 +00:00
|
|
|
#
|
2015-06-26 12:00:10 +00:00
|
|
|
# @summary Returns an iCal file with all objects matching the calendar subscriptions preferences of the current user as events.
|
2015-06-25 14:17:57 +00:00
|
|
|
#
|
|
|
|
# @response_message 200 [String] iCal file ready to import in calendar applications.
|
2021-02-04 08:28:41 +00:00
|
|
|
# @response_message 403 Forbidden / Invalid session.
|
|
|
|
# @response_message 422 Unprocessable Entity.
|
2015-06-25 14:17:57 +00:00
|
|
|
def all
|
2016-08-17 11:48:11 +00:00
|
|
|
calendar_subscriptions = CalendarSubscriptions.new(current_user)
|
2015-06-26 12:00:10 +00:00
|
|
|
ical = calendar_subscriptions.all
|
2015-06-25 14:17:57 +00:00
|
|
|
|
|
|
|
send_data(
|
|
|
|
ical,
|
2018-12-19 17:31:51 +00:00
|
|
|
filename: 'zammad.ical',
|
|
|
|
type: 'text/plain',
|
2015-06-25 14:17:57 +00:00
|
|
|
disposition: 'inline'
|
|
|
|
)
|
|
|
|
rescue => e
|
2017-04-19 10:09:54 +00:00
|
|
|
logger.error e
|
2015-06-25 14:17:57 +00:00
|
|
|
render json: { error: e.message }, status: :unprocessable_entity
|
|
|
|
end
|
|
|
|
|
2015-06-26 12:00:10 +00:00
|
|
|
# @path [GET] /calendar_subscriptions/:object
|
|
|
|
# @path [GET] /calendar_subscriptions/:object/:method
|
2015-06-25 14:17:57 +00:00
|
|
|
#
|
2015-06-26 12:00:10 +00:00
|
|
|
# @summary Returns an iCal file of the given object (and method) matching the calendar subscriptions preferences of the current user as events.
|
2015-06-25 14:17:57 +00:00
|
|
|
#
|
|
|
|
# @response_message 200 [String] iCal file ready to import in calendar applications.
|
2021-02-04 08:28:41 +00:00
|
|
|
# @response_message 403 Forbidden / Invalid session.
|
|
|
|
# @response_message 422 Unprocessable Entity.
|
2015-06-25 14:17:57 +00:00
|
|
|
def object
|
2016-08-17 11:48:11 +00:00
|
|
|
calendar_subscriptions = CalendarSubscriptions.new(current_user)
|
|
|
|
ical = calendar_subscriptions.generic(params[:object], params[:method])
|
2015-06-25 14:17:57 +00:00
|
|
|
|
|
|
|
send_data(
|
|
|
|
ical,
|
2018-12-19 17:31:51 +00:00
|
|
|
filename: 'zammad.ical',
|
|
|
|
type: 'text/plain',
|
2015-06-25 14:17:57 +00:00
|
|
|
disposition: 'inline'
|
|
|
|
)
|
|
|
|
rescue => e
|
2017-04-19 10:09:54 +00:00
|
|
|
logger.error e
|
2015-06-25 14:17:57 +00:00
|
|
|
render json: { error: e.message }, status: :unprocessable_entity
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|