import { getHit as dbGetHit, postHit as dbPostHit } from "@/app/www/system/DB";
import { isBannedIP } from "@/app/www/utilities/Utility";
import dayjs from "dayjs";
import { getDate } from "taehui-lib/date";

export const getHit = async () => {
  return dbGetHit(getDate(), dayjs().subtract(1, "day").format("YYYY-MM-DD"));
};

export const postHit = async (avatarIP: string) => {
  if (isBannedIP(avatarIP)) {
    return false;
  } else {
    return dbPostHit(avatarIP, getDate());
  }
};
