mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 01:34:13 +08:00
0a5f548635
As part of this move, we are also renaming `discourse-chat` to `chat`.
27 lines
789 B
Ruby
27 lines
789 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class ChatChannelArchive < ::Jobs::Base
|
|
sidekiq_options retry: false
|
|
|
|
def execute(args = {})
|
|
channel_archive = ::ChatChannelArchive.find_by(id: args[:chat_channel_archive_id])
|
|
|
|
# this should not really happen, but better to do this than throw an error
|
|
if channel_archive.blank?
|
|
Rails.logger.warn(
|
|
"Chat channel archive #{args[:chat_channel_archive_id]} could not be found, aborting archive job.",
|
|
)
|
|
return
|
|
end
|
|
|
|
return if channel_archive.complete?
|
|
|
|
DistributedMutex.synchronize(
|
|
"archive_chat_channel_#{channel_archive.chat_channel_id}",
|
|
validity: 20.minutes,
|
|
) { Chat::ChatChannelArchiveService.new(channel_archive).execute }
|
|
end
|
|
end
|
|
end
|