feat: Implement core Discord clone functionality including Convex backend, Electron frontend, and UI components for chat, voice, and settings.
This commit is contained in:
98
convex/schema.ts
Normal file
98
convex/schema.ts
Normal file
@@ -0,0 +1,98 @@
|
||||
import { defineSchema, defineTable } from "convex/server";
|
||||
import { v } from "convex/values";
|
||||
|
||||
export default defineSchema({
|
||||
userProfiles: defineTable({
|
||||
username: v.string(),
|
||||
clientSalt: v.string(),
|
||||
encryptedMasterKey: v.string(),
|
||||
hashedAuthKey: v.string(),
|
||||
publicIdentityKey: v.string(),
|
||||
publicSigningKey: v.string(),
|
||||
encryptedPrivateKeys: v.string(),
|
||||
isAdmin: v.boolean(),
|
||||
}).index("by_username", ["username"]),
|
||||
|
||||
channels: defineTable({
|
||||
name: v.string(),
|
||||
type: v.string(), // 'text' | 'voice' | 'dm'
|
||||
}).index("by_name", ["name"]),
|
||||
|
||||
messages: defineTable({
|
||||
channelId: v.id("channels"),
|
||||
senderId: v.id("userProfiles"),
|
||||
ciphertext: v.string(),
|
||||
nonce: v.string(),
|
||||
signature: v.string(),
|
||||
keyVersion: v.number(),
|
||||
}).index("by_channel", ["channelId"]),
|
||||
|
||||
messageReactions: defineTable({
|
||||
messageId: v.id("messages"),
|
||||
userId: v.id("userProfiles"),
|
||||
emoji: v.string(),
|
||||
})
|
||||
.index("by_message", ["messageId"])
|
||||
.index("by_message_user_emoji", ["messageId", "userId", "emoji"]),
|
||||
|
||||
channelKeys: defineTable({
|
||||
channelId: v.id("channels"),
|
||||
userId: v.id("userProfiles"),
|
||||
encryptedKeyBundle: v.string(),
|
||||
keyVersion: v.number(),
|
||||
})
|
||||
.index("by_channel", ["channelId"])
|
||||
.index("by_user", ["userId"])
|
||||
.index("by_channel_and_user", ["channelId", "userId"]),
|
||||
|
||||
roles: defineTable({
|
||||
name: v.string(),
|
||||
color: v.string(),
|
||||
position: v.number(),
|
||||
permissions: v.any(), // JSON object of permissions
|
||||
isHoist: v.boolean(),
|
||||
}),
|
||||
|
||||
userRoles: defineTable({
|
||||
userId: v.id("userProfiles"),
|
||||
roleId: v.id("roles"),
|
||||
})
|
||||
.index("by_user", ["userId"])
|
||||
.index("by_role", ["roleId"])
|
||||
.index("by_user_and_role", ["userId", "roleId"]),
|
||||
|
||||
invites: defineTable({
|
||||
code: v.string(),
|
||||
encryptedPayload: v.string(),
|
||||
createdBy: v.id("userProfiles"),
|
||||
maxUses: v.optional(v.number()),
|
||||
uses: v.number(),
|
||||
expiresAt: v.optional(v.number()), // timestamp
|
||||
keyVersion: v.number(),
|
||||
}).index("by_code", ["code"]),
|
||||
|
||||
dmParticipants: defineTable({
|
||||
channelId: v.id("channels"),
|
||||
userId: v.id("userProfiles"),
|
||||
})
|
||||
.index("by_channel", ["channelId"])
|
||||
.index("by_user", ["userId"]),
|
||||
|
||||
typingIndicators: defineTable({
|
||||
channelId: v.id("channels"),
|
||||
userId: v.id("userProfiles"),
|
||||
username: v.string(),
|
||||
expiresAt: v.number(), // timestamp
|
||||
}).index("by_channel", ["channelId"]),
|
||||
|
||||
voiceStates: defineTable({
|
||||
channelId: v.id("channels"),
|
||||
userId: v.id("userProfiles"),
|
||||
username: v.string(),
|
||||
isMuted: v.boolean(),
|
||||
isDeafened: v.boolean(),
|
||||
isScreenSharing: v.boolean(),
|
||||
})
|
||||
.index("by_channel", ["channelId"])
|
||||
.index("by_user", ["userId"]),
|
||||
});
|
||||
Reference in New Issue
Block a user