-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: main
Are you sure you want to change the base?
Conversation
fdb80c7
to
70ce40d
Compare
const userCoinEntryText = `${leaderboardArray.length + 1}. ${userTag} - ${userCoinEntry.balance} ${getCoinEmoji()}`; | ||
const userTag = user?.tag; | ||
const displayTag = userTag && !isUserPrivate ? userTag : '<unknown>'; | ||
const userCoinEntryText = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope I got everything...
c33bba8
to
32eddcc
Compare
What's the motivation for wanting to not be seen on the leaderboard? It seems fairly innocuous |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nitpick
src/commandDetails/coin/privacy.ts
Outdated
import { getUserPrivacy, changeUserPrivacy } from '../../components/coin'; | ||
|
||
// Update coin leaderboard privacy of a user | ||
const coinUpdateExecuteCommand: SapphireMessageExecuteType = async (client, messageFromUser, args) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to coinPrivacyExecuteCommand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I just like my privacy. |
There was a problem hiding this 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.
src/commandDetails/coin/privacy.ts
Outdated
// 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.'); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/components/db.ts
Outdated
@@ -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)) |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOT NULL
removed
Probably would make more sense to have this be controlled by the |
I was thinking this is more an admin-only command |
32eddcc
to
6d03acc
Compare
Why should privacy be limited to admins only? |
Privacy shouldn't, but the ability to be set to private should? |
Why? It's just a user preference |
@Raymo111 I'm not sure if you saw my comment from earlier.
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. |
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? |
@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. |
Sounds good. I was wondering if you wanted to address this?
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. |
Alright! 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Just putting this here for the records, we would have to execute |
There was a problem hiding this 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, |
There was a problem hiding this comment.
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
Alright so change of plan, it looks like @Raymo111 will be implementing all of the changes in this PR. |
Yep and I'll also be integrating everything into profile. Marking this PR as WIP. |
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
becomes
Further Information and Comments
Ping me on Discord if you have any