Skip to content

Commit 57eab12

Browse files
committed
Ban revoke
Fixes #168
1 parent e9bb994 commit 57eab12

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ALTER TABLE ban
2+
ADD COLUMN revoke_reason TEXT,
3+
ADD COLUMN revoke_author_id MEDIUMINT UNSIGNED,
4+
ADD COLUMN revoke_time TIMESTAMP NULL DEFAULT NULL,
5+
ADD CONSTRAINT ban_revoke_author FOREIGN KEY (author_id) REFERENCES login (id);
6+
7+
UPDATE ban
8+
JOIN ban_revoke ON ban.id = ban_revoke.ban_id
9+
SET ban.revoke_reason = ban_revoke.reason,
10+
ban.revoke_author_id = ban_revoke.author_id,
11+
ban.revoke_time = ban_revoke.create_time;
12+
13+
ALTER VIEW lobby_ban AS
14+
select
15+
`ban`.`player_id` AS `idUser`,
16+
`ban`.`reason` AS `reason`,
17+
coalesce(`ban`.`revoke_time`, `ban`.`expires_at`, cast('2999-12-31' as date)) AS `expires_at`
18+
from `ban`
19+
where (`ban`.`level` <> 'CHAT');
20+
21+
DROP TABLE ban_revoke;

test-data.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ DELETE FROM updates_faf;
2626
DELETE FROM updates_faf_files;
2727
DELETE FROM avatars;
2828
DELETE FROM avatars_list;
29-
DELETE FROM ban_revoke;
3029
DELETE FROM ban;
3130
DELETE FROM clan_membership;
3231
DELETE FROM clan;
@@ -183,8 +182,9 @@ insert into ban(id, player_id, author_id, reason, level) values
183182
(2, 3, 1, 'This test ban should be revoked', 'CHAT');
184183
insert into ban(player_id, author_id, reason, level, expires_at) values
185184
(4, 1, 'This test ban should be expired', 'CHAT', NOW());
186-
insert into ban_revoke (ban_id, reason, author_id) values
187-
(2, 'I want to show that you can revoke the ban, but keep the data', 1);
185+
insert into ban (player_id, author_id, reason, level, expires_at, revoke_reason, revoke_author_id, revoke_time) values
186+
(4, 1, 'This test ban should be revoked', 'CHAT', DATE_ADD(NOW(), INTERVAL 1 YEAR), 'this was a test ban', 1,
187+
NOW());
188188

189189
-- sample clans
190190
insert into clan (id, name, tag, founder_id, leader_id, description) values

0 commit comments

Comments
 (0)