gab-social/app/services/delete_chat_message_service.rb
mgabdev 7ec426e3d8 Progress on DMs
Progress on DMs
2020-12-19 01:33:33 -05:00

24 lines
480 B
Ruby

# frozen_string_literal: true
class DeleteChatMessageService < BaseService
include Redisable
def call(chat_message)
return if chat_message.nil?
@chat_message = chat_message
RedisLock.acquire(lock_options) do |lock|
if lock.acquired?
@chat_message.destroy!
else
raise GabSocial::RaceConditionError
end
end
end
def lock_options
{ redis: Redis.current, key: "distribute_chat_message:#{@chat_message.id}" }
end
end