diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-17 03:03:57 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-17 03:03:57 +0500 |
| commit | dfbaa457d5e3dbc68407b41a9d76d58f1737f77e (patch) | |
| tree | 9c8eb0c317cb82c653c411b6427a58aa642fe230 /luamods | |
| parent | cbd5810df1f051a56a052fd4ad48c9629e884d26 (diff) | |
fix: improper event unsubscription
Diffstat (limited to 'luamods')
| -rw-r--r-- | luamods/notify.lua | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/luamods/notify.lua b/luamods/notify.lua index afd4322..cfb4def 100644 --- a/luamods/notify.lua +++ b/luamods/notify.lua @@ -42,7 +42,8 @@ local lines = { ["empty_subs"] = "{sender.alias_name}: You do not have any event subscriptions in this channel.", ["sub"] = "{sender.alias_name}: You have successfully subscribed to event %s", - ["unsub"] = "{sender.alias_name}: You have successfully unsubscribed from event %s" + ["unsub"] = "{sender.alias_name}: You have successfully unsubscribed from event %s", + ["not_subbed"] = "{sender.alias_name}: You were not subscribed to event %s" }, russian = { ["no_subcommand"] = @@ -61,6 +62,7 @@ local lines = { ["sub"] = "{sender.alias_name}: Вы успешно подписались на событие %s", ["unsub"] = "{sender.alias_name}: Вы отписались от события %s", + ["not_subbed"] = "{sender.alias_name}: Вы не были подписаны на событие %s" }, } @@ -183,7 +185,7 @@ WHERE e.channel_id = $1 AND es.user_id = $2 local events = db_query([[ SELECT e.id, es.id AS sub_id FROM events e -LEFT JOIN event_subscriptions es ON es.id = e.id AND es.user_id = $3 +LEFT JOIN event_subscriptions es ON es.event_id = e.id AND es.user_id = $3 WHERE e.name = $1 AND e.event_type = $2 ]], { data_name, data.type, request.sender.id }) @@ -204,6 +206,10 @@ WHERE e.name = $1 AND e.event_type = $2 return l10n_custom_formatted_line_request(request, lines, "sub", { data_original }) elseif scid == "unsub" then + if event.sub_id == nil then + return l10n_custom_formatted_line_request(request, lines, "not_subbed", { data_original }) + end + db_execute('DELETE FROM event_subscriptions WHERE id = $1', { event.sub_id }) return l10n_custom_formatted_line_request(request, lines, "unsub", { data_original }) end |
