-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmake-recurring.ts
More file actions
55 lines (46 loc) · 1.7 KB
/
make-recurring.ts
File metadata and controls
55 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { connectToSuperhuman, disconnect } from "./src/superhuman-api";
async function makeRecurring(eventId: string) {
const conn = await connectToSuperhuman(9333, true);
if (!conn) return;
const result = await conn.Runtime.evaluate({
expression: `
(async () => {
try {
const ga = window.GoogleAccount;
const msgraph = ga?.di?.get?.('msgraph');
if (!msgraph) return { error: "msgraph service not found" };
const url = msgraph._fullURL('/v1.0/me/messages/' + ${JSON.stringify(eventId)}, {});
// Actually messages endpoint isn't right for calendar, should be events
const eventUrl = 'https://graph.microsoft.com/v1.0/me/events/' + ${JSON.stringify(eventId)};
const patchBody = {
recurrence: {
pattern: {
type: 'weekly',
interval: 1,
daysOfWeek: ['tuesday']
},
range: {
type: 'noEnd',
startDate: '2026-02-03'
}
}
};
const response = await msgraph._fetchJSONWithRetry(eventUrl, {
method: 'PATCH',
body: JSON.stringify(patchBody),
headers: { 'Content-Type': 'application/json' },
endpoint: 'events.update'
});
return { success: true, response };
} catch (e) {
return { error: e.message };
}
})()
`,
returnByValue: true,
awaitPromise: true
});
console.log(JSON.stringify(result.result.value, null, 2));
await disconnect(conn);
}
makeRecurring("AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0AXIqdBgk1EkKJ_kY4ZzlqaQABlgCZBQAA").catch(console.error);