Skip to content

Commit 40ef96b

Browse files
Bugfix #68
Fixed the bug described in #68 where the ban import would fail if the user was not previously created in our database
1 parent 50e9785 commit 40ef96b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lua/msync/server/modules/sv_mbsync.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,29 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
660660
- Create User
661661
- Create ban query
662662
]]
663+
--[[
664+
Add user transaction
665+
]]
666+
transactions[k..'_user'] = MSync.DBServer:prepare( [[
667+
INSERT INTO `tbl_users` (steamid, steamid64, nickname, joined)
668+
VALUES (?, ?, ?, ?)
669+
ON DUPLICATE KEY UPDATE steamid=steamid;
670+
]] )
671+
transactions[k..'_user']:setString(1, k)
672+
transactions[k..'_user']:setString(2, util.SteamIDTo64( k ))
673+
if ULib.ucl.users[k] then
674+
transactions[k..'_user']:setString(3, ULib.ucl.users[k].name or 'None Given')
675+
else
676+
transactions[k..'_user']:setString(3, 'None Given')
677+
end
678+
transactions[k..'_user']:setString(4, os.date("%Y-%m-%d %H:%M:%S", os.time()))
679+
680+
banTransaction:addQuery(transactions[k..'_user'])
681+
MSync.log(MSYNC_DBG_DEBUG, "[MBSync] Import Bans: added create user transaction for: " .. k)
682+
683+
--[[
684+
Add ban transaction
685+
]]
663686
transactions[k] = MSync.DBServer:prepare( [[
664687
INSERT INTO `tbl_mbsync` (user_id, admin_id, reason, date_unix, length_unix, server_group)
665688
VALUES (
@@ -703,6 +726,7 @@ MSync.modules[info.ModuleIdentifier].init = function( transaction )
703726

704727
banTransaction:addQuery(transactions[k])
705728
MSync.log(MSYNC_DBG_INFO, "[MBSync] Imported ban for SteamID: " .. k)
729+
MSync.log(MSYNC_DBG_DEBUG, "[MBSync] Import Bans: added create ban transaction for: " .. k)
706730
end
707731

708732
banTransaction.onSuccess = function()

0 commit comments

Comments
 (0)