events.rb 676 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class Calendar::IcsFile::Events < BaseQuery
  4. description 'Fetch events from ICS file'
  5. argument :file_id, GraphQL::Types::ID, loads: Gql::Types::StoredFileType, description: 'The file to be parsed for events.', required: true
  6. type [Gql::Types::Calendar::IcsFile::EventType], null: false
  7. def resolve(file:)
  8. calendar_data = ::Service::Calendar::IcsFile::Parse
  9. .new(current_user: context.current_user)
  10. .execute(file:)
  11. return [] if calendar_data.blank? || calendar_data[:events].blank?
  12. calendar_data[:events]
  13. end
  14. end
  15. end