momentum-mod / website

Momentum Mod's main website.
https://momentum-mod.org
MIT License
55 stars 60 forks source link

Import Steam friends into follows #897

Open tsa96 opened 5 months ago

tsa96 commented 5 months ago

Steam's API lets us fetch all of a user's Steam friends, so we can use that to automatically follow them.

Backend

Let's do a GET /user/steamfriends endpoint that uses the SteamService.getSteamFriends method to fetch Steam friends, then query DB for the matching SteamIDs. Then return an array of UserDto for every found user. A regular array is probably better than PagedResponseDto since we want to avoid calling Steam's API too often, and users can have at most 500 Steam friends. The likelihood that someone has more than ~100 friends with Momentum is always going to be pretty low.

Be sure to check out LeaderboardRunsService.getRuns to see an example of how to handle Steam friend data.

Then we'll want an endpoint for bulk following users. This can be at POST /user/follow and take an array (just CSV in the URL) of Momentum User IDs.

Frontend

Add a button with a Steam icon to the activity feed component that opens a new PrimeNG dialog component. It should contain a scrolling list of every user (<a> containing their avatar and alias) next to a checkbox, plus "Select All" and "Deselect All" buttons at the top right of the list. If >0 users are selected, enable a "Follow users" button that creates a POST /user/follow query on press, then closes the dialog.