feat: Implement core Discord clone functionality including Convex backend, Electron frontend, and UI components for chat, voice, and settings.
This commit is contained in:
34
convex/voice.ts
Normal file
34
convex/voice.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
"use node";
|
||||
|
||||
import { action } from "./_generated/server";
|
||||
import { v } from "convex/values";
|
||||
import { AccessToken } from "livekit-server-sdk";
|
||||
|
||||
// Generate LiveKit token for voice channel
|
||||
export const getToken = action({
|
||||
args: {
|
||||
channelId: v.string(),
|
||||
userId: v.string(),
|
||||
username: v.string(),
|
||||
},
|
||||
returns: v.object({ token: v.string() }),
|
||||
handler: async (_ctx, args) => {
|
||||
const apiKey = process.env.LIVEKIT_API_KEY || "devkey";
|
||||
const apiSecret = process.env.LIVEKIT_API_SECRET || "secret";
|
||||
|
||||
const at = new AccessToken(apiKey, apiSecret, {
|
||||
identity: args.userId,
|
||||
name: args.username,
|
||||
});
|
||||
|
||||
at.addGrant({
|
||||
roomJoin: true,
|
||||
room: args.channelId,
|
||||
canPublish: true,
|
||||
canSubscribe: true,
|
||||
});
|
||||
|
||||
const token = await at.toJwt();
|
||||
return { token };
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user