mirror of
https://github.com/hanzoai/calendar.git
synced 2026-09-24 22:42:24 +00:00
* feat: Cal.diy — community-driven MIT-licensed fork of Cal.com This squashed commit contains all Cal.diy changes applied on top of calcom/cal.com main: - Rebrand Cal.com to Cal.diy across the entire codebase - Remove Enterprise Edition (EE) features, license checks, and AGPL restrictions - Switch license from AGPL-3.0 to MIT - Remove docs/ directory (migrated to Nextra at cal.diy) - Remove dead code: org tests, EE tips, platform nav, premium username, SAML/SSO, etc. - Clean up .env.example for self-hosted Cal.diy - Update Docker image references to calcom/cal.diy - Update README, CONTRIBUTING.md, and issue templates for Cal.diy community fork - Add PR welcome bot for Cal.diy contributors - Fix API v2 breaking changes oasdiff ignore entries - Replace Blacksmith CI runners with default GitHub Actions 3893 files changed, 20789 insertions(+), 411020 deletions(-) Co-Authored-By: [email protected] <[email protected]> * refactor: remove org-specific /organizations/:orgId endpoints from API v2 atoms controllers (#1701) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: revert Cal.diy Inc to Cal.com, Inc. in license files, copyright notices, and package metadata (#1702) Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * rip out org related comments in api v2 --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
131 lines
3.1 KiB
TypeScript
131 lines
3.1 KiB
TypeScript
import logger from "@calcom/lib/logger";
|
|
|
|
import { LARK_HOST } from "../common";
|
|
import { getAppAccessToken } from "./AppAccessToken";
|
|
|
|
const log = logger.getSubLogger({ prefix: [`[[LarkTenantCredential]`] });
|
|
|
|
const msg = {
|
|
en_us: {
|
|
title: "Welcome to Cal.diy!",
|
|
content: [
|
|
[
|
|
{
|
|
tag: "text",
|
|
text: "Cal.diy is an open source scheduling infrastructure.",
|
|
},
|
|
],
|
|
[
|
|
{
|
|
tag: "text",
|
|
text: 'It allows users to send a unique "cal.com" URL that allows anyone to create bookings on their calendars',
|
|
},
|
|
],
|
|
[
|
|
{
|
|
tag: "text",
|
|
text: "",
|
|
},
|
|
],
|
|
[
|
|
{
|
|
tag: "text",
|
|
text: "Get started",
|
|
},
|
|
],
|
|
[
|
|
{
|
|
tag: "text",
|
|
text: "1. Visit https://cal.com and sign up for an account.",
|
|
},
|
|
],
|
|
[
|
|
{
|
|
tag: "text",
|
|
text: '2. Then go to "Apps" in Cal -> install ',
|
|
},
|
|
{
|
|
tag: "a",
|
|
text: '"Larksuite Calendar"',
|
|
href: "https://www.larksuite.com/hc/articles/057527702350",
|
|
},
|
|
{
|
|
tag: "text",
|
|
text: " -> sign-in via Lark",
|
|
},
|
|
],
|
|
[
|
|
{
|
|
tag: "text",
|
|
text: "3. Done. Create your Event Types and share your booking links with external participants!",
|
|
},
|
|
],
|
|
[
|
|
{
|
|
tag: "text",
|
|
text: "",
|
|
},
|
|
],
|
|
[
|
|
{
|
|
tag: "text",
|
|
text: "Do not hesitate to reach out to our agents if you need any assistance.",
|
|
},
|
|
],
|
|
[
|
|
{
|
|
tag: "a",
|
|
text: "Get Help",
|
|
href: "https://applink.larksuite.com/client/helpdesk/open?id=6650327445582905610",
|
|
},
|
|
],
|
|
],
|
|
},
|
|
};
|
|
|
|
async function getTenantAccessTokenByTenantKey(tenantKey: string): Promise<string> {
|
|
try {
|
|
const appAccessToken = await getAppAccessToken();
|
|
const resp = await fetch(`https://${LARK_HOST}/open-apis/auth/v3/tenant_access_token`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
app_access_token: appAccessToken,
|
|
tenant_key: tenantKey,
|
|
}),
|
|
});
|
|
const data = await resp.json();
|
|
return data.tenant_access_token;
|
|
} catch (error) {
|
|
log.error(error);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
export async function sendPostMsg(
|
|
tenantKey: string,
|
|
senderOpenId: string,
|
|
message: string = JSON.stringify(msg)
|
|
): Promise<{ code: number; msg: string }> {
|
|
const tenantAccessToken = await getTenantAccessTokenByTenantKey(tenantKey);
|
|
|
|
const response = await fetch(`https://${LARK_HOST}/open-apis/im/v1/messages?receive_id_type=open_id`, {
|
|
method: "POST",
|
|
headers: {
|
|
Authorization: `Bearer ${tenantAccessToken}`,
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify({
|
|
receive_id: senderOpenId,
|
|
content: message,
|
|
msg_type: "post",
|
|
}),
|
|
});
|
|
|
|
const responseBody = await response.json();
|
|
log.debug("send message success", responseBody);
|
|
return responseBody;
|
|
}
|