mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-08-01 19:02:58 -04:00
Add suspicious user limitations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {type JSONContent} from '@tiptap/core'
|
||||
import {APIErrors, APIHandler} from 'api/helpers/endpoint'
|
||||
import {isSuspiciousId} from 'common/moderation/suspicious'
|
||||
import {Notification} from 'common/notifications'
|
||||
import {convertComment} from 'common/supabase/comment'
|
||||
import {type Row} from 'common/supabase/utils'
|
||||
@@ -56,6 +57,7 @@ const validateComment = async (userId: string, creatorId: string, content: JSONC
|
||||
|
||||
if (!creator) throw APIErrors.unauthorized('Your account was not found')
|
||||
if (creator.isBannedFromPosting) throw APIErrors.forbidden('You are banned')
|
||||
if (isSuspiciousId(creator.id)) throw APIErrors.forbidden('Suspicious users cannot send messages')
|
||||
|
||||
const otherUser = await getPrivateUser(userId)
|
||||
if (!otherUser) throw APIErrors.notFound('Other user not found')
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {MAX_COMMENT_JSON_LENGTH} from 'api/create-comment'
|
||||
import {APIErrors, APIHandler} from 'api/helpers/endpoint'
|
||||
import {createPrivateUserMessageMain} from 'api/helpers/private-messages'
|
||||
import {isSuspiciousId} from 'common/moderation/suspicious'
|
||||
import {createSupabaseDirectClient} from 'shared/supabase/init'
|
||||
import {getUser} from 'shared/utils'
|
||||
|
||||
@@ -16,6 +17,7 @@ export const createPrivateUserMessage: APIHandler<'create-private-user-message'>
|
||||
const creator = await getUser(auth.uid)
|
||||
if (!creator) throw APIErrors.unauthorized('Your account was not found')
|
||||
if (creator.isBannedFromPosting) throw APIErrors.forbidden('You are banned')
|
||||
if (isSuspiciousId(creator.id)) throw APIErrors.forbidden('Suspicious users cannot send messages')
|
||||
|
||||
const pg = createSupabaseDirectClient()
|
||||
return await createPrivateUserMessageMain(creator, channelId, content, pg, 'private')
|
||||
|
||||
Reference in New Issue
Block a user