Skip to content

Commit 4c93304

Browse files
committed
update to add cwcc to images
1 parent f7775c7 commit 4c93304

5 files changed

Lines changed: 99 additions & 28 deletions

File tree

‎backend/firebase/functions/src/calendly/pubsub.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
queryPurrfectPageByCalendarId,
77
} from './../utilities/notion.server';
88

9-
import { getEvent, listEventInvitees } from './../utilities/calendly';
9+
import { getEvent, listEventInvitees, ccd } from './../utilities/calendly';
1010
import { utcOffset } from '../utilities/date';
1111
import { log, LogSeverity } from '../utilities/logging';
1212
import { WebhookPayload } from '../models/calendly';
@@ -23,6 +23,7 @@ export const calendlyCreateNotionCardPubSub = functions.pubsub
2323
JSON.stringify(message.json)
2424
);
2525
const eventUuid = webhookPayload?.payload?.event?.uuid;
26+
const eventType = webhookPayload?.payload?.event_type?.uuid;
2627

2728
try {
2829
const calendarIds = await queryPurrfectPageByCalendarId(eventUuid);
@@ -79,6 +80,16 @@ export const calendlyCreateNotionCardPubSub = functions.pubsub
7980
guestIds: [guestId],
8081
recordingDate: utcOffset(calendlyEvent.resource.start_time),
8182
calendarid: webhookPayload?.payload?.event?.uuid,
83+
Stream: {
84+
select: {
85+
id:
86+
eventType === ccd
87+
? 'd73f1782-28b1-4b49-9ff8-517e27dabd7a'
88+
: '15d98593-82e7-48a7-85a0-a753918d92d5',
89+
name: eventType === ccd ? 'CodingCat.dev' : 'Purrfect.dev',
90+
color: eventType === ccd ? 'purple' : 'pink',
91+
},
92+
},
8293
};
8394
log(
8495
LogSeverity.DEBUG,

‎backend/firebase/functions/src/calendly/webhook.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import * as functions from 'firebase-functions';
33
import { WebhookPayload } from '../models/calendly';
44
import { sendTopic } from '../utilities/googleapis';
55
import { queryPurrfectPageByCalendarId } from '../utilities/notion.server';
6-
7-
const ccd = `e3f45196-30ad-4597-9e7d-6b4ae147ca00`;
8-
const purrfect = `c4e6fdd3-768a-4157-846e-41b4ef5fae9d`;
9-
// const sirens = `1d4ddcce-8fac-4dfa-805b-88f3be093990`;
6+
import { ccd, purrfect } from '../utilities/calendly';
107

118
export const topicId = 'calendlyCreateNotionCard';
129

‎backend/firebase/functions/src/cloudinary/scheduledNotionCheck.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as functions from 'firebase-functions';
22
import {
3-
generateCodingCatCoverURL,
3+
generateCodeWithCodingCatCoverURL,
4+
generatePurrfectDevCoverURL,
45
uploadCloudinaryFromUrl,
56
} from '../utilities/cloudinaryUtils';
67
import { projectId } from '../config/config';
@@ -87,13 +88,16 @@ export const cloudinaryToNotionPubSub = functions.pubsub
8788
slug: `${cloudinaryFolder}/${slug}`,
8889
guestName: guestRes.properties.Name.title[0].plain_text,
8990
guestImagePublicId: res.public_id,
90-
backgroundPath: `${cloudinaryFolder}/Season2Background`,
91+
folder: `${cloudinaryFolder}`,
9192
};
9293
console.log('generating cloudinary url with: ', JSON.stringify(param));
93-
const coverUrl = (await generateCodingCatCoverURL(param)).replace(
94-
'http://',
95-
'https://'
96-
);
94+
95+
const coverUrl = (
96+
page?.properties?.Stream?.select?.id ===
97+
'd73f1782-28b1-4b49-9ff8-517e27dabd7a'
98+
? await generateCodeWithCodingCatCoverURL(param)
99+
: await generatePurrfectDevCoverURL(param)
100+
).replace('http://', 'https://');
97101
console.log('coverURL', coverUrl);
98102
const update = {
99103
page_id: page.id,

‎backend/firebase/functions/src/utilities/calendly.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import fetch from 'node-fetch';
22
import { calendlyAccessToken } from '../config/config';
33
const calendlyApi = `https://api.calendly.com`;
44

5+
export const ccd = `e3f45196-30ad-4597-9e7d-6b4ae147ca00`;
6+
export const purrfect = `c4e6fdd3-768a-4157-846e-41b4ef5fae9d`;
7+
// const sirens = `1d4ddcce-8fac-4dfa-805b-88f3be093990`;
8+
59
export const call = async (path: string) => {
610
const url = `${calendlyApi}${path}`;
711
console.log('Calling', url);

‎backend/firebase/functions/src/utilities/cloudinaryUtils.ts‎

Lines changed: 72 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,87 @@
11
import cloudinary from './cloudinary';
2+
export const generateCodeWithCodingCatCoverURL = async ({
3+
title,
4+
slug,
5+
guestName,
6+
guestImagePublicId,
7+
folder,
8+
}: {
9+
title: string;
10+
slug: string;
11+
guestName: string;
12+
guestImagePublicId: string;
13+
folder: string;
14+
}) => {
15+
const url = cloudinary.url(`${folder}/Code_with_Coding_Cat_Empty_Title`, {
16+
quality: 'auto',
17+
fetch_format: 'jpg',
18+
transformation: [
19+
{
20+
width: 990,
21+
color: '#FBFBFB',
22+
y: '550',
23+
x: '75',
24+
crop: 'fit',
25+
gravity: 'north_west',
26+
overlay: {
27+
text: title,
28+
font_family: 'Nunito',
29+
font_size: 120,
30+
font_weight: 'black',
31+
line_spacing: '-10',
32+
},
33+
},
34+
{
35+
color: '#FBFBFB',
36+
y: '10',
37+
x: '0',
38+
crop: 'fit',
39+
gravity: 'north',
40+
background: '#D11663',
41+
radius: '8:50',
42+
border: '30px_solid_rgb:D11663',
43+
overlay: {
44+
font_family: 'Nunito',
45+
font_size: 65,
46+
text: guestName,
47+
font_weight: 'bold',
48+
text_align: 'left',
49+
},
50+
},
51+
{
52+
overlay: guestImagePublicId.split('/').join(':'),
53+
height: '250',
54+
width: '250',
55+
y: '180',
56+
x: '0',
57+
gravity: 'north',
58+
crop: 'fill',
59+
border: '5px_solid_rgb:FBFBFB',
60+
},
61+
],
62+
});
263

3-
export const generateCodingCatCoverURL = async ({
64+
//Write real image with new name
65+
const res = await cloudinary.uploader.upload(url, {
66+
public_id: slug,
67+
});
68+
return res.secure_url;
69+
};
70+
71+
export const generatePurrfectDevCoverURL = async ({
472
title,
573
slug,
674
guestName,
775
guestImagePublicId,
8-
backgroundPath,
76+
folder,
977
}: {
1078
title: string;
1179
slug: string;
1280
guestName: string;
1381
guestImagePublicId: string;
14-
backgroundPath: string;
82+
folder: string;
1583
}) => {
16-
const url = cloudinary.url(backgroundPath, {
84+
const url = cloudinary.url(`${folder}/Season2Background`, {
1785
quality: 'auto',
1886
fetch_format: 'jpg',
1987
transformation: [
@@ -36,19 +104,6 @@ export const generateCodingCatCoverURL = async ({
36104
text_align: 'center',
37105
},
38106
},
39-
{
40-
color: '#FBFBFB',
41-
y: '577',
42-
x: '45',
43-
crop: 'limit',
44-
gravity: 'south_west',
45-
overlay: {
46-
font_family: 'Nunito',
47-
font_weight: 'bold',
48-
font_size: 60,
49-
text: 'With',
50-
},
51-
},
52107
{
53108
color: '#D11663',
54109
y: '410',

0 commit comments

Comments
 (0)