mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-03-21 18:04:11 -05:00
Add defaults to table and stop invalid blacklists
This commit is contained in:
parent
598a75f37d
commit
9bfb3d2474
|
|
@ -10,13 +10,13 @@ import (
|
|||
|
||||
// Update a user's last online time
|
||||
func UpdateUserLastOnlineTime(pid uint32, lastOnline *nex.DateTime) {
|
||||
var showOnline sql.NullBool
|
||||
var showOnline bool
|
||||
|
||||
err := database.Postgres.QueryRow(`SELECT show_online FROM "3ds".user_data WHERE pid=$1`, pid).Scan(&showOnline)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
globals.Logger.Critical(err.Error())
|
||||
}
|
||||
if showOnline.Valid && !showOnline.Bool {
|
||||
if !showOnline {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ func initPostgres3DS() {
|
|||
|
||||
_, err = Postgres.Exec(`CREATE TABLE IF NOT EXISTS "3ds".user_data (
|
||||
pid integer PRIMARY KEY,
|
||||
show_online boolean,
|
||||
show_current_game boolean,
|
||||
show_online boolean DEFAULT true,
|
||||
show_current_game boolean DEFAULT true,
|
||||
comment text,
|
||||
comment_changed bigint,
|
||||
last_online bigint,
|
||||
|
|
|
|||
|
|
@ -16,14 +16,38 @@ func AddBlacklist(err error, client *nex.Client, callID uint32, blacklistPrincip
|
|||
titleID := currentBlacklistPrincipal.GameKey.TitleID
|
||||
titleVersion := currentBlacklistPrincipal.GameKey.TitleVersion
|
||||
|
||||
database_wiiu.SetUserBlocked(client.PID(), senderPID, titleID, titleVersion)
|
||||
|
||||
date := nex.NewDateTime(0)
|
||||
date.FromTimestamp(time.Now())
|
||||
|
||||
currentBlacklistPrincipal.PrincipalBasicInfo = database_wiiu.GetUserInfoByPID(currentBlacklistPrincipal.PrincipalBasicInfo.PID)
|
||||
userInfo := database_wiiu.GetUserInfoByPID(currentBlacklistPrincipal.PrincipalBasicInfo.PID)
|
||||
|
||||
if userInfo == nil {
|
||||
rmcResponse := nex.NewRMCResponse(nexproto.FriendsWiiUProtocolID, callID)
|
||||
rmcResponse.SetError(nex.Errors.FPD.FriendNotExists) // TODO: Not sure if this is the correct error.
|
||||
|
||||
rmcResponseBytes := rmcResponse.Bytes()
|
||||
|
||||
responsePacket, _ := nex.NewPacketV0(client, nil)
|
||||
|
||||
responsePacket.SetVersion(0)
|
||||
responsePacket.SetSource(0xA1)
|
||||
responsePacket.SetDestination(0xAF)
|
||||
responsePacket.SetType(nex.DataPacket)
|
||||
responsePacket.SetPayload(rmcResponseBytes)
|
||||
|
||||
responsePacket.AddFlag(nex.FlagNeedsAck)
|
||||
responsePacket.AddFlag(nex.FlagReliable)
|
||||
|
||||
globals.NEXServer.Send(responsePacket)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
currentBlacklistPrincipal.PrincipalBasicInfo = userInfo
|
||||
currentBlacklistPrincipal.BlackListedSince = date
|
||||
|
||||
database_wiiu.SetUserBlocked(client.PID(), senderPID, titleID, titleVersion)
|
||||
|
||||
rmcResponseStream := nex.NewStreamOut(globals.NEXServer)
|
||||
|
||||
rmcResponseStream.WriteStructure(blacklistPrincipal)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user