feat: Implement core Discord clone functionality including Convex backend services for authentication, channels, messages, roles, and voice state, alongside new Electron frontend components for chat, voice, server settings, and user interface.
All checks were successful
Build and Release / build-and-release (push) Successful in 14m19s
All checks were successful
Build and Release / build-and-release (push) Successful in 14m19s
This commit is contained in:
@@ -2,6 +2,7 @@ import { query, mutation } from "./_generated/server";
|
||||
import { paginationOptsValidator } from "convex/server";
|
||||
import { v } from "convex/values";
|
||||
import { getPublicStorageUrl } from "./storageUrl";
|
||||
import { getRolesForUser } from "./roles";
|
||||
|
||||
export const list = query({
|
||||
args: {
|
||||
@@ -173,9 +174,23 @@ export const listPinned = query({
|
||||
});
|
||||
|
||||
export const remove = mutation({
|
||||
args: { id: v.id("messages") },
|
||||
args: { id: v.id("messages"), userId: v.id("userProfiles") },
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
const message = await ctx.db.get(args.id);
|
||||
if (!message) throw new Error("Message not found");
|
||||
|
||||
const isSender = message.senderId === args.userId;
|
||||
if (!isSender) {
|
||||
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 message");
|
||||
}
|
||||
}
|
||||
|
||||
const reactions = await ctx.db
|
||||
.query("messageReactions")
|
||||
.withIndex("by_message", (q) => q.eq("messageId", args.id))
|
||||
|
||||
Reference in New Issue
Block a user