* feat: support lark calendar * New Crowdin translations by Github Action (#3016) Co-authored-by: Crowdin Bot <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> * fix: lark calendar get app ticket bugs * feat: add send msg service for lark bot * fix: comment on PR of lark-calendar * chore: update lark bot message * Refactors add endpoint * Adds missing GET endpoint handler * Update yarn.lock * fix: comments * Update yarn.lock * fix: comment about inferred type * Added fetcher helper * Update yarn.lock Co-authored-by: chengcheng.frontend <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Crowdin Bot <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: zomars <[email protected]>
27 lines
944 B
TypeScript
27 lines
944 B
TypeScript
import logger from "@calcom/lib/logger";
|
|
|
|
import getAppKeysFromSlug from "../_utils/getAppKeysFromSlug";
|
|
import { LarkAppKeys } from "./types/LarkCalendar";
|
|
|
|
export const LARK_HOST = "open.larksuite.com";
|
|
|
|
export const getAppKeys = () => getAppKeysFromSlug("lark-calendar") as Promise<LarkAppKeys>;
|
|
|
|
export const isExpired = (expiryDate: number) =>
|
|
!expiryDate || expiryDate < Math.round(Number(new Date()) / 1000);
|
|
|
|
export async function handleLarkError<T extends { code: number; msg: string }>(
|
|
response: Response,
|
|
log: typeof logger
|
|
): Promise<T> {
|
|
const data: T = await response.json();
|
|
if (!response.ok || data.code !== 0) {
|
|
log.error("lark error with error: ", data, ", logid is:", response.headers.get("X-Tt-Logid"));
|
|
log.debug("lark request with data", data);
|
|
throw data;
|
|
}
|
|
log.info("lark request with logid:", response.headers.get("X-Tt-Logid"));
|
|
log.debug("lark request with data", data);
|
|
return data;
|
|
}
|