Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

add an endpoint to get all meetings as ical

Klaus Zanders006584168505
diff --git a/modules/meeting/app/controllers/meetings/ical_controller.rb b/modules/meeting/app/controllers/meetings/ical_controller.rb
new file mode 100644
index 00000000000..98d8e5510b6
--- /dev/null
+++ b/modules/meeting/app/controllers/meetings/ical_controller.rb
@@ -0,0 +1,49 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+# ++
+module Meetings
+ class ICalController < ApplicationController
+ skip_before_action :check_if_login_required
+ authorization_checked! :index
+
+ def index
+ token = Token::ICalMeeting.find_by_plaintext_value(params[:token]) # rubocop:disable Rails/DynamicFindBy
+
+ user = token.user
+
+ service = Meetings::UnifiedICalService.new(user:)
+
+ respond_to do |format|
+ format.ics do
+ send_data(service.call.result, filename: "mycal.ics", disposition: "inline; filename=mycal.ics", type: "text/calendar")
+ end
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/services/meetings/unified_ical_service.rb b/modules/meeting/app/services/meetings/unified_ical_service.rb
new file mode 100644
index 00000000000..10267a0291f
--- /dev/null
+++ b/modules/meeting/app/services/meetings/unified_ical_service.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+require "icalendar"
+require "icalendar/tzinfo"
+
+module Meetings
+ class UnifiedICalService
+ include ICalHelpers
+ attr_reader :user, :url_helpers, :include_historic
+
+ def initialize(user:, include_historic: false)
+ @user = user
+ @url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.new
+ @include_historic = include_historic
+ end
+
+ def call
+ calendar = ::Icalendar::Calendar.new.tap do |calendar|
+ calendar.prodid = "-//OpenProject GmbH//#{OpenProject::VERSION}//Meeting//EN"
+ # calendar.add_timezone ical_timezone
+ end
+
+ ServiceResult.success(result: calendar.to_ical)
+ end
+
+ private
+
+ def recurring_meetings
+ @recurring_meetings ||= RecurringMeeting.visible(user)
+ end
+
+ def single_meetings
+ @single_meetings ||= if include_historic
+ Meeting.not_recurring.visible(user)
+ else
+ Meeting.not_recurring.from_today.visible(user)
+ end
+ end
+ end
+end
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index 0078e52fdbd..24aad015748 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -99,6 +99,8 @@ Rails.application.routes.draw do
get :new_dialog
get "menu" => "meetings/menus#show"
get :fetch_timezone
+
+ get "ical/:token", controller: "meetings/ical", action: :index, as: "ical_feed"
end
resources :agenda_items, controller: "meeting_agenda_items" do
@@ -167,9 +169,7 @@ Rails.application.routes.draw do
end
member do
- match "/:tab" => "meetings#show", :constraints => { tab: /(agenda|minutes)/ },
- :via => :get,
- :as => "tab"
+ get "/:tab" => "meetings#show", :constraints => { tab: /(agenda|minutes)/ }, :as => "tab"
end
end
end