achievements-app / psn-api

A JavaScript library that lets you get trophy, user, and game data from the PlayStation Network.
https://psn-api.achievements.app
MIT License
265 stars 33 forks source link

Add a function to retrieve user presence #99

Closed wescopeland closed 1 year ago

wescopeland commented 1 year ago

Ref: https://github.com/FunkeyFlo/ps5-mqtt/blob/main/ps5-mqtt/server/src/psn-account.ts#L113

cc @FunkeyFlo Sometime this week I'll shoot to have this function added -- I'd like to first prioritize the "what's missing" bucket based on projects that are actively using psn-api and having to use workarounds

TheYuriG commented 1 year ago

I've tested the endpoint, which is honestly the simplest one to add (so I might as well PR this myself in a week or two) and it gives decent information, pulling data from both PS4 and PS5 online statuses. Can't talk about PS3 or Vita, didn't test those yet.

This is the data that is returned when the user is offline:

{
    "basicPresence": {
        "availability": "unavailable",
        "lastAvailableDate": "2023-02-06T05:43:38.019Z",
        "primaryPlatformInfo": {
            "onlineStatus": "offline",
            "platform": "PS5",
            "lastOnlineDate": "2023-02-06T05:43:38.019Z"
        }
    }
}

and this is the data when the user is online:

{
    "basicPresence": {
        "availability": "availableToPlay",
        "primaryPlatformInfo": {
            "onlineStatus": "online",
            "platform": "PS5",
            "lastOnlineDate": "2023-02-28T23:04:41.937Z"
        },
        "gameTitleInfoList": [
            {
                "npTitleId": "CUSA32853_00",
                "titleName": "THEATRHYTHM FINAL BAR LINE",
                "format": "ps4",
                "launchPlatform": "PS5",
                "npTitleIconUrl": "http://gs2-sec.ww.prod.dl.playstation.net/gs2-sec/appkgo/prod/CUSA32853_00/4/i_41661140eb4b3829075887f5dc48fddc015fb01cc8daacb171b37d6eeb5b37af/i/icon0.png"
            }
        ]
    }
}

Both were different users. I like how neither data can be traced back to the original users, as there is no PSN ID or accountId listed in either of them.

What's missing:

The only thing that I'm worried about from adding this is for library users to combine the "fetch all account friends" endpoint with this and then expose their friends' list status at all times on whatever public project they create.

Let's hope that won't happen though, and that people will abide by the warning of using "this project to elevate the PlayStation Network experience, not damage it" that Wes added to the Readme's disclaimer.

JenCrawford commented 1 year ago

Hi @TheYuriG did you PR this one in yet?

TheYuriG commented 1 year ago

Hi @TheYuriG did you PR this one in yet?

nope and not going to, feel free to work on it

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 2.10.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: