From 39be868a4fd3d1d5e03c27a651190a6713dae0fd Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Fri, 21 Nov 2025 14:34:33 +0000 Subject: [PATCH 1/2] Add `RichPresenceUpdated` to `API_GetUserSummary.php` --- app/Helpers/database/user.php | 1 + public/API/API_GetUserSummary.php | 1 + tests/Feature/Api/V1/UserSummaryTest.php | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/app/Helpers/database/user.php b/app/Helpers/database/user.php index 998b687ecd..006077399a 100644 --- a/app/Helpers/database/user.php +++ b/app/Helpers/database/user.php @@ -61,6 +61,7 @@ function getUserPageInfo(string $username, int $numGames = 0, int $numRecentAchi $libraryOut['MemberSince'] = $user->created_at->__toString(); $libraryOut['LastActivity'] = $user->LastLogin?->__toString(); $libraryOut['RichPresenceMsg'] = empty($user->RichPresenceMsg) || $user->RichPresenceMsg === 'Unknown' ? null : $user->RichPresenceMsg; + $libraryOut['RichPresenceUpdated'] = $user->RichPresenceMsgDate?->__toString(); $libraryOut['LastGameID'] = (int) $user->LastGameID; $libraryOut['ContribCount'] = (int) $user->ContribCount; $libraryOut['ContribYield'] = (int) $user->ContribYield; diff --git a/public/API/API_GetUserSummary.php b/public/API/API_GetUserSummary.php index d3fc677af0..1ce89257d1 100644 --- a/public/API/API_GetUserSummary.php +++ b/public/API/API_GetUserSummary.php @@ -42,6 +42,7 @@ * string? ReleasedAtGranularity how precise the Released value is. possible values are "day", "month", "year", and null. * int IsFinal deprecated, will always be 0 * string RichPresenceMsg activity information about the last game the user played + * datetime RichPresenceUpdated when the RichPresenceMsg was last updated * int RecentlyPlayedCount number of items in the RecentlyPlayed array * array RecentlyPlayed * int GameID unique identifier of the game diff --git a/tests/Feature/Api/V1/UserSummaryTest.php b/tests/Feature/Api/V1/UserSummaryTest.php index adc422566e..5572edba8f 100644 --- a/tests/Feature/Api/V1/UserSummaryTest.php +++ b/tests/Feature/Api/V1/UserSummaryTest.php @@ -72,6 +72,7 @@ public function testGetUserSummaryNoGameHistoryByName(): void 'TotalRanked' => 0, 'LastGameID' => null, 'RichPresenceMsg' => null, + 'RichPresenceUpdated' => null, 'RecentlyPlayedCount' => 0, 'RecentlyPlayed' => [], ]); @@ -104,6 +105,7 @@ public function testGetUserSummaryNoGameHistoryByUlid(): void 'TotalRanked' => 0, 'LastGameID' => null, 'RichPresenceMsg' => null, + 'RichPresenceUpdated' => null, 'RecentlyPlayedCount' => 0, 'RecentlyPlayed' => [], ]); @@ -221,6 +223,7 @@ public function testGetUserSummary(): void 'TotalRanked' => 2, // $this->user and $user 'LastGameID' => $game->id, 'RichPresenceMsg' => 'Playing ' . $game->title, + 'RichPresenceUpdated' => Carbon::now()->__toString(), 'RecentlyPlayedCount' => 0, 'RecentlyPlayed' => [], 'LastActivity' => [ @@ -275,6 +278,7 @@ public function testGetUserSummary(): void 'ReleasedAtGranularity' => $game->released_at_granularity->value, ], 'RichPresenceMsg' => 'Playing ' . $game->title, + 'RichPresenceUpdated' => Carbon::now()->__toString(), 'RecentlyPlayedCount' => 2, 'RecentlyPlayed' => [ [ @@ -388,6 +392,7 @@ public function testGetUserSummary(): void 'ReleasedAtGranularity' => $game->released_at_granularity->value, ], 'RichPresenceMsg' => 'Playing ' . $game->title, + 'RichPresenceUpdated' => Carbon::now()->__toString(), 'RecentlyPlayedCount' => 1, 'RecentlyPlayed' => [ [ From aaed95e7da39e8e570dc3d1059f41d451f29cfb6 Mon Sep 17 00:00:00 2001 From: Miguel Piedrafita Date: Sat, 22 Nov 2025 15:10:51 +0000 Subject: [PATCH 2/2] nit: rename `RichPresenceUpdated` field to `RichPresenceMsgDate` --- app/Helpers/database/user.php | 2 +- tests/Feature/Api/V1/UserSummaryTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Helpers/database/user.php b/app/Helpers/database/user.php index 006077399a..3c3ddc7682 100644 --- a/app/Helpers/database/user.php +++ b/app/Helpers/database/user.php @@ -61,7 +61,7 @@ function getUserPageInfo(string $username, int $numGames = 0, int $numRecentAchi $libraryOut['MemberSince'] = $user->created_at->__toString(); $libraryOut['LastActivity'] = $user->LastLogin?->__toString(); $libraryOut['RichPresenceMsg'] = empty($user->RichPresenceMsg) || $user->RichPresenceMsg === 'Unknown' ? null : $user->RichPresenceMsg; - $libraryOut['RichPresenceUpdated'] = $user->RichPresenceMsgDate?->__toString(); + $libraryOut['RichPresenceMsgDate'] = $user->RichPresenceMsgDate?->__toString(); $libraryOut['LastGameID'] = (int) $user->LastGameID; $libraryOut['ContribCount'] = (int) $user->ContribCount; $libraryOut['ContribYield'] = (int) $user->ContribYield; diff --git a/tests/Feature/Api/V1/UserSummaryTest.php b/tests/Feature/Api/V1/UserSummaryTest.php index 5572edba8f..ce2f96de81 100644 --- a/tests/Feature/Api/V1/UserSummaryTest.php +++ b/tests/Feature/Api/V1/UserSummaryTest.php @@ -72,7 +72,7 @@ public function testGetUserSummaryNoGameHistoryByName(): void 'TotalRanked' => 0, 'LastGameID' => null, 'RichPresenceMsg' => null, - 'RichPresenceUpdated' => null, + 'RichPresenceMsgDate' => null, 'RecentlyPlayedCount' => 0, 'RecentlyPlayed' => [], ]); @@ -105,7 +105,7 @@ public function testGetUserSummaryNoGameHistoryByUlid(): void 'TotalRanked' => 0, 'LastGameID' => null, 'RichPresenceMsg' => null, - 'RichPresenceUpdated' => null, + 'RichPresenceMsgDate' => null, 'RecentlyPlayedCount' => 0, 'RecentlyPlayed' => [], ]); @@ -223,7 +223,7 @@ public function testGetUserSummary(): void 'TotalRanked' => 2, // $this->user and $user 'LastGameID' => $game->id, 'RichPresenceMsg' => 'Playing ' . $game->title, - 'RichPresenceUpdated' => Carbon::now()->__toString(), + 'RichPresenceMsgDate' => Carbon::now()->__toString(), 'RecentlyPlayedCount' => 0, 'RecentlyPlayed' => [], 'LastActivity' => [ @@ -278,7 +278,7 @@ public function testGetUserSummary(): void 'ReleasedAtGranularity' => $game->released_at_granularity->value, ], 'RichPresenceMsg' => 'Playing ' . $game->title, - 'RichPresenceUpdated' => Carbon::now()->__toString(), + 'RichPresenceMsgDate' => Carbon::now()->__toString(), 'RecentlyPlayedCount' => 2, 'RecentlyPlayed' => [ [ @@ -392,7 +392,7 @@ public function testGetUserSummary(): void 'ReleasedAtGranularity' => $game->released_at_granularity->value, ], 'RichPresenceMsg' => 'Playing ' . $game->title, - 'RichPresenceUpdated' => Carbon::now()->__toString(), + 'RichPresenceMsgDate' => Carbon::now()->__toString(), 'RecentlyPlayedCount' => 1, 'RecentlyPlayed' => [ [