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

Move the AllMeetingsICalService into its own namespace

Klaus Zandersb91695657d63
diff --git a/modules/meeting/app/controllers/meetings/ical_controller.rb b/modules/meeting/app/controllers/meetings/ical_controller.rb
index 9582b789951..e8346e5e57f 100644
--- a/modules/meeting/app/controllers/meetings/ical_controller.rb
+++ b/modules/meeting/app/controllers/meetings/ical_controller.rb
@@ -37,7 +37,7 @@ module Meetings
user = token.user
- service = AllMeetingsICalService.new(user:)
+ service = AllMeetings::ICalService.new(user:)
respond_to do |format|
format.ics do
diff --git a/modules/meeting/app/services/all_meetings/ical_service.rb b/modules/meeting/app/services/all_meetings/ical_service.rb
new file mode 100644
index 00000000000..dc9796af195
--- /dev/null
+++ b/modules/meeting/app/services/all_meetings/ical_service.rb
@@ -0,0 +1,71 @@
+# 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 AllMeetings
+ class ICalService
+ include Meetings::ICalHelpers
+ attr_reader :user, :url_helpers, :include_historic, :calendar, :timezone
+
+ def initialize(user:, include_historic: false)
+ @user = user
+ @timezone = user.time_zone
+ @url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.new
+ @include_historic = include_historic
+ @calendar = build_icalendar(Time.current.in_time_zone(user.time_zone))
+ end
+
+ def call
+ single_meetings.each do |meeting|
+ build_single_meeting(meeting)
+ end
+
+ ServiceResult.success(result: calendar.to_ical)
+ end
+
+ private
+
+ def ical_subject(meeting)
+ "[#{meeting.project.name}] #{I18n.t(:label_meeting)}: #{meeting.title}"
+ end
+
+ 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/app/services/all_meetings_ical_service.rb b/modules/meeting/app/services/all_meetings_ical_service.rb
deleted file mode 100644
index a60f4ba107c..00000000000
--- a/modules/meeting/app/services/all_meetings_ical_service.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-# 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"
-
-class AllMeetingsICalService
- include Meetings::ICalHelpers
- attr_reader :user, :url_helpers, :include_historic, :calendar, :timezone
-
- def initialize(user:, include_historic: false)
- @user = user
- @timezone = user.time_zone
- @url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.new
- @include_historic = include_historic
- @calendar = build_icalendar(Time.current.in_time_zone(user.time_zone))
- end
-
- def call
- single_meetings.each do |meeting|
- build_single_meeting(meeting)
- end
-
- ServiceResult.success(result: calendar.to_ical)
- end
-
- private
-
- def build_single_meeting(meeting) # rubocop:disable Metrics/AbcSize
- tzinfo = timezone.tzinfo
- tzid = tzinfo.canonical_identifier
-
- calendar.event do |e|
- e.dtstart = ical_datetime meeting.start_time, tzid
- e.dtend = ical_datetime meeting.end_time, tzid
- e.url = url_helpers.meeting_url(meeting)
- e.summary = "[#{meeting.project.name}] #{meeting.title}"
- e.description = ical_subject(meeting)
- e.uid = "#{meeting.id}@#{meeting.project.identifier}"
- e.organizer = ical_organizer
- e.location = meeting.location.presence
-
- # set_status(cancelled, e)
- add_attendees(e, meeting)
- end
- end
-
- def ical_subject(meeting)
- "[#{meeting.project.name}] #{I18n.t(:label_meeting)}: #{meeting.title}"
- end
-
- 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