Update FriendPersistentInfo on 3DS

One of the DateTimes doesn't represent the date of the friendship, but
when the friend has updated their Mii.

I noticed this when playing with the friend servers researching
information about the data stored on the FRD sysmodule.

The friendship date is still stored internally, but it's not provided to
the user anymore.
This commit is contained in:
Daniel López Guimaraes
2023-10-08 19:24:58 +01:00
parent 73871a4537
commit 3f48ae8306
3 changed files with 37 additions and 46 deletions

View File

@@ -1,8 +1,6 @@
package database_3ds
import (
"database/sql"
"github.com/PretendoNetwork/friends/database"
"github.com/PretendoNetwork/nex-go"
friends_3ds_types "github.com/PretendoNetwork/nex-protocols-go/friends-3ds/types"
@@ -14,7 +12,7 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) ([]*friends_3ds_t
persistentInfos := make([]*friends_3ds_types.FriendPersistentInfo, 0)
rows, err := database.Postgres.Query(`
SELECT pid, region, area, language, favorite_title, favorite_title_version, comment, comment_changed, last_online FROM "3ds".user_data WHERE pid=ANY($1::int[])`, pq.Array(pids))
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))
if err != nil {
return persistentInfos, err
}
@@ -26,24 +24,14 @@ func GetFriendPersistentInfos(user1_pid uint32, pids []uint32) ([]*friends_3ds_t
var lastOnlineTime uint64
var msgUpdateTime uint64
var friendedAtTime uint64
var miiModifiedAtTime uint64
rows.Scan(
&persistentInfo.PID, &persistentInfo.Region, &persistentInfo.Area, &persistentInfo.Language,
&gameKey.TitleID, &gameKey.TitleVersion, &persistentInfo.Message, &msgUpdateTime, &lastOnlineTime)
err = database.Postgres.QueryRow(`
SELECT date FROM "3ds".friendships WHERE user1_pid=$1 AND user2_pid=$2 AND type=0 LIMIT 1`, user1_pid, persistentInfo.PID).Scan(&friendedAtTime)
if err != nil {
if err == sql.ErrNoRows {
return nil, database.ErrFriendshipNotFound
} else {
return nil, err
}
}
&gameKey.TitleID, &gameKey.TitleVersion, &persistentInfo.Message, &msgUpdateTime, &lastOnlineTime, &miiModifiedAtTime)
persistentInfo.MessageUpdatedAt = nex.NewDateTime(msgUpdateTime)
persistentInfo.FriendedAt = nex.NewDateTime(friendedAtTime)
persistentInfo.MiiModifiedAt = nex.NewDateTime(miiModifiedAtTime)
persistentInfo.LastOnline = nex.NewDateTime(lastOnlineTime)
persistentInfo.GameKey = gameKey
persistentInfo.Platform = 2 // Always 3DS