channels_google_controller.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. class ChannelsGoogleController < ApplicationController
  3. include CanXoauth2EmailChannel
  4. prepend_before_action :authenticate_and_authorize!
  5. def area
  6. 'Google::Account'.freeze
  7. end
  8. def external_credential_name
  9. 'google'.freeze
  10. end
  11. def enable
  12. channel = Channel.find_by(id: params[:id], area:)
  13. channel.active = true
  14. channel.save!
  15. render json: {}
  16. end
  17. def disable
  18. channel = Channel.find_by(id: params[:id], area:)
  19. channel.active = false
  20. channel.save!
  21. render json: {}
  22. end
  23. def destroy
  24. channel = Channel.find_by(id: params[:id], area:)
  25. email = EmailAddress.find_by(channel_id: channel.id)
  26. email&.destroy!
  27. channel.destroy!
  28. render json: {}
  29. end
  30. def rollback_migration
  31. channel = Channel.find_by!(id: params[:id], area:)
  32. raise __('Failed to find backup on channel!') if !channel.options[:backup_imap_classic]
  33. channel.update!(channel.options[:backup_imap_classic][:attributes])
  34. render json: {}
  35. end
  36. end