Skip to content

getUserKarmaFromCurrentSubreddit should not require moderator permissions #244

@shrink

Description

@shrink

The getUserKarmaFromCurrentSubreddit method works when making the request as a moderator but not when making the request as a user. As a consequence, a user cannot get their own karma from the subreddit: an error is thrown. The behaviour is non-obvious (not documented in code, doesn't behave intuitively) so my guess is this is a bug on the reddit backend (?) i.e: the endpoint requires moderator permissions for all usernames without providing an exception for the authenticated user's username.

To reproduce: as a user (not moderator) access an app that uses getUserKarmaFromCurrentSubreddit() and receive this error:

Error: 7 PERMISSION_DENIED: only moderators can access user karma for subreddit

Discussed in Discord here: https://discord.com/channels/1050224141732687912/1050227353311248404/1458164688591388732

/**
* Returns the karma for this User in the current subreddit.
*
* @returns The GetUserKarmaForSubredditResponse, containing the user's karma for comments and posts in the subreddit.
*/
async getUserKarmaFromCurrentSubreddit(): Promise<GetUserKarmaForSubredditResponse> {
return await getRedditApiPlugins().Users.GetUserKarmaForSubreddit({
username: this.username,
subredditId: context.subredditId,
});
}

/**
* Returns the karma for a given user in the current subreddit.
*
* @param username - The username of the user to get the karma for. e.g. 'spez'
* @returns The GetUserKarmaForSubredditResponse, containing the user's karma for posts and comments in the subreddit.
*/
getUserKarmaFromCurrentSubreddit(username: string): Promise<GetUserKarmaForSubredditResponse> {
return User.getUserKarmaFromCurrentSubreddit(username);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions