feat: Implement initial Electron frontend with core UI, user and server settings, chat, and voice features, along with Convex backend schemas and functions.
Some checks failed
Build and Release / build-and-release (push) Has been cancelled
Some checks failed
Build and Release / build-and-release (push) Has been cancelled
This commit is contained in:
@@ -6,7 +6,13 @@ export const get = query({
|
||||
args: {},
|
||||
returns: v.any(),
|
||||
handler: async (ctx) => {
|
||||
return await ctx.db.query("serverSettings").first();
|
||||
const settings = await ctx.db.query("serverSettings").first();
|
||||
if (!settings) return null;
|
||||
let iconUrl = null;
|
||||
if (settings.iconStorageId) {
|
||||
iconUrl = await ctx.storage.getUrl(settings.iconStorageId);
|
||||
}
|
||||
return { ...settings, iconUrl };
|
||||
},
|
||||
});
|
||||
|
||||
@@ -56,6 +62,74 @@ export const update = mutation({
|
||||
},
|
||||
});
|
||||
|
||||
export const updateName = mutation({
|
||||
args: {
|
||||
userId: v.id("userProfiles"),
|
||||
serverName: v.string(),
|
||||
},
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
// Permission check
|
||||
const roles = await getRolesForUser(ctx, args.userId);
|
||||
const canManage = roles.some(
|
||||
(role) => (role.permissions as Record<string, boolean>)?.["manage_channels"]
|
||||
);
|
||||
if (!canManage) {
|
||||
throw new Error("You don't have permission to manage server settings");
|
||||
}
|
||||
|
||||
// Validate name
|
||||
const name = args.serverName.trim();
|
||||
if (name.length === 0 || name.length > 100) {
|
||||
throw new Error("Server name must be between 1 and 100 characters");
|
||||
}
|
||||
|
||||
const existing = await ctx.db.query("serverSettings").first();
|
||||
if (existing) {
|
||||
await ctx.db.patch(existing._id, { serverName: name });
|
||||
} else {
|
||||
await ctx.db.insert("serverSettings", {
|
||||
serverName: name,
|
||||
afkTimeout: 300,
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
export const updateIcon = mutation({
|
||||
args: {
|
||||
userId: v.id("userProfiles"),
|
||||
iconStorageId: v.optional(v.id("_storage")),
|
||||
},
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
// Permission check
|
||||
const roles = await getRolesForUser(ctx, args.userId);
|
||||
const canManage = roles.some(
|
||||
(role) => (role.permissions as Record<string, boolean>)?.["manage_channels"]
|
||||
);
|
||||
if (!canManage) {
|
||||
throw new Error("You don't have permission to manage server settings");
|
||||
}
|
||||
|
||||
const existing = await ctx.db.query("serverSettings").first();
|
||||
if (existing) {
|
||||
await ctx.db.patch(existing._id, {
|
||||
iconStorageId: args.iconStorageId,
|
||||
});
|
||||
} else {
|
||||
await ctx.db.insert("serverSettings", {
|
||||
iconStorageId: args.iconStorageId,
|
||||
afkTimeout: 300,
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
export const clearAfkChannel = internalMutation({
|
||||
args: { channelId: v.id("channels") },
|
||||
returns: v.null(),
|
||||
|
||||
Reference in New Issue
Block a user