Skip to content

WIP: Allow for user privacy (opt out of leaderboard) #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Raymo111
Copy link
Member

@Raymo111 Raymo111 commented Aug 19, 2022

Closes #333

Summary of Changes

Add a privacy option (is_private column in the coin DB to prevent showing on the leaderboard)

Motivation and Explanation

I don't want to be shown on the leaderboard

Related Issues/Steps to Reproduce

DB needs to have an additional column added

Demonstration of Changes

image
becomes
Screenshot_20220819_020537

Further Information and Comments

Ping me on Discord if you have any

@Raymo111 Raymo111 added feature New feature enhancement Improvements on existing work labels Aug 19, 2022
@Raymo111 Raymo111 force-pushed the feat/raymo/privacy branch from fdb80c7 to 70ce40d Compare August 19, 2022 06:16
const userCoinEntryText = `${leaderboardArray.length + 1}. ${userTag} - ${userCoinEntry.balance} ${getCoinEmoji()}`;
const userTag = user?.tag;
const displayTag = userTag && !isUserPrivate ? userTag : '<unknown>';
const userCoinEntryText =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lint

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

export const getPrivateUserIdList = async (userId: string): Promise<number> => {
const db = await openDB();
// Query user privacy from DB.
const res = await db.get('SELECT is_private FROM user_coin WHERE user_id = ?', userId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corresponding update statement for how ppl can set that they wanna be private?
also might need to change DB schema code for new column

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope I got everything...

@Raymo111 Raymo111 force-pushed the feat/raymo/privacy branch 4 times, most recently from c33bba8 to 32eddcc Compare August 19, 2022 06:50
@hydrobeam
Copy link
Contributor

What's the motivation for wanting to not be seen on the leaderboard? It seems fairly innocuous

Copy link
Contributor

@mcpenguin mcpenguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick

import { getUserPrivacy, changeUserPrivacy } from '../../components/coin';

// Update coin leaderboard privacy of a user
const coinUpdateExecuteCommand: SapphireMessageExecuteType = async (client, messageFromUser, args) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to coinPrivacyExecuteCommand

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@Raymo111
Copy link
Member Author

What's the motivation for wanting to not be seen on the leaderboard? It seems fairly innocuous

I just like my privacy.

Copy link
Contributor

@Picowchew Picowchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this command is currently admin-only and the admin has to specify the user. Should the command usage be changed such that any user would be able to toggle their own privacy?

Note that a user can still check your coin balance with the .coin check command or through your user profile (if you create one). Did you want privacy for these as well? If so, new issues can be created and later tackled in other PRs.

// First mandatory argument is user
const user = <User>args['user'];
if (!user) {
throw new Error('please enter a valid user mention or ID for balance adjustment.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace balance adjustment with leaderboard privacy update?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -92,7 +92,8 @@ const initUserCoinTable = async (db: Database): Promise<void> => {
`
CREATE TABLE IF NOT EXISTS user_coin (
user_id VARCHAR(255) PRIMARY KEY NOT NULL,
balance INTEGER NOT NULL CHECK(balance>=0)
balance INTEGER NOT NULL CHECK(balance>=0),
is_private INTEGER NOT NULL CHECK(is_private IN (0, 1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we should either add DEFAULT 0 or remove NOT NULL because changeDbCoinBalanceByUserId does not set a value for is_private.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOT NULL removed

@hydrobeam
Copy link
Contributor

hydrobeam commented Aug 19, 2022

Probably would make more sense to have this be controlled by the profile command rather than be set by a separate command imo

@Raymo111
Copy link
Member Author

Probably would make more sense to have this be controlled by the profile command rather than be set by a separate command imo

I was thinking this is more an admin-only command

@hydrobeam
Copy link
Contributor

I was thinking this is more an admin-only command

Why should privacy be limited to admins only?

@Raymo111
Copy link
Member Author

I was thinking this is more an admin-only command

Why should privacy be limited to admins only?

Privacy shouldn't, but the ability to be set to private should?

@hydrobeam
Copy link
Contributor

Privacy shouldn't, but the ability to be set to private should?

Why? It's just a user preference

@Picowchew
Copy link
Contributor

@Raymo111 I'm not sure if you saw my comment from earlier.

It looks like this command is currently admin-only and the admin has to specify the user. Should the command usage be changed such that any user would be able to toggle their own privacy?

Note that a user can still check your coin balance with the .coin check command or through your user profile (if you create one). Did you want privacy for these as well? If so, new issues can be created and later tackled in other PRs.

As for the privacy toggle, suppose a user wants to be private. They would have to tell an admin to toggle it for them. I don't really see a reason why an admin would deny their request, so shouldn't we just let any user toggle their own privacy?

If you'd like, we could get this PR merged in, and then have a separate issue and PR that would enable any user to be able to change their own privacy?

@Raymo111
Copy link
Member Author

@Raymo111 I'm not sure if you saw my comment from earlier.

It looks like this command is currently admin-only and the admin has to specify the user. Should the command usage be changed such that any user would be able to toggle their own privacy?
Note that a user can still check your coin balance with the .coin check command or through your user profile (if you create one). Did you want privacy for these as well? If so, new issues can be created and later tackled in other PRs.

As for the privacy toggle, suppose a user wants to be private. They would have to tell an admin to toggle it for them. I don't really see a reason why an admin would deny their request, so shouldn't we just let any user toggle their own privacy?

If you'd like, we could get this PR merged in, and then have a separate issue and PR that would enable any user to be able to change their own privacy?

Actually I see your point. I'll just make the code change to let any user do it, it should just be deleting one line.

@Picowchew
Copy link
Contributor

I don't think it's deleting one line because won't that make any user be able to change the privacy of any other user?

@Raymo111
Copy link
Member Author

@Raymo111 I'm not sure if you saw my comment from earlier.

It looks like this command is currently admin-only and the admin has to specify the user. Should the command usage be changed such that any user would be able to toggle their own privacy?
Note that a user can still check your coin balance with the .coin check command or through your user profile (if you create one). Did you want privacy for these as well? If so, new issues can be created and later tackled in other PRs.

As for the privacy toggle, suppose a user wants to be private. They would have to tell an admin to toggle it for them. I don't really see a reason why an admin would deny their request, so shouldn't we just let any user toggle their own privacy?
If you'd like, we could get this PR merged in, and then have a separate issue and PR that would enable any user to be able to change their own privacy?

Actually I see your point. I'll just make the code change to let any user do it, it should just be deleting one line.

@Picowchew Actually I take that back, looks like it'll be a whole new thing. I've made #334 to cover that, let's get this one in first.

@Picowchew
Copy link
Contributor

Sounds good. I was wondering if you wanted to address this?

Note that a user can still check your coin balance with the .coin check command or through your user profile (if you create one). Did you want privacy for these as well? If so, new issues can be created and later tackled in other PRs.

Just a yes/no would be good.

@Raymo111
Copy link
Member Author

Sounds good. I was wondering if you wanted to address this?

Note that a user can still check your coin balance with the .coin check command or through your user profile (if you create one). Did you want privacy for these as well? If so, new issues can be created and later tackled in other PRs.

Just a yes/no would be good.

Sorry, I keep missing that. I don't see that as a problem, this is specifically for the leaderboard showing all the users to not show private users.

@Picowchew
Copy link
Contributor

Alright! 👍

Copy link
Contributor

@Picowchew Picowchew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@mcpenguin mcpenguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Picowchew
Copy link
Contributor

Just putting this here for the records, we would have to execute ALTER TABLE user_coin ADD COLUMN is_private INTEGER CHECK(is_private IN (0, 1)); to change the schema of the existing table.

Copy link
Contributor

@hydrobeam hydrobeam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment +

@Picowchew Actually I take that back, looks like it'll be a whole new thing. I've made #334 to cover that, let's get this one in first.

Why not just handle it in this PR if the code's going to be rewritten immediately after merging? Also, if you go with the approach with checking the user profile for the boolean, then you could avoid unnecessarily changing the schema

{
name: 'privacy',
description: 'The privacy to set the specified user to,',
type: CodeyCommandOptionType.NUMBER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would make more sense as a CodeyCommandOptionType.BOOLEAN

@Picowchew
Copy link
Contributor

Alright so change of plan, it looks like @Raymo111 will be implementing all of the changes in this PR.

@Raymo111
Copy link
Member Author

Yep and I'll also be integrating everything into profile. Marking this PR as WIP.

@Raymo111 Raymo111 changed the title Allow for user privacy (opt out of leaderboard) WIP: Allow for user privacy (opt out of leaderboard) Aug 19, 2022
@Raymo111 Raymo111 marked this pull request as draft August 20, 2022 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements on existing work feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Option for privacy from leaderboard
5 participants