Compare commits
5 Commits
release-20
...
release-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4806a7fd4e | ||
|
|
85605de8aa | ||
|
|
7a22629c55 | ||
|
|
8deb9acb93 | ||
|
|
61a5448ff5 |
@@ -29,7 +29,7 @@ npm run db-fill-clean
|
||||
|
||||
Now open the [.env](web/.env) file and fill in the missing values.
|
||||
|
||||
> Default users are created with tokens: `admin`, `verifier`, `verified`, `normal` (configurable via env vars)
|
||||
> Default users are created with tokens: `admin`, `moderator`, `verified`, `normal` (configurable via env vars)
|
||||
|
||||
### Running the project
|
||||
|
||||
|
||||
@@ -26,4 +26,4 @@ All commands are run from the root of the project, from a terminal:
|
||||
|
||||
> **Note**: `db-fill` and `db-fill-clean` support the `-- --services=n` flag, where n is the number of fake services to add. It defaults to 10. For example, `npm run db-fill -- --services=5` will add 5 fake services.
|
||||
|
||||
> **Note**: `db-fill` and `db-fill-clean` create default users with tokens: `admin`, `verifier`, `verified`, `normal` (override with `DEV_*****_USER_SECRET_TOKEN` env vars)
|
||||
> **Note**: `db-fill` and `db-fill-clean` create default users with tokens: `admin`, `moderator`, `verified`, `normal` (override with `DEV_*****_USER_SECRET_TOKEN` env vars)
|
||||
|
||||
@@ -131,11 +131,11 @@ export default defineConfig({
|
||||
min: 1,
|
||||
default: 'admin',
|
||||
}),
|
||||
DEV_VERIFIER_USER_SECRET_TOKEN: envField.string({
|
||||
DEV_MODERATOR_USER_SECRET_TOKEN: envField.string({
|
||||
context: 'server',
|
||||
access: 'secret',
|
||||
min: 1,
|
||||
default: 'verifier',
|
||||
default: 'moderator',
|
||||
}),
|
||||
DEV_VERIFIED_USER_SECRET_TOKEN: envField.string({
|
||||
context: 'server',
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
Manully edited to be a rename migration.
|
||||
*/
|
||||
-- AlterEnum
|
||||
BEGIN;
|
||||
ALTER TYPE "AccountStatusChange" RENAME VALUE 'VERIFIER_TRUE' TO 'MODERATOR_TRUE';
|
||||
ALTER TYPE "AccountStatusChange" RENAME VALUE 'VERIFIER_FALSE' TO 'MODERATOR_FALSE';
|
||||
COMMIT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User"
|
||||
RENAME COLUMN "verifier" TO "moderator"
|
||||
|
||||
@@ -120,8 +120,8 @@ enum AccountStatusChange {
|
||||
ADMIN_FALSE
|
||||
VERIFIED_TRUE
|
||||
VERIFIED_FALSE
|
||||
VERIFIER_TRUE
|
||||
VERIFIER_FALSE
|
||||
MODERATOR_TRUE
|
||||
MODERATOR_FALSE
|
||||
SPAMMER_TRUE
|
||||
SPAMMER_FALSE
|
||||
}
|
||||
@@ -464,7 +464,7 @@ model User {
|
||||
spammer Boolean @default(false)
|
||||
verified Boolean @default(false)
|
||||
admin Boolean @default(false)
|
||||
verifier Boolean @default(false)
|
||||
moderator Boolean @default(false)
|
||||
verifiedLink String?
|
||||
secretTokenHash String @unique
|
||||
/// Computed via trigger. Do not update through prisma.
|
||||
|
||||
@@ -25,12 +25,12 @@ BEGIN
|
||||
VALUES (NEW.id, 'ACCOUNT_STATUS_CHANGE', status_change);
|
||||
END IF;
|
||||
|
||||
-- Check for verifier status change
|
||||
IF OLD.verifier IS DISTINCT FROM NEW.verifier THEN
|
||||
IF NEW.verifier = true THEN
|
||||
status_change := 'VERIFIER_TRUE';
|
||||
-- Check for moderator status change
|
||||
IF OLD.moderator IS DISTINCT FROM NEW.moderator THEN
|
||||
IF NEW.moderator = true THEN
|
||||
status_change := 'MODERATOR_TRUE';
|
||||
ELSE
|
||||
status_change := 'VERIFIER_FALSE';
|
||||
status_change := 'MODERATOR_FALSE';
|
||||
END IF;
|
||||
INSERT INTO "Notification" ("userId", "type", "aboutAccountStatusChange")
|
||||
VALUES (NEW.id, 'ACCOUNT_STATUS_CHANGE', status_change);
|
||||
@@ -57,6 +57,6 @@ DROP TRIGGER IF EXISTS user_status_change_notifications_trigger ON "User";
|
||||
|
||||
-- Create the trigger to fire after updates on specific status columns
|
||||
CREATE TRIGGER user_status_change_notifications_trigger
|
||||
AFTER UPDATE OF admin, verified, verifier, spammer ON "User"
|
||||
AFTER UPDATE OF admin, verified, moderator, spammer ON "User"
|
||||
FOR EACH ROW
|
||||
EXECUTE FUNCTION trigger_user_status_change_notifications();
|
||||
|
||||
@@ -85,7 +85,7 @@ async function createAccount(preGeneratedToken?: string) {
|
||||
verifiedLink,
|
||||
verified: !!verifiedLink,
|
||||
admin: faker.datatype.boolean({ probability: 0.1 }),
|
||||
verifier: faker.datatype.boolean({ probability: 0.1 }),
|
||||
moderator: faker.datatype.boolean({ probability: 0.1 }),
|
||||
},
|
||||
include: {
|
||||
serviceAffiliations: true,
|
||||
@@ -859,6 +859,22 @@ const generateFakeServiceContactMethod = (serviceId: number) => {
|
||||
{
|
||||
value: `https://x.com/${faker.internet.username()}`,
|
||||
},
|
||||
{
|
||||
value: `https://matrix.to/#/@${faker.internet.username()}:${faker.internet.domainName()}`,
|
||||
},
|
||||
{
|
||||
value: `https://instagram.com/${faker.internet.username()}`,
|
||||
},
|
||||
{
|
||||
value: `https://linkedin.com/in/${faker.helpers.slugify(faker.person.fullName())}`,
|
||||
},
|
||||
{
|
||||
label: faker.lorem.word({ length: 2 }),
|
||||
value: `https://bitcointalk.org/index.php?topic=${faker.number.int({ min: 1, max: 1000000 }).toString()}.0`,
|
||||
},
|
||||
{
|
||||
value: `https://bitcointalk.org/index.php?topic=${faker.number.int({ min: 1, max: 1000000 }).toString()}.0`,
|
||||
},
|
||||
{
|
||||
value: faker.internet.url(),
|
||||
},
|
||||
@@ -867,7 +883,7 @@ const generateFakeServiceContactMethod = (serviceId: number) => {
|
||||
value: faker.internet.url(),
|
||||
},
|
||||
{
|
||||
value: `https://www.linkedin.com/company/${faker.helpers.slugify(faker.company.name())}`,
|
||||
value: `https://linkedin.com/company/${faker.helpers.slugify(faker.company.name())}`,
|
||||
},
|
||||
] as const satisfies Partial<Prisma.ServiceContactMethodCreateInput>[]
|
||||
|
||||
@@ -883,19 +899,19 @@ const specialUsersData = {
|
||||
envToken: 'DEV_ADMIN_USER_SECRET_TOKEN',
|
||||
defaultToken: 'admin',
|
||||
admin: true,
|
||||
verifier: true,
|
||||
moderator: true,
|
||||
verified: true,
|
||||
verifiedLink: 'https://kycnot.me',
|
||||
totalKarma: 1001,
|
||||
link: 'https://kycnot.me',
|
||||
picture: 'https://comments.kycnot.me/api/users/549f290e-0542-4c18-b437-5b64b35758f0/avatar?size=L',
|
||||
},
|
||||
verifier: {
|
||||
name: 'verifier_dev',
|
||||
envToken: 'DEV_VERIFIER_USER_SECRET_TOKEN',
|
||||
defaultToken: 'verifier',
|
||||
moderator: {
|
||||
name: 'moderator_dev',
|
||||
envToken: 'DEV_MODERATOR_USER_SECRET_TOKEN',
|
||||
defaultToken: 'moderator',
|
||||
admin: false,
|
||||
verifier: true,
|
||||
moderator: true,
|
||||
verified: true,
|
||||
verifiedLink: 'https://kycnot.me',
|
||||
totalKarma: 1001,
|
||||
@@ -907,7 +923,7 @@ const specialUsersData = {
|
||||
envToken: 'DEV_VERIFIED_USER_SECRET_TOKEN',
|
||||
defaultToken: 'verified',
|
||||
admin: false,
|
||||
verifier: false,
|
||||
moderator: false,
|
||||
verified: true,
|
||||
verifiedLink: 'https://kycnot.me',
|
||||
totalKarma: 1001,
|
||||
@@ -917,7 +933,7 @@ const specialUsersData = {
|
||||
envToken: 'DEV_NORMAL_USER_SECRET_TOKEN',
|
||||
defaultToken: 'normal',
|
||||
admin: false,
|
||||
verifier: false,
|
||||
moderator: false,
|
||||
verified: false,
|
||||
},
|
||||
spam: {
|
||||
@@ -925,7 +941,7 @@ const specialUsersData = {
|
||||
envToken: 'DEV_SPAM_USER_SECRET_TOKEN',
|
||||
defaultToken: 'spam',
|
||||
admin: false,
|
||||
verifier: false,
|
||||
moderator: false,
|
||||
verified: false,
|
||||
totalKarma: -100,
|
||||
spammer: true,
|
||||
@@ -1290,7 +1306,7 @@ async function runFaker() {
|
||||
tx.internalUserNote.create({
|
||||
data: generateFakeInternalNote(
|
||||
user.id,
|
||||
faker.helpers.arrayElement([specialUsers.admin.id, specialUsers.verifier.id])
|
||||
faker.helpers.arrayElement([specialUsers.admin.id, specialUsers.moderator.id])
|
||||
),
|
||||
})
|
||||
)
|
||||
@@ -1307,7 +1323,7 @@ async function runFaker() {
|
||||
tx.internalUserNote.create({
|
||||
data: generateFakeInternalNote(
|
||||
user.id,
|
||||
faker.helpers.arrayElement([specialUsers.admin.id, specialUsers.verifier.id])
|
||||
faker.helpers.arrayElement([specialUsers.admin.id, specialUsers.moderator.id])
|
||||
),
|
||||
})
|
||||
)
|
||||
|
||||
@@ -187,13 +187,17 @@ export const adminServiceActions = {
|
||||
accept: 'form',
|
||||
permissions: 'admin',
|
||||
input: z.object({
|
||||
label: z.string().min(1).max(50).optional(),
|
||||
label: z.string().min(1).max(50).nullable(),
|
||||
value: z.string().url(),
|
||||
serviceId: z.number().int().positive(),
|
||||
}),
|
||||
handler: async (input) => {
|
||||
const contactMethod = await prisma.serviceContactMethod.create({
|
||||
data: input,
|
||||
data: {
|
||||
label: input.label,
|
||||
value: input.value,
|
||||
serviceId: input.serviceId,
|
||||
},
|
||||
})
|
||||
return { contactMethod }
|
||||
},
|
||||
@@ -203,16 +207,19 @@ export const adminServiceActions = {
|
||||
accept: 'form',
|
||||
permissions: 'admin',
|
||||
input: z.object({
|
||||
id: z.number().int().positive().optional(),
|
||||
label: z.string().min(1).max(50).optional(),
|
||||
id: z.number().int().positive(),
|
||||
label: z.string().min(1).max(50).nullable(),
|
||||
value: z.string().url(),
|
||||
serviceId: z.number().int().positive(),
|
||||
}),
|
||||
handler: async (input) => {
|
||||
const { id, ...data } = input
|
||||
const contactMethod = await prisma.serviceContactMethod.update({
|
||||
where: { id },
|
||||
data,
|
||||
where: { id: input.id },
|
||||
data: {
|
||||
label: input.label,
|
||||
value: input.value,
|
||||
serviceId: input.serviceId,
|
||||
},
|
||||
})
|
||||
return { contactMethod }
|
||||
},
|
||||
|
||||
@@ -16,7 +16,7 @@ const selectUserReturnFields = {
|
||||
picture: true,
|
||||
admin: true,
|
||||
verified: true,
|
||||
verifier: true,
|
||||
moderator: true,
|
||||
verifiedLink: true,
|
||||
secretTokenHash: true,
|
||||
totalKarma: true,
|
||||
@@ -55,7 +55,7 @@ export const adminUserActions = {
|
||||
.default(null) // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||
.transform((val) => val || null),
|
||||
pictureFile: z.instanceof(File).optional(),
|
||||
type: z.array(z.enum(['admin', 'verifier', 'spammer'])),
|
||||
type: z.array(z.enum(['admin', 'moderator', 'spammer'])),
|
||||
verifiedLink: z
|
||||
.string()
|
||||
.url('Invalid URL')
|
||||
@@ -101,7 +101,7 @@ export const adminUserActions = {
|
||||
verified: !!valuesToUpdate.verifiedLink,
|
||||
picture: pictureUrl,
|
||||
admin: type.includes('admin'),
|
||||
verifier: type.includes('verifier'),
|
||||
moderator: type.includes('moderator'),
|
||||
spammer: type.includes('spammer'),
|
||||
},
|
||||
select: selectUserReturnFields,
|
||||
|
||||
@@ -331,7 +331,7 @@ export const commentActions = {
|
||||
}),
|
||||
|
||||
moderate: defineProtectedAction({
|
||||
permissions: ['admin', 'verifier'],
|
||||
permissions: ['admin', 'moderator'],
|
||||
input: z.object({
|
||||
commentId: z.number(),
|
||||
userId: z.number(),
|
||||
|
||||
@@ -61,8 +61,8 @@ const isHighlighted = comment.id === highlightedCommentId
|
||||
const userVote = user ? comment.votes.find((v) => v.userId === user.id) : null
|
||||
|
||||
const isAuthor = user?.id === comment.author.id
|
||||
const isAdminOrVerifier = !!user && (user.admin || user.verifier)
|
||||
const isAuthorOrPrivileged = isAuthor || isAdminOrVerifier
|
||||
const isAdminOrModerator = !!user && (user.admin || user.moderator)
|
||||
const isAuthorOrPrivileged = isAuthor || isAdminOrModerator
|
||||
|
||||
// Check if user is new (less than 1 week old)
|
||||
const isNewUser =
|
||||
@@ -75,7 +75,7 @@ const isRatingActive =
|
||||
!comment.suspicious &&
|
||||
(comment.status === 'APPROVED' || comment.status === 'VERIFIED')
|
||||
|
||||
// Skip rendering if comment is not approved/verified and user is not the author or admin/verifier
|
||||
// Skip rendering if comment is not approved/verified and user is not the author or admin/moderator
|
||||
const shouldShow =
|
||||
comment.status === 'APPROVED' ||
|
||||
comment.status === 'VERIFIED' ||
|
||||
@@ -164,10 +164,10 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
||||
/>
|
||||
|
||||
{
|
||||
(comment.author.verified || comment.author.admin || comment.author.verifier) && (
|
||||
(comment.author.verified || comment.author.admin || comment.author.moderator) && (
|
||||
<Tooltip
|
||||
text={`${
|
||||
comment.author.admin || comment.author.verifier
|
||||
comment.author.admin || comment.author.moderator
|
||||
? `KYCnot.me ${comment.author.admin ? 'Admin' : 'Moderator'}${comment.author.verifiedLink ? '. ' : ''}`
|
||||
: ''
|
||||
}${comment.author.verifiedLink ? `Related to ${comment.author.verifiedLink}` : ''}`}
|
||||
@@ -186,7 +186,7 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
||||
)
|
||||
}
|
||||
{
|
||||
comment.author.verifier && !comment.author.admin && (
|
||||
comment.author.moderator && !comment.author.admin && (
|
||||
<BadgeSmall
|
||||
icon="ri:graduation-cap-fill"
|
||||
color="teal"
|
||||
@@ -198,14 +198,14 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
||||
}
|
||||
|
||||
{
|
||||
isNewUser && !comment.author.admin && !comment.author.verifier && (
|
||||
isNewUser && !comment.author.admin && !comment.author.moderator && (
|
||||
<Tooltip text={`Joined ${formatDateShort(comment.author.createdAt, { hourPrecision: true })}`}>
|
||||
<BadgeSmall icon="ri:user-add-fill" color="purple" text="New User" variant="faded" inlineIcon />
|
||||
</Tooltip>
|
||||
)
|
||||
}
|
||||
{
|
||||
authorUnlocks.highKarmaBadge && !comment.author.admin && !comment.author.verifier && (
|
||||
authorUnlocks.highKarmaBadge && !comment.author.admin && !comment.author.moderator && (
|
||||
<BadgeSmall
|
||||
icon={karmaUnlocksById.highKarmaBadge.icon}
|
||||
color="lime"
|
||||
@@ -380,7 +380,7 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
||||
}
|
||||
|
||||
{
|
||||
user && (user.admin || user.verifier) && comment.internalNote && (
|
||||
user && (user.admin || user.moderator) && comment.internalNote && (
|
||||
<div class="mt-2 peer-checked/collapse:hidden">
|
||||
<div class="border-l-2 border-red-600 bg-red-900/20 py-0.5 pl-2 text-xs">
|
||||
<span class="font-medium text-red-400">Internal note:</span>
|
||||
@@ -391,7 +391,7 @@ const commentUrl = makeCommentUrl({ serviceSlug, commentId: comment.id, origin:
|
||||
}
|
||||
|
||||
{
|
||||
user && (user.admin || user.verifier) && comment.privateContext && (
|
||||
user && (user.admin || user.moderator) && comment.privateContext && (
|
||||
<div class="mt-2 peer-checked/collapse:hidden">
|
||||
<div class="border-l-2 border-blue-600 bg-blue-900/20 py-0.5 pl-2 text-xs">
|
||||
<span class="font-medium text-blue-400">Private context:</span>
|
||||
|
||||
@@ -28,8 +28,8 @@ const { comment, class: className, ...divProps } = Astro.props
|
||||
|
||||
const user = Astro.locals.user
|
||||
|
||||
// Only render for admin/verifier users
|
||||
if (!user || !user.admin || !user.verifier) return null
|
||||
// Only render for admin/moderator users
|
||||
if (!user || !user.admin || !user.moderator) return null
|
||||
---
|
||||
|
||||
<div {...divProps} class={cn('text-xs', className)}>
|
||||
|
||||
@@ -202,7 +202,7 @@ function makeReplySchema(comment: CommentWithRepliesPopulated): Comment {
|
||||
Most Upvotes
|
||||
</a>
|
||||
{
|
||||
user && (user.admin || user.verifier) && (
|
||||
user && (user.admin || user.moderator) && (
|
||||
<a
|
||||
href={getSortUrl('status')}
|
||||
class={cn([
|
||||
|
||||
@@ -43,14 +43,14 @@ export const {
|
||||
notificationTitle: 'Your account is no longer verified',
|
||||
},
|
||||
{
|
||||
value: 'VERIFIER_TRUE',
|
||||
label: 'Verifier role granted',
|
||||
notificationTitle: 'Verifier role granted',
|
||||
value: 'MODERATOR_TRUE',
|
||||
label: 'Moderator role granted',
|
||||
notificationTitle: 'Moderator role granted',
|
||||
},
|
||||
{
|
||||
value: 'VERIFIER_FALSE',
|
||||
label: 'Verifier role revoked',
|
||||
notificationTitle: 'Verifier role revoked',
|
||||
value: 'MODERATOR_FALSE',
|
||||
label: 'Moderator role revoked',
|
||||
notificationTitle: 'Moderator role revoked',
|
||||
},
|
||||
{
|
||||
value: 'SPAMMER_TRUE',
|
||||
|
||||
@@ -30,14 +30,14 @@ export const {
|
||||
{
|
||||
type: 'email',
|
||||
label: 'Email',
|
||||
matcher: /mailto:(.*)/,
|
||||
matcher: /mailto:(.+)/,
|
||||
formatter: (value) => value,
|
||||
icon: 'ri:mail-line',
|
||||
},
|
||||
{
|
||||
type: 'telephone',
|
||||
label: 'Telephone',
|
||||
matcher: /tel:(.*)/,
|
||||
matcher: /tel:(.+)/,
|
||||
formatter: (value) => {
|
||||
return parsePhoneNumberWithError(value).formatInternational()
|
||||
},
|
||||
@@ -46,7 +46,7 @@ export const {
|
||||
{
|
||||
type: 'whatsapp',
|
||||
label: 'WhatsApp',
|
||||
matcher: /https?:\/\/(?:www\.)?wa\.me\/(.*)\/?/,
|
||||
matcher: /https?:\/\/(?:www\.)?wa\.me\/(.+)/,
|
||||
formatter: (value) => {
|
||||
return parsePhoneNumberWithError(value).formatInternational()
|
||||
},
|
||||
@@ -55,42 +55,35 @@ export const {
|
||||
{
|
||||
type: 'telegram',
|
||||
label: 'Telegram',
|
||||
matcher: /https?:\/\/(?:www\.)?t\.me\/(.*)\/?/,
|
||||
matcher: /https?:\/\/(?:www\.)?t\.me\/(.+)/,
|
||||
formatter: (value) => `t.me/${value}`,
|
||||
icon: 'ri:telegram-line',
|
||||
},
|
||||
{
|
||||
type: 'linkedin',
|
||||
label: 'LinkedIn',
|
||||
matcher: /https?:\/\/(?:www\.)?linkedin\.com\/(?:in|company)\/(.*)\/?/,
|
||||
matcher: /https?:\/\/(?:www\.)?linkedin\.com\/(?:in|company)\/(.+)/,
|
||||
formatter: (value) => `in/${value}`,
|
||||
icon: 'ri:linkedin-box-line',
|
||||
},
|
||||
{
|
||||
type: 'website',
|
||||
label: 'Website',
|
||||
matcher: /https?:\/\/(?:www\.)?((?:[a-zA-Z0-9-]+\.)+[a-zA-Z]+)/,
|
||||
formatter: (value) => value,
|
||||
icon: 'ri:global-line',
|
||||
},
|
||||
{
|
||||
type: 'x',
|
||||
label: 'X',
|
||||
matcher: /https?:\/\/(?:www\.)?x\.com\/(.*)\/?/,
|
||||
matcher: /https?:\/\/(?:www\.)?x\.com\/(.+)/,
|
||||
formatter: (value) => `@${value}`,
|
||||
icon: 'ri:twitter-x-line',
|
||||
},
|
||||
{
|
||||
type: 'instagram',
|
||||
label: 'Instagram',
|
||||
matcher: /https?:\/\/(?:www\.)?instagram\.com\/(.*)\/?/,
|
||||
matcher: /https?:\/\/(?:www\.)?instagram\.com\/(.+)/,
|
||||
formatter: (value) => `@${value}`,
|
||||
icon: 'ri:instagram-line',
|
||||
},
|
||||
{
|
||||
type: 'matrix',
|
||||
label: 'Matrix',
|
||||
matcher: /https?:\/\/(?:www\.)?matrix\.to\/#\/(.*)\/?/,
|
||||
matcher: /https?:\/\/(?:www\.)?matrix\.to\/#\/(.+)/,
|
||||
formatter: (value) => value,
|
||||
icon: 'ri:hashtag',
|
||||
},
|
||||
@@ -101,6 +94,14 @@ export const {
|
||||
formatter: () => 'BitcoinTalk',
|
||||
icon: 'ri:btc-line',
|
||||
},
|
||||
// Website must go last because it's a catch-all
|
||||
{
|
||||
type: 'website',
|
||||
label: 'Website',
|
||||
matcher: /https?:\/\/(?:www\.)?((?:[a-zA-Z0-9-]+\.)+[a-zA-Z]+)/,
|
||||
formatter: (value) => value,
|
||||
icon: 'ri:global-line',
|
||||
},
|
||||
] as const satisfies ContactMethodInfo[]
|
||||
)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ const commentReplyQuery = {
|
||||
name: true,
|
||||
verified: true,
|
||||
admin: true,
|
||||
verifier: true,
|
||||
moderator: true,
|
||||
createdAt: true,
|
||||
displayName: true,
|
||||
picture: true,
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import type { MaybePromise } from 'astro/actions/runtime/utils.js'
|
||||
import type { z } from 'astro/zod'
|
||||
|
||||
type SpecialUserPermission = 'admin' | 'verified' | 'verifier'
|
||||
type SpecialUserPermission = 'admin' | 'verified' | 'moderator'
|
||||
type Permission = SpecialUserPermission | 'guest' | 'not-spammer' | 'user'
|
||||
|
||||
type ActionAPIContextWithUser = ActionAPIContext & {
|
||||
@@ -87,8 +87,8 @@ export function defineProtectedAction<
|
||||
}
|
||||
|
||||
if (
|
||||
(permissions === 'verifier' || (Array.isArray(permissions) && permissions.includes('verifier'))) &&
|
||||
!context.locals.user.verifier
|
||||
(permissions === 'moderator' || (Array.isArray(permissions) && permissions.includes('moderator'))) &&
|
||||
!context.locals.user.moderator
|
||||
) {
|
||||
if (context.locals.user.spammer) {
|
||||
throw new ActionError({
|
||||
@@ -98,7 +98,7 @@ export function defineProtectedAction<
|
||||
}
|
||||
throw new ActionError({
|
||||
code: 'FORBIDDEN',
|
||||
message: 'Verifier privileges required.',
|
||||
message: 'Moderator privileges required.',
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ const USER_SECRET_TOKEN_DEV_USERS_REGEX = (() => {
|
||||
defaultToken: 'admin',
|
||||
},
|
||||
{
|
||||
envToken: 'DEV_VERIFIER_USER_SECRET_TOKEN',
|
||||
defaultToken: 'verifier',
|
||||
envToken: 'DEV_MODERATOR_USER_SECRET_TOKEN',
|
||||
defaultToken: 'moderator',
|
||||
},
|
||||
{
|
||||
envToken: 'DEV_VERIFIED_USER_SECRET_TOKEN',
|
||||
|
||||
@@ -44,7 +44,7 @@ const user = await Astro.locals.banners.try('user', async () => {
|
||||
spammer: true,
|
||||
verified: true,
|
||||
admin: true,
|
||||
verifier: true,
|
||||
moderator: true,
|
||||
verifiedLink: true,
|
||||
totalKarma: true,
|
||||
createdAt: true,
|
||||
@@ -206,7 +206,7 @@ if (!user) return Astro.rewrite('/404')
|
||||
</h1>
|
||||
{user.displayName && <p class="text-day-200 font-title">{user.name}</p>}
|
||||
{
|
||||
(user.admin || user.verified || user.verifier) && (
|
||||
(user.admin || user.verified || user.moderator) && (
|
||||
<div class="mt-1 flex gap-2">
|
||||
{user.admin && (
|
||||
<span class="rounded-full border border-red-500/50 bg-red-500/20 px-2 py-0.5 text-xs text-red-400">
|
||||
@@ -218,9 +218,9 @@ if (!user) return Astro.rewrite('/404')
|
||||
verified
|
||||
</span>
|
||||
)}
|
||||
{user.verifier && (
|
||||
{user.moderator && (
|
||||
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
||||
verifier
|
||||
moderator
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
@@ -356,14 +356,14 @@ if (!user) return Astro.rewrite('/404')
|
||||
)
|
||||
}
|
||||
{
|
||||
user.verifier && (
|
||||
user.moderator && (
|
||||
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
||||
Verifier
|
||||
Moderator
|
||||
</span>
|
||||
)
|
||||
}
|
||||
{
|
||||
!user.admin && !user.verified && !user.verifier && (
|
||||
!user.admin && !user.verified && !user.moderator && (
|
||||
<span class="border-day-700/50 bg-day-700/20 text-day-400 rounded-full border px-2 py-0.5 text-xs">
|
||||
Standard User
|
||||
</span>
|
||||
|
||||
@@ -20,7 +20,7 @@ import { prisma } from '../../lib/prisma'
|
||||
import { urlWithParams } from '../../lib/urls'
|
||||
|
||||
const user = Astro.locals.user
|
||||
if (!user || (!user.admin && !user.verifier)) {
|
||||
if (!user || (!user.admin && !user.moderator)) {
|
||||
return Astro.rewrite('/404')
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ type AdminLink = {
|
||||
icon: ComponentProps<typeof Icon>['name']
|
||||
title: string
|
||||
href: string
|
||||
description: string
|
||||
}
|
||||
|
||||
const adminLinks: AdminLink[] = [
|
||||
@@ -17,37 +16,36 @@ const adminLinks: AdminLink[] = [
|
||||
icon: 'ri:box-3-line',
|
||||
title: 'Services',
|
||||
href: '/admin/services',
|
||||
description: 'Manage your available services',
|
||||
},
|
||||
{
|
||||
icon: 'ri:file-list-3-line',
|
||||
title: 'Attributes',
|
||||
href: '/admin/attributes',
|
||||
description: 'Configure service attributes',
|
||||
},
|
||||
{
|
||||
icon: 'ri:user-3-line',
|
||||
title: 'Users',
|
||||
href: '/admin/users',
|
||||
description: 'Manage user accounts',
|
||||
},
|
||||
{
|
||||
icon: 'ri:chat-settings-line',
|
||||
title: 'Comments',
|
||||
href: '/admin/comments',
|
||||
description: 'Moderate user comments',
|
||||
},
|
||||
{
|
||||
icon: 'ri:lightbulb-line',
|
||||
title: 'Service suggestions',
|
||||
href: '/admin/service-suggestions',
|
||||
description: 'Review and manage service suggestions',
|
||||
},
|
||||
{
|
||||
icon: 'ri:megaphone-line',
|
||||
title: 'Announcements',
|
||||
href: '/admin/announcements',
|
||||
description: 'Manage site announcements',
|
||||
},
|
||||
{
|
||||
icon: 'ri:database-2-line',
|
||||
title: 'Database',
|
||||
href: 'https://db.kycnot.me',
|
||||
},
|
||||
]
|
||||
---
|
||||
@@ -58,23 +56,17 @@ const adminLinks: AdminLink[] = [
|
||||
Admin Dashboard
|
||||
</h1>
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
|
||||
<div class="grid grid-cols-[repeat(auto-fill,minmax(calc(var(--spacing)*40),1fr))] gap-4">
|
||||
{
|
||||
adminLinks.map((link) => (
|
||||
<a
|
||||
href={link.href}
|
||||
class="group block rounded-lg border border-zinc-800 bg-gradient-to-br from-zinc-900/90 to-zinc-900/50 p-6 shadow-lg backdrop-blur-xs transition-all duration-300 hover:-translate-y-0.5 hover:from-zinc-800/90 hover:to-zinc-800/50 hover:shadow-xl hover:shadow-zinc-900/20"
|
||||
class="group flex flex-col items-center justify-evenly rounded-lg border border-zinc-800 bg-gradient-to-br from-zinc-900/90 to-zinc-900/50 py-3 text-center shadow-lg backdrop-blur-xs transition-all duration-300 hover:-translate-y-0.5 hover:from-zinc-800/90 hover:to-zinc-800/50 hover:shadow-xl hover:shadow-zinc-900/20"
|
||||
>
|
||||
<div class="mb-4 flex items-center gap-3">
|
||||
<Icon
|
||||
name={link.icon}
|
||||
class="h-6 w-6 text-zinc-400 transition-colors group-hover:text-green-400"
|
||||
/>
|
||||
<h2 class="font-title text-xl font-semibold text-zinc-100 transition-colors group-hover:text-green-400">
|
||||
{link.title}
|
||||
</h2>
|
||||
</div>
|
||||
<p class="text-sm text-zinc-400">{link.description}</p>
|
||||
<Icon name={link.icon} class="size-8 text-zinc-400 transition-colors group-hover:text-green-400" />
|
||||
<span class="font-title text-xl leading-none font-semibold text-zinc-100 transition-colors group-hover:text-green-400">
|
||||
{link.title}
|
||||
</span>
|
||||
</a>
|
||||
))
|
||||
}
|
||||
|
||||
@@ -170,8 +170,6 @@ const errorTextClasses = 'mt-1 text-xs text-red-400'
|
||||
</h1>
|
||||
<a
|
||||
href={`/service/${service.slug}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-sm text-sky-400 hover:text-sky-300 hover:underline focus:ring-2 focus:ring-sky-500 focus:ring-offset-2 focus:ring-offset-zinc-900 focus:outline-none"
|
||||
>
|
||||
<Icon name="ri:external-link-line" class="size-4" />
|
||||
@@ -405,8 +403,7 @@ const errorTextClasses = 'mt-1 text-xs text-red-400'
|
||||
}))}
|
||||
selectedValue={service.serviceVisibility}
|
||||
error={serviceInputErrors.serviceVisibility}
|
||||
cardSize="md"
|
||||
iconSize="md"
|
||||
cardSize="sm"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1018,12 +1015,10 @@ const errorTextClasses = 'mt-1 text-xs text-red-400'
|
||||
<div class="flex-grow space-y-1">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<Icon name={contactMethodInfo.icon} class="size-4 text-zinc-300" />
|
||||
<span class="text-md font-semibold text-zinc-100">
|
||||
{method.label ?? contactMethodInfo.label}
|
||||
</span>
|
||||
<span class="text-md font-semibold text-zinc-100">{contactMethodInfo.label}</span>
|
||||
</div>
|
||||
<p class="text-sm text-pretty text-zinc-400">
|
||||
{contactMethodInfo.formattedValue}{' '}
|
||||
{method.label ?? contactMethodInfo.formattedValue}{' '}
|
||||
<span class="text-zinc-500">({method.value})</span>
|
||||
</p>
|
||||
</div>
|
||||
@@ -1068,7 +1063,7 @@ const errorTextClasses = 'mt-1 text-xs text-red-400'
|
||||
id={`contactLabel-${method.id}`}
|
||||
value={method.label}
|
||||
class={inputBaseClasses}
|
||||
placeholder={contactMethodInfo.label}
|
||||
placeholder={contactMethodInfo.formattedValue}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -52,7 +52,7 @@ const [user, allServices] = await Astro.locals.banners.tryMany([
|
||||
link: true,
|
||||
admin: true,
|
||||
verified: true,
|
||||
verifier: true,
|
||||
moderator: true,
|
||||
spammer: true,
|
||||
verifiedLink: true,
|
||||
internalNotes: {
|
||||
@@ -141,7 +141,7 @@ if (!user) return Astro.rewrite('/404')
|
||||
<div class="mb-4 flex flex-wrap justify-center gap-2">
|
||||
{user.admin && <BadgeSmall color="green" text="Admin" icon="ri:shield-star-fill" />}
|
||||
{user.verified && <BadgeSmall color="cyan" text="Verified" icon="ri:verified-badge-fill" />}
|
||||
{user.verifier && <BadgeSmall color="blue" text="Moderator" icon="ri:graduation-cap-fill" />}
|
||||
{user.moderator && <BadgeSmall color="blue" text="Moderator" icon="ri:graduation-cap-fill" />}
|
||||
{user.spammer && <BadgeSmall color="red" text="Spammer" icon="ri:alert-fill" />}
|
||||
</div>
|
||||
|
||||
@@ -226,7 +226,7 @@ if (!user) return Astro.rewrite('/404')
|
||||
label="Type"
|
||||
options={[
|
||||
{ label: 'Admin', value: 'admin', icon: 'ri:shield-star-fill' },
|
||||
{ label: 'Moderator', value: 'verifier', icon: 'ri:graduation-cap-fill' },
|
||||
{ label: 'Moderator', value: 'moderator', icon: 'ri:graduation-cap-fill' },
|
||||
{ label: 'Spammer', value: 'spammer', icon: 'ri:alert-fill' },
|
||||
{
|
||||
label: 'Verified',
|
||||
@@ -239,7 +239,7 @@ if (!user) return Astro.rewrite('/404')
|
||||
selectedValue={[
|
||||
user.admin ? 'admin' : null,
|
||||
user.verified ? 'verified' : null,
|
||||
user.verifier ? 'verifier' : null,
|
||||
user.moderator ? 'moderator' : null,
|
||||
user.spammer ? 'spammer' : null,
|
||||
].filter((v) => v !== null)}
|
||||
required
|
||||
|
||||
@@ -21,7 +21,7 @@ const { data: filters } = zodParseQueryParamsStoringErrors(
|
||||
'sort-by': z.enum(['name', 'role', 'createdAt', 'karma']).default('createdAt'),
|
||||
'sort-order': z.enum(['asc', 'desc']).default('desc'),
|
||||
search: z.string().optional(),
|
||||
role: z.enum(['user', 'admin', 'verifier', 'verified', 'spammer']).optional(),
|
||||
role: z.enum(['user', 'admin', 'moderator', 'verified', 'spammer']).optional(),
|
||||
},
|
||||
Astro
|
||||
)
|
||||
@@ -46,7 +46,7 @@ if (filters.role) {
|
||||
switch (filters.role) {
|
||||
case 'user': {
|
||||
whereClause.admin = false
|
||||
whereClause.verifier = false
|
||||
whereClause.moderator = false
|
||||
whereClause.verified = false
|
||||
whereClause.spammer = false
|
||||
break
|
||||
@@ -55,8 +55,8 @@ if (filters.role) {
|
||||
whereClause.admin = true
|
||||
break
|
||||
}
|
||||
case 'verifier': {
|
||||
whereClause.verifier = true
|
||||
case 'moderator': {
|
||||
whereClause.moderator = true
|
||||
break
|
||||
}
|
||||
case 'verified': {
|
||||
@@ -80,7 +80,7 @@ const dbUsers = await prisma.user.findMany({
|
||||
picture: true,
|
||||
verified: true,
|
||||
admin: true,
|
||||
verifier: true,
|
||||
moderator: true,
|
||||
spammer: true,
|
||||
totalKarma: true,
|
||||
createdAt: true,
|
||||
@@ -147,7 +147,7 @@ const makeSortUrl = (sortBy: NonNullable<(typeof filters)['sort-by']>) => {
|
||||
<option value="" selected={!filters.role}>All Users</option>
|
||||
<option value="user" selected={filters.role === 'user'}>Regular Users</option>
|
||||
<option value="admin" selected={filters.role === 'admin'}>Admins</option>
|
||||
<option value="verifier" selected={filters.role === 'verifier'}>Verifiers</option>
|
||||
<option value="moderator" selected={filters.role === 'moderator'}>Moderators</option>
|
||||
<option value="verified" selected={filters.role === 'verified'}>Verified Users</option>
|
||||
<option value="spammer" selected={filters.role === 'spammer'}>Spammers</option>
|
||||
</select>
|
||||
@@ -277,10 +277,10 @@ const makeSortUrl = (sortBy: NonNullable<(typeof filters)['sort-by']>) => {
|
||||
Verified
|
||||
</span>
|
||||
)}
|
||||
{user.verifier && (
|
||||
{user.moderator && (
|
||||
<span class="inline-flex items-center gap-1 rounded-md bg-blue-900/30 px-2 py-0.5 text-xs font-medium text-blue-400">
|
||||
<Icon name="ri:shield-check-fill" class="size-3.5" />
|
||||
Verifier
|
||||
Moderator
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -43,7 +43,7 @@ const user = await Astro.locals.banners.try('user', async () => {
|
||||
spammer: true,
|
||||
verified: true,
|
||||
admin: true,
|
||||
verifier: true,
|
||||
moderator: true,
|
||||
verifiedLink: true,
|
||||
totalKarma: true,
|
||||
createdAt: true,
|
||||
@@ -208,7 +208,7 @@ const isCurrentUser = !!Astro.locals.user && user.id === Astro.locals.user.id
|
||||
sameAs: user.link ? [user.link] : undefined,
|
||||
description: `User profile page for ${user.displayName ?? user.name} on KYCnot.me`,
|
||||
identifier: [user.name, user.id.toString()],
|
||||
jobTitle: user.admin ? 'Administrator' : user.verifier ? 'Moderator' : undefined,
|
||||
jobTitle: user.admin ? 'Administrator' : user.moderator ? 'Moderator' : undefined,
|
||||
memberOf: KYCNOTME_SCHEMA_MINI,
|
||||
interactionStatistic: [
|
||||
{
|
||||
@@ -281,9 +281,9 @@ const isCurrentUser = !!Astro.locals.user && user.id === Astro.locals.user.id
|
||||
)
|
||||
}
|
||||
{
|
||||
user.verifier && (
|
||||
user.moderator && (
|
||||
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
||||
verifier
|
||||
moderator
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -415,14 +415,14 @@ const isCurrentUser = !!Astro.locals.user && user.id === Astro.locals.user.id
|
||||
)
|
||||
}
|
||||
{
|
||||
user.verifier && (
|
||||
user.moderator && (
|
||||
<span class="rounded-full border border-green-500/50 bg-green-500/20 px-2 py-0.5 text-xs text-green-400">
|
||||
Verifier
|
||||
Moderator
|
||||
</span>
|
||||
)
|
||||
}
|
||||
{
|
||||
!user.admin && !user.verified && !user.verifier && (
|
||||
!user.admin && !user.verified && !user.moderator && (
|
||||
<span class="border-day-700/50 bg-day-700/20 text-day-400 rounded-full border px-2 py-0.5 text-xs">
|
||||
Standard User
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user