-
Notifications
You must be signed in to change notification settings - Fork 162
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
Trading ban #2853
Open
SirSaltyy
wants to merge
17
commits into
main
Choose a base branch
from
trading-ban
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Trading ban #2853
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ba32955
prevent admins from trading sweepstakes
SirSaltyy e0dc418
rename banUser endpoint to banUserFromPosting
SirSaltyy 170e7ff
rename ban-user.ts file
SirSaltyy 7fa80ec
banUserFromTrading endpoint
SirSaltyy f0d27a3
Updated ban badges
SirSaltyy 8105dce
update trading ban and sign in logic
SirSaltyy 602e651
Stop banning acounts when deleted (they can't log in anymore)
SirSaltyy e4ca16f
update reports.tsx
SirSaltyy 4061d16
fixed badge positioning
SirSaltyy e8022e6
Merge branch 'main' into trading-ban
SirSaltyy 55eaa89
update place-bet.ts
SirSaltyy 68a1b3d
remove twitch bot updates
SirSaltyy 119b933
rename db to pg
SirSaltyy 7b7f498
seperate trading ban into mana and sweepcash
SirSaltyy 67f1c0b
add sweepcash ban logic
SirSaltyy 810b211
set Twomba enabled back to false
SirSaltyy 074f23b
Merge branch 'main' into trading-ban
SirSaltyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { APIError, authEndpoint, validate } from 'api/helpers/endpoint' | ||
import { z } from 'zod' | ||
import { trackPublicEvent } from 'shared/analytics' | ||
import { throwErrorIfNotMod } from 'shared/helpers/auth' | ||
import { isAdminId } from 'common/envs/constants' | ||
import { log } from 'shared/utils' | ||
import { createSupabaseDirectClient } from 'shared/supabase/init' | ||
import { updateUser } from 'shared/supabase/users' | ||
|
||
const bodySchema = z | ||
.object({ | ||
userId: z.string(), | ||
unban: z.boolean().optional(), | ||
}) | ||
.strict() | ||
|
||
export const banUserFromTrading = authEndpoint(async (req, auth) => { | ||
const { userId, unban } = validate(bodySchema, req.body) | ||
const db = createSupabaseDirectClient() | ||
await throwErrorIfNotMod(auth.uid) | ||
if (isAdminId(userId)) throw new APIError(403, 'Cannot ban admin') | ||
await trackPublicEvent(auth.uid, 'ban user from trading', { | ||
userId, | ||
}) | ||
await updateUser(db, userId, { | ||
isBannedFromTrading: !unban, | ||
}) | ||
log(`Updated trading ban status for user ${userId}`) | ||
return { success: true } | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SirSaltyy marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,7 @@ import { createUser } from 'web/lib/api/api' | |
import { randomString } from 'common/util/random' | ||
import { identifyUser, setUserProperty } from 'web/lib/service/analytics' | ||
import { useStateCheckEquality } from 'web/hooks/use-state-check-equality' | ||
import { | ||
AUTH_COOKIE_NAME, | ||
BANNED_TRADING_USER_IDS, | ||
TEN_YEARS_SECS, | ||
} from 'common/envs/constants' | ||
import { AUTH_COOKIE_NAME, TEN_YEARS_SECS } from 'common/envs/constants' | ||
import { getCookie, setCookie } from 'web/lib/util/cookie' | ||
import { | ||
type PrivateUser, | ||
|
@@ -114,12 +110,13 @@ export function AuthProvider(props: { | |
useEffect(() => { | ||
if (authUser) { | ||
if ( | ||
BANNED_TRADING_USER_IDS.includes(authUser.user.id) || | ||
(authUser.user.isBannedFromPosting && | ||
authUser.user.isBannedFromTrading) || | ||
authUser.user.userDeleted | ||
) { | ||
const message = authUser.user.userDeleted | ||
? 'You have deleted the account associated with this email. To restore your account please email [email protected]' | ||
: 'You are banned from trading. To learn more please email [email protected]' | ||
: 'You are banned from Manifold. To learn more please email [email protected]' | ||
|
||
firebaseLogout().then(() => { | ||
alert(message) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,15 +334,25 @@ export const updateMarket = curriedAPI('market/:contractId/update') | |
|
||
export const updateUser = curriedAPI('me/update') | ||
|
||
export function banUser(params: { userId: string; unban?: boolean }) { | ||
return call(getApiUrl('ban-user'), 'POST', params) | ||
export function banUserFromPosting(params: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't how we create api endpoints anymore, but I guess this is okay. In the future you should use the |
||
userId: string | ||
unban?: boolean | ||
}) { | ||
return call(getApiUrl('ban-user-from-posting'), 'POST', params) | ||
} | ||
export function createPrivateMessageChannelWithUsers(params: { | ||
userIds: string[] | ||
}) { | ||
return call(getApiUrl('create-private-user-message-channel'), 'POST', params) | ||
} | ||
|
||
export function banUserFromTrading(params: { | ||
userId: string | ||
unban?: boolean | ||
}) { | ||
return call(getApiUrl('ban-user-from-trading'), 'POST', params) | ||
} | ||
|
||
export function sendUserPrivateMessage(params: { | ||
channelId: number | ||
content: JSONContent | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
best to name properties in the positive valence, like
ban
rather thanunban