import { autumn } from './autumn';
export const create = mutation({
args: {
name: v.string(),
description: v.optional(v.string()),
type: v.optional(v.union(v.literal("group"), v.literal("channel"))),
isPrivate: v.optional(v.boolean()),
},
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
throw new Error("Not authenticated");
}
// Check channel limit using Autumn
const checkResult = await autumn.check(ctx, {
featureId: CHANNEL_FEATURE_ID,
});
console.log('checkResult', checkResult);
if (!checkResult.data) {
throw new Error("Error checking channel limit");
}
if (!checkResult.data.allowed && !checkResult.data.unlimited) {
throw new Error(
"Channel limit reached. Upgrade to Pro to create unlimited channels.",
);
}
import { autumn } from './autumn';
export const create = mutation({
args: {
name: v.string(),
description: v.optional(v.string()),
type: v.optional(v.union(v.literal("group"), v.literal("channel"))),
isPrivate: v.optional(v.boolean()),
},
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
throw new Error("Not authenticated");
}
// Check channel limit using Autumn
const checkResult = await autumn.check(ctx, {
featureId: CHANNEL_FEATURE_ID,
});
console.log('checkResult', checkResult);
if (!checkResult.data) {
throw new Error("Error checking channel limit");
}
if (!checkResult.data.allowed && !checkResult.data.unlimited) {
throw new Error(
"Channel limit reached. Upgrade to Pro to create unlimited channels.",
);
}