mirror of
https://github.com/PretendoNetwork/friends.git
synced 2025-04-02 11:01:46 -04:00
44 lines
1.7 KiB
Go
44 lines
1.7 KiB
Go
package nex_friends_3ds
|
|
|
|
import (
|
|
database_3ds "github.com/PretendoNetwork/friends/database/3ds"
|
|
"github.com/PretendoNetwork/friends/globals"
|
|
notifications_3ds "github.com/PretendoNetwork/friends/notifications/3ds"
|
|
nex "github.com/PretendoNetwork/nex-go/v2"
|
|
"github.com/PretendoNetwork/nex-go/v2/types"
|
|
friends_3ds "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds"
|
|
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/v2/friends-3ds/types"
|
|
)
|
|
|
|
func UpdatePreference(err error, packet nex.PacketInterface, callID uint32, publicMode types.Bool, showGame types.Bool, showPlayedGame types.Bool) (*nex.RMCMessage, *nex.Error) {
|
|
if err != nil {
|
|
globals.Logger.Error(err.Error())
|
|
return nil, nex.NewError(nex.ResultCodes.FPD.InvalidArgument, "") // TODO - Add error message
|
|
}
|
|
|
|
connection := packet.Sender().(*nex.PRUDPConnection)
|
|
|
|
err = database_3ds.UpdateUserPreferences(uint32(connection.PID()), bool(publicMode), bool(showGame))
|
|
if err != nil {
|
|
globals.Logger.Critical(err.Error())
|
|
return nil, nex.NewError(nex.ResultCodes.FPD.Unknown, "") // TODO - Add error message
|
|
}
|
|
|
|
if !showGame {
|
|
emptyPresence := friends_3ds_types.NewNintendoPresence()
|
|
emptyPresence.GameKey = friends_3ds_types.NewGameKey()
|
|
emptyPresence.ChangedFlags = types.NewUInt32(0xFFFFFFFF) // * All flags
|
|
notifications_3ds.SendPresenceUpdate(connection, emptyPresence)
|
|
}
|
|
|
|
if !publicMode {
|
|
notifications_3ds.SendUserWentOfflineGlobally(connection)
|
|
}
|
|
|
|
rmcResponse := nex.NewRMCSuccess(globals.SecureEndpoint, nil)
|
|
rmcResponse.ProtocolID = friends_3ds.ProtocolID
|
|
rmcResponse.MethodID = friends_3ds.MethodUpdatePreference
|
|
rmcResponse.CallID = callID
|
|
|
|
return rmcResponse, nil
|
|
}
|