Skip to content

Commit

Permalink
fix: api/v1/viewers to return proper username and displayName (#2607)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfw authored Jul 14, 2024
1 parent 64c4fae commit c4d084d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/backend/viewers/viewer-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,21 @@ class ViewerDatabase extends EventEmitter {
}
}

async getAllUsernamesWithIds(): Promise<{ id: string; username: string; }[]> {
async getAllUsernamesWithIds(): Promise<{ id: string; username: string; displayName: string; }[]> {
if (this.isViewerDBOn() !== true) {
return [];
}

const projectionObj = {
displayName: 1
displayName: 1,
username: 1
};

try {
const viewers = await this._db.findAsync({ twitch: true })
.projection(projectionObj);

return viewers?.map(u => ({ id: u._id, username: u.displayName })) ?? [];
return viewers?.map(u => ({ id: u._id, username: u.username, displayName: u.displayName })) ?? [];
} catch (error) {
logger.error("Error getting all viewers: ", error);
return [];
Expand Down

0 comments on commit c4d084d

Please sign in to comment.