mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-08-02 08:04:39 -05:00
database: Update database defaults and add country
This prevents errors when scanning the fields on the database
This commit is contained in:
parent
7aef2f1750
commit
f4a4b2830b
|
|
@ -13,7 +13,7 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) (*types.List[*fri
|
|||
persistentInfos.Type = friends_3ds_types.NewFriendPersistentInfo()
|
||||
|
||||
rows, err := database.Postgres.Query(`
|
||||
SELECT pid, region, area, language, favorite_title, favorite_title_version, comment, comment_changed, last_online, mii_changed FROM "3ds".user_data WHERE pid=ANY($1::int[])`, pq.Array(pids))
|
||||
SELECT pid, region, area, language, country, favorite_title, favorite_title_version, comment, comment_changed, last_online, mii_changed FROM "3ds".user_data WHERE pid=ANY($1::int[])`, pq.Array(pids))
|
||||
if err != nil {
|
||||
return persistentInfos, err
|
||||
}
|
||||
|
|
@ -28,6 +28,7 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) (*types.List[*fri
|
|||
var region uint8
|
||||
var area uint8
|
||||
var language uint8
|
||||
var country uint8
|
||||
var titleID uint64
|
||||
var titleVersion uint16
|
||||
var message string
|
||||
|
|
@ -37,11 +38,12 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) (*types.List[*fri
|
|||
|
||||
// * This is allowed to error for now.
|
||||
// * Some of these fields are optional, and the DB doesn't have defaults
|
||||
rows.Scan(
|
||||
err := rows.Scan(
|
||||
&pid,
|
||||
®ion,
|
||||
&area,
|
||||
&language,
|
||||
&country,
|
||||
&titleID,
|
||||
&titleVersion,
|
||||
&message,
|
||||
|
|
@ -49,13 +51,16 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) (*types.List[*fri
|
|||
&lastOnlineTime,
|
||||
&miiModifiedAtTime,
|
||||
)
|
||||
if err != nil {
|
||||
return persistentInfos, err
|
||||
}
|
||||
|
||||
gameKey.TitleID = types.NewPrimitiveU64(titleID)
|
||||
gameKey.TitleVersion = types.NewPrimitiveU16(titleVersion)
|
||||
|
||||
persistentInfo.PID = types.NewPID(uint64(pid))
|
||||
persistentInfo.Region = types.NewPrimitiveU8(region)
|
||||
persistentInfo.Country = types.NewPrimitiveU8(0) // TODO - What is this?
|
||||
persistentInfo.Country = types.NewPrimitiveU8(country)
|
||||
persistentInfo.Area = types.NewPrimitiveU8(area)
|
||||
persistentInfo.Language = types.NewPrimitiveU8(language)
|
||||
persistentInfo.Platform = types.NewPrimitiveU8(2) // * Always 3DS
|
||||
|
|
|
|||
|
|
@ -8,13 +8,14 @@ import (
|
|||
// UpdateUserProfile updates a user's profile
|
||||
func UpdateUserProfile(pid uint32, profileData *friends_3ds_types.MyProfile) error {
|
||||
_, err := database.Postgres.Exec(`
|
||||
INSERT INTO "3ds".user_data (pid, region, area, language)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
INSERT INTO "3ds".user_data (pid, region, area, language, country)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
ON CONFLICT (pid)
|
||||
DO UPDATE SET
|
||||
region = $2,
|
||||
area = $3,
|
||||
language = $4`, pid, profileData.Region.Value, profileData.Area.Value, profileData.Language.Value)
|
||||
language = $4,
|
||||
country = $5`, pid, profileData.Region.Value, profileData.Area.Value, profileData.Language.Value, profileData.Country.Value)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -17,17 +17,18 @@ func initPostgres3DS() {
|
|||
pid integer PRIMARY KEY,
|
||||
show_online boolean DEFAULT true,
|
||||
show_current_game boolean DEFAULT true,
|
||||
comment text,
|
||||
comment_changed bigint,
|
||||
last_online bigint,
|
||||
favorite_title bigint,
|
||||
favorite_title_version integer,
|
||||
mii_name text,
|
||||
mii_data bytea,
|
||||
mii_changed bigint,
|
||||
region integer,
|
||||
area integer,
|
||||
language integer
|
||||
comment text DEFAULT '',
|
||||
comment_changed bigint DEFAULT 0,
|
||||
last_online bigint DEFAULT 0,
|
||||
favorite_title bigint DEFAULT 0,
|
||||
favorite_title_version integer DEFAULT 0,
|
||||
mii_name text DEFAULT '',
|
||||
mii_data bytea DEFAULT '',
|
||||
mii_changed bigint DEFAULT 0,
|
||||
region integer DEFAULT 0,
|
||||
area integer DEFAULT 0,
|
||||
language integer DEFAULT 0,
|
||||
country integer DEFAULT 0
|
||||
)`)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ func initPostgresWiiU() {
|
|||
block_friend_requests boolean DEFAULT false,
|
||||
comment text DEFAULT '',
|
||||
comment_changed bigint DEFAULT 0,
|
||||
last_online bigint
|
||||
last_online bigint DEFAULT 0
|
||||
)`)
|
||||
if err != nil {
|
||||
globals.Logger.Critical(err.Error())
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user