mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-18 14:53:13 +09:00
Add the exp_reports plugin and move the scenario onto it
Reports were the last legacy control module, kept in the lua state of each instance. They are now an exp_reports plugin which stores them on the controller: a report is immutable and holds the reported player, who made it, the reason, the instance name and when it was made, and the only operations are get, list, create and delete. In game nothing is stored. The lua module sends each request over ipc, the instance plugin asks the controller and hands the answer back with rcon, and the module prints it to whoever asked if they are still online. Answers are dropped if the instance stopped meanwhile. The module raises on_player_reported with the count and reporters of every report against the player, which report_jail and discord_alerts use, and the commands and player list button call into it. The web ui gets a /reports page: a table with search on the player, reporter and reason, a filter on the instance, delete per row and a create form which reports in the name of the web user. New reports are posted to two optional webhooks configured on the controller, a Discord channel hook as an embed and a generic JSON hook. Failures are logged rather than failing the report. Tests cover the messages, the controller against a real Controller, the instance plugin against a real Instance, and the lua module through the shared harness.
This commit is contained in:
1 parent
142d296a02
commit
bad98c5013
35 files changed
+1707
-350
No files matched your search
@@ -0,0 +1,34 @@
|
||||
local Suite = ... --- @type Suite<ExpReports.TestEnv>
|
||||
|
||||
Suite.test("create_report() sends the report to the controller", function(env)
|
||||
local alice = env.add_player("alice")
|
||||
local bob = env.add_player("bob")
|
||||
env.Reports.create_report(alice, bob, "griefing")
|
||||
Suite.eq(env.sent, {
|
||||
{ channel = "exp_reports:create", data = { player_name = "bob", by_player_name = "alice", reason = "griefing" } },
|
||||
}, "the report names both players")
|
||||
end)
|
||||
|
||||
Suite.test("list_reports() sends the caller and the player", function(env)
|
||||
local alice = env.add_player("alice")
|
||||
local bob = env.add_player("bob")
|
||||
env.Reports.list_reports(alice, bob)
|
||||
env.Reports.list_reports(alice)
|
||||
Suite.eq(env.sent, {
|
||||
{ channel = "exp_reports:list", data = { caller = "alice", player_name = "bob" } },
|
||||
{ channel = "exp_reports:list", data = { caller = "alice" } },
|
||||
}, "the player is left out when listing everyone")
|
||||
end)
|
||||
|
||||
Suite.test("delete_reports() sends the caller, the player and the reporter", function(env)
|
||||
local alice = env.add_player("alice")
|
||||
local bob = env.add_player("bob")
|
||||
env.Reports.delete_reports(alice, bob, "carol")
|
||||
env.Reports.delete_reports(alice, bob)
|
||||
Suite.eq(env.sent, {
|
||||
{ channel = "exp_reports:delete", data = { caller = "alice", player_name = "bob", by_player_name = "carol" } },
|
||||
{ channel = "exp_reports:delete", data = { caller = "alice", player_name = "bob" } },
|
||||
}, "the reporter is left out when deleting every report")
|
||||
end)
|
||||
|
||||
return Suite.run()
|
||||
Reference in new issue
Block a user