FIX: do not use return in block (#26260)

We were incorrectly using `return` in a block which was causing exceptions at runtime. These exceptions were not causing much issues as they are in defer block.

While working on writing a test for this specific case, I noticed that our `upsert_custom_fields` function was using rails `update_all` which is not updating the `updated_at` timestamp. This commit also fixes it and adds a test for it.
This commit is contained in:
Joffrey JAFFEUX
2024-03-20 10:49:28 +01:00
committed by GitHub
parent 2a37be701f
commit a884842fa5
4 changed files with 20 additions and 2 deletions

View File

@@ -174,7 +174,7 @@ module Chat
def update_user_last_channel(guardian:, channel:)
Scheduler::Defer.later "Chat::ListChannelMessages - defer update_user_last_channel" do
return if guardian.user.custom_fields[::Chat::LAST_CHAT_CHANNEL_ID] == channel.id
next if guardian.user.custom_fields[::Chat::LAST_CHAT_CHANNEL_ID] == channel.id
guardian.user.upsert_custom_fields(::Chat::LAST_CHAT_CHANNEL_ID => channel.id)
end
end