Add password login and collection visibility settings
All checks were successful
Build plugin / build (push) Successful in 1m10s
All checks were successful
Build plugin / build (push) Successful in 1m10s
This commit is contained in:
parent
173aa94ea9
commit
e2a4464d0d
5 changed files with 218 additions and 26 deletions
|
|
@ -371,6 +371,21 @@ func _login_with_api_key(api_key: String) -> void:
|
|||
emit_signal.call_deferred("logged_in", LOGIN_STATUS.OK, profile)
|
||||
|
||||
|
||||
func login_with_password(username: String, password: String) -> void:
|
||||
await thread_group.exec(_login_with_password.bind(username, password))
|
||||
|
||||
|
||||
func _login_with_password(username: String, password: String) -> void:
|
||||
var res := await _rpc_call("Profile.LoginWithPassword", {"username": username, "password": password})
|
||||
if "error" in res:
|
||||
is_logged_in = false
|
||||
emit_signal.call_deferred("logged_in", LOGIN_STATUS.INVALID_KEY, {})
|
||||
return
|
||||
profile = res.get("profile", {})
|
||||
is_logged_in = true
|
||||
emit_signal.call_deferred("logged_in", LOGIN_STATUS.OK, profile)
|
||||
|
||||
|
||||
## Returns every game the logged-in profile owns a download key for.
|
||||
## Each item looks like: {"downloadKey": {...}, "game": {...}}
|
||||
func get_owned_games() -> Array:
|
||||
|
|
@ -429,6 +444,38 @@ func _get_collection_games() -> Array:
|
|||
)
|
||||
|
||||
|
||||
## Like get_collection_games, but returns {id, title, games} per collection
|
||||
## so the library can filter by collection visibility settings.
|
||||
func get_collection_groups() -> Array:
|
||||
return await thread_group.exec(_get_collection_groups)
|
||||
|
||||
|
||||
func _get_collection_groups() -> Array:
|
||||
if not is_logged_in:
|
||||
return []
|
||||
var params := {"profileId": profile.get("user", {}).get("id", profile.get("id", 0))}
|
||||
var res := await _rpc_call("Fetch.ProfileCollections", params)
|
||||
if "error" in res:
|
||||
return []
|
||||
if res.get("stale", false):
|
||||
params["fresh"] = true
|
||||
res = await _rpc_call("Fetch.ProfileCollections", params)
|
||||
if "error" in res:
|
||||
return []
|
||||
var collections: Array = res.get("items", [])
|
||||
var groups := []
|
||||
for c in collections:
|
||||
var collection: Dictionary = c
|
||||
var col_id: int = collection.get("id", 0)
|
||||
var col_title: String = collection.get("title", "")
|
||||
var games := await _fetch_collection_games(
|
||||
profile.get("user", {}).get("id", profile.get("id", 0)),
|
||||
[collection]
|
||||
)
|
||||
groups.append({"id": col_id, "title": col_title, "games": games})
|
||||
return groups
|
||||
|
||||
|
||||
## Paginates through Fetch.Collection.Games for every collection, collecting the
|
||||
## embedded game objects. Each collection can span multiple pages (cursor), and
|
||||
## a page served from butlerd's local cache is re-issued fresh.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue