bump
Some checks failed
Build and Release / build-and-release (push) Has been cancelled

This commit is contained in:
Bryan1029384756
2026-04-20 17:09:04 -05:00
parent 82f8a12e27
commit b83360db35
48 changed files with 6079 additions and 49 deletions

View File

@@ -1,5 +1,6 @@
import { mutation, query } from "./_generated/server";
import { v } from "convex/values";
import { getRolesForUser } from "./roles";
const pollOptionValidator = v.object({
id: v.string(),
@@ -195,8 +196,17 @@ export const remove = mutation({
handler: async (ctx, args) => {
const poll = await ctx.db.get(args.pollId);
if (!poll) return null;
if (poll.createdBy !== args.userId) {
throw new Error("Only the poll creator can delete it");
const isCreator = poll.createdBy === args.userId;
if (!isCreator) {
// Mirror `messages.removeInternal` — users with `manage_messages`
// can delete any poll, not just their own.
const roles = await getRolesForUser(ctx, args.userId);
const canManage = roles.some(
(role) => (role.permissions as Record<string, boolean>)?.manage_messages,
);
if (!canManage) {
throw new Error("Not authorized to delete this poll");
}
}
const votes = await ctx.db
.query("pollVotes")