import { prisma } from "../../db/prisma.js";

export const notifyService = {
  async createRule(input: {
    guildId: string;
    channelId: string;
    cronExpr: string;
    message: string;
  }) {
    return prisma.notificationRule.create({ data: input });
  },

  async listRules(guildId: string) {
    return prisma.notificationRule.findMany({
      where: { guildId, enabled: true },
      orderBy: { createdAt: "desc" },
      take: 20,
    });
  },

  async disableRule(id: string, guildId: string) {
    return prisma.notificationRule.update({
      where: { id },
      data: { enabled: false },
    });
  },
};
