Allow requesting multiple presence server users

This commit is contained in:
Samuel Elliott 2025-07-31 23:16:08 +01:00
parent 426f97ff6d
commit 3bfee7559f
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6

View File

@ -712,17 +712,18 @@ class Server extends HttpServer {
}
const query = new URL(req.originalUrl, 'http://localhost').searchParams;
const user_na_id = query.get('user');
const user_na_ids = query.has('user') ? query.getAll('user') : null;
const include_splatnet3 = this.splatnet3_users && query.get('include-splatoon3') === '1';
if (user_na_id && !this.user_ids.includes(user_na_id)) {
for (const user_na_id of user_na_ids ?? []) {
if (this.user_ids.includes(user_na_id)) continue;
debug('requested unknown user', user_na_id);
throw new ResponseError(400, 'invalid_request');
}
const result: AllUsersResult[] = [];
const user_ids = user_na_id ? [user_na_id] : this.user_ids;
const user_ids = user_na_ids ?? this.user_ids;
const user_ids_splatnet3 = this.user_ids_splatnet3.filter(id => user_ids.includes(id));
const users = await Promise.all(user_ids.map(id => this.getCoralUser(id)));