-
Notifications
You must be signed in to change notification settings - Fork 159
Storage Module Update + Action History (.json use / no dependencies) #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DukeOfCheese
wants to merge
31
commits into
Blumlaut:master
Choose a base branch
from
DukeOfCheese:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
035d8af
Adds a moderation action history into the player submenus without any…
DukeOfCheese aa3e543
Refactor action deletion logic to use action ID and improve action hi…
DukeOfCheese 5013313
Enhance action logging by adding detailed ban and unban information t…
DukeOfCheese 3305aaf
Normalize action names in logging: use consistent casing for actions …
DukeOfCheese 0c02a69
Add unban option to action history for banned players
DukeOfCheese 4fb2aaf
Implement ban storage functionality and integrate ban addition in off…
DukeOfCheese 6b5e511
Merge branch 'master' of https://github.com/DukeOfCheese/EasyAdmin
DukeOfCheese d1481ec
Update loading item text in action history menu for better localization
DukeOfCheese 3680508
Refactor action logging to ensure action history is recorded consiste…
DukeOfCheese 76355de
Update English localization for improved clarity and consistency
DukeOfCheese ed5b1eb
Merge branch 'Blumlaut:master' into master
DukeOfCheese 989b2c7
feat(storage): implement banlist and actions management functions
DukeOfCheese 73e1691
feat(storage): refactor ban and action management functions for impro…
DukeOfCheese 0156946
feat(storage): refactor action history management to utilize storage …
DukeOfCheese 0abecb4
Merge branch 'Blumlaut:master' into master
DukeOfCheese 8b0d481
feat(storage): add action logging functionality and permissions for a…
DukeOfCheese 4560358
Merge branch 'master' of https://github.com/DukeOfCheese/EasyAdmin
DukeOfCheese cd5ff0a
fix(warnPlayer): correct permission check logic for warning players
DukeOfCheese 74645cd
feat(action-logging): implement action logging for moderation events
DukeOfCheese df983c8
feat(storage): enhance storage functionality with new ban management …
DukeOfCheese 7c1af0b
fix(banlist, storage): remove unnecessary backticks and clarify updat…
DukeOfCheese b365a51
Merge branch 'master' into master
DukeOfCheese d670b3d
refactor(storage): remove unused notes variable and fix getBanlist fu…
DukeOfCheese ac60157
fix(gui): correct localization string for action history submenu
DukeOfCheese 9e6ba5f
fix(gui): correct string concatenation in action history submenu
DukeOfCheese f33334d
fix(gui): correct string concatenation in action history submenu
DukeOfCheese 5f1a07c
Merge branch 'master' of https://github.com/DukeOfCheese/EasyAdmin
DukeOfCheese 2e1a357
fix(kick): streamline action logging by using Storage for kick actions
DukeOfCheese f4e7c15
fix(ban): improve ban action logging and standardize identifier usage
DukeOfCheese ca31e92
fix(ban): update action logging to use discord identifiers for ban ac…
DukeOfCheese bb055dc
Merge branch 'master' into master
DukeOfCheese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
------------------------------------ | ||
------------------------------------ | ||
---- DONT TOUCH ANY OF THIS IF YOU DON'T KNOW WHAT YOU ARE DOING | ||
---- THESE ARE **NOT** CONFIG VALUES, USE THE CONVARS IF YOU WANT TO CHANGE SOMETHING | ||
---- | ||
---- | ||
---- If you are a developer and want to change something, consider writing a plugin instead: | ||
---- https://easyadmin.readthedocs.io/en/latest/plugins/ | ||
---- | ||
------------------------------------ | ||
------------------------------------ | ||
|
||
local actions = {} | ||
|
||
moderationNotification = GetConvar("ea_moderationNotification", "false") | ||
reportNotification = GetConvar("ea_reportNotification", "false") | ||
detailNotification = GetConvar("ea_detailNotification", "false") | ||
minimumMatchingIdentifierCount = GetConvarInt("ea_minIdentifierMatches", 2) | ||
|
||
RegisterNetEvent("EasyAdmin:GetActionHistory", function(discordId) | ||
if DoesPlayerHavePermission(source, "player.actionhistory.view") then | ||
if not discordId then | ||
PrintDebugMessage("No Discord ID provided, returning empty action history.", 2) | ||
TriggerClientEvent("EasyAdmin:ReceiveActionHistory", source, {}) | ||
return | ||
end | ||
local history = Storage.getAction(discordId) | ||
TriggerClientEvent("EasyAdmin:ReceiveActionHistory", source, history) | ||
else | ||
PrintDebugMessage("Player does not have permission to view action history.", 2) | ||
TriggerClientEvent("EasyAdmin:ReceiveActionHistory", source, {}) | ||
end | ||
end) | ||
|
||
RegisterNetEvent("EasyAdmin:LogAction", function(action) | ||
if DoesPlayerHavePermission(source, "player.actionhistory.add") then | ||
if not action then | ||
PrintDebugMessage("Action not defined.", 2) | ||
end | ||
Storage.addAction(action.type, action.discordId, action.reason, action.moderator, action.moderatorId, action.expire, action.expireString) | ||
PrintDebugMessage("Action logged successfully.", 2) | ||
end | ||
end) | ||
|
||
RegisterNetEvent("EasyAdmin:DeleteAction", function(actionId) | ||
if DoesPlayerHavePermission(source, "player.actionhistory.delete") then | ||
if not actionId then | ||
PrintDebugMessage("Invalid parameters provided for action deletion.", 2) | ||
return | ||
end | ||
Storage.removeAction(actionId) | ||
PrintDebugMessage("Action deleted successfully.", 2) | ||
local preferredWebhook = detailNotification ~= "false" and detailNotification or moderationNotification | ||
SendWebhookMessage(preferredWebhook, string.format(GetLocalisedText("actionhistorydeleted"), getName(source, false, true), actionId), "", 16777214) | ||
else | ||
PrintDebugMessage("Player does not have permission to delete actions.", 2) | ||
end | ||
end) | ||
|
||
-- MOVED TO STORAGE.LUA | ||
|
||
-- AddEventHandler("EasyAdmin:LogAction", function(data, remove, forceChange) | ||
-- if GetConvar("ea_enableActionHistory", "true") == "true" then | ||
-- local change = (forceChange or false) | ||
-- local content = LoadResourceFile(GetCurrentResourceName(), "actions.json") | ||
-- if not content then | ||
-- PrintDebugMessage("actions.json file was missing, we created a new one.", 2) | ||
-- local saved = SaveResourceFile(GetCurrentResourceName(), "actions.json", json.encode({}), -1) | ||
-- if not saved then | ||
-- PrintDebugMessage("^1Saving actions.json failed! Please check if EasyAdmin has Permission to write in its own folder!^7", 1) | ||
-- end | ||
-- content = json.encode({}) | ||
-- end | ||
-- actions = json.decode(content) | ||
|
||
-- if not actions then | ||
-- PrintDebugMessage("^1-^2-^3-^4-^5-^6-^8-^9-^1-^2-^3-^4-^5-^6-^8-^9-^1-^2-^3-^3!^1FATAL ERROR^3!^3-^2-^1-^9-^8-^6-^5-^4-^3-^2-^1-^9-^8-^6-^5-^4-^3-^2-^7\n") | ||
-- PrintDebugMessage("^1Failed^7 to load Actions!\n") | ||
-- PrintDebugMessage("Please check your actions file for errors, ^Action history *will not* work!^7\n") | ||
-- PrintDebugMessage("^1-^2-^3-^4-^5-^6-^8-^9-^1-^2-^3-^4-^5-^6-^8-^9-^1-^2-^3-^3!^1FATAL ERROR^3!^3-^2-^1-^9-^8-^6-^5-^4-^3-^2-^1-^9-^8-^6-^5-^4-^3-^2-^7\n") | ||
-- return | ||
-- end | ||
|
||
-- if data and not remove then | ||
-- if data.action == "BAN" then | ||
-- table.insert(actions, { | ||
-- time = os.time(), | ||
-- id = #actions + 1, | ||
-- banId = data.banId, | ||
-- action = data.action, | ||
-- discord = data.discord, | ||
-- reason = data.reason, | ||
-- moderator = data.moderator, | ||
-- moderatorId = data.moderatorId, | ||
-- expire = data.expire, | ||
-- expireString = data.expireString | ||
-- }) | ||
-- elseif data.action == "OFFLINE BAN" then | ||
-- table.insert(actions, { | ||
-- time = os.time(), | ||
-- id = #actions + 1, | ||
-- banId = data.banId, | ||
-- action = data.action, | ||
-- discord = data.discord, | ||
-- reason = data.reason, | ||
-- moderator = data.moderator, | ||
-- moderatorId = data.moderatorId, | ||
-- expire = data.expire, | ||
-- expireString = data.expireString | ||
-- }) | ||
-- elseif data.action == "KICK" then | ||
-- table.insert(actions, { | ||
-- time = os.time(), | ||
-- id = #actions + 1, | ||
-- action = data.action, | ||
-- discord = data.discord, | ||
-- reason = data.reason, | ||
-- moderator = data.moderator, | ||
-- moderatorId = data.moderatorId, | ||
-- }) | ||
-- elseif data.action == "WARN" then | ||
-- table.insert(actions, { | ||
-- time = os.time(), | ||
-- id = #actions + 1, | ||
-- action = data.action, | ||
-- discord = data.discord, | ||
-- reason = data.reason, | ||
-- moderator = data.moderator, | ||
-- moderatorId = data.moderatorId, | ||
-- }) | ||
-- elseif data.action == "UNBAN" then | ||
-- for i, act in ipairs(actions) do | ||
-- if act.banId == data.banId then | ||
-- act["action"] = data.action | ||
-- break | ||
-- end | ||
-- end | ||
-- end | ||
-- PrintDebugMessage("Added the following to actions:\n"..table_to_string(data), 4) | ||
-- change=true | ||
-- elseif not data then | ||
-- return | ||
-- end | ||
-- if data and remove then | ||
-- PrintDebugMessage("Removed the following data from actions:\n"..table_to_string(data), 4) | ||
-- change = true | ||
-- end | ||
-- if change then | ||
-- PrintDebugMessage("Actions changed, saving..", 4) | ||
-- local saved = SaveResourceFile(GetCurrentResourceName(), "actions.json", json.encode(actions, {indent = true}), -1) | ||
-- if not saved then | ||
-- PrintDebugMessage("^1Saving actions.json failed! Please check if EasyAdmin has Permission to write in its own folder!^7", 1) | ||
-- end | ||
-- end | ||
-- PrintDebugMessage("Completed Actions Updated.", 4) | ||
-- end | ||
-- end) | ||
|
||
for i, action in ipairs(actions) do | ||
if action.time + (GetConvar("ea_actionHistoryExpiry", 30) * 24 * 60 * 60) < os.time() then | ||
table.remove(actions, i) | ||
PrintDebugMessage("Removed expired action: " .. json.encode(action), 4) | ||
end | ||
end | ||
|
||
local change = (forceChange or false) | ||
local content = LoadResourceFile(GetCurrentResourceName(), "actions.json") | ||
if not content then | ||
PrintDebugMessage("actions.json file was missing, we created a new one.", 2) | ||
local saved = SaveResourceFile(GetCurrentResourceName(), "actions.json", json.encode({}), -1) | ||
if not saved then | ||
PrintDebugMessage("^1Saving actions.json failed! Please check if EasyAdmin has Permission to write in its own folder!^7", 1) | ||
end | ||
content = json.encode({}) | ||
end | ||
actions = json.decode(content) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.