- Introduced user status management with the ability to update online, busy, offline, and away statuses. - Added metadata fields for user preferences, including phrase preferences and friends list. - Updated API and database schema to accommodate new user fields. - Enhanced the authentication component to handle additional user data effectively. - Implemented hooks for socket management and OLM setup to improve user experience.
28 lines
No EOL
660 B
TypeScript
28 lines
No EOL
660 B
TypeScript
import { v } from "convex/values";
|
|
import { Id } from "../../_generated/dataModel";
|
|
import { mutation } from "../../_generated/server";
|
|
|
|
export const updateUserStatus = mutation({
|
|
args: {
|
|
status: v.string(),
|
|
isUserSet: v.boolean(),
|
|
},
|
|
handler: async (ctx, args) => {
|
|
const user = await ctx.auth.getUserIdentity();
|
|
if (!user) {
|
|
throw new Error("User not found");
|
|
}
|
|
|
|
const userId = ctx.db.normalizeId("user", user.subject as string) as Id<"user">;
|
|
if (!userId) {
|
|
throw new Error("User not found");
|
|
}
|
|
|
|
return ctx.db.patch<"user">("user", userId, {
|
|
status: {
|
|
status: args.status,
|
|
isUserSet: args.isUserSet,
|
|
},
|
|
});
|
|
},
|
|
}); |