wonderfulBlushMagpiemain.tsx6 matches
1112useEffect(() => {
13fetchShorts();
14}, []);
1516const fetchShorts = async () => {
17try {
18const response = await fetch('/get-shorts');
19const data = await response.json();
20setShorts(data);
21} catch (err) {
22console.error('Failed to fetch shorts', err);
23}
24};
4041try {
42const response = await fetch('/add-short', {
43method: 'POST',
44headers: {
50if (response.ok) {
51setNewShortLink('');
52fetchShorts();
53}
54} catch (err) {
instagram-toolsfollows-check.jsx4 matches
1import makeFetchCookie from "npm:fetch-cookie";
2const fetchCookie = makeFetchCookie(fetch);
34export default async function handleCron(interval) {
5const following = await fetchCookie(
6"https://www.instagram.com/api/v1/friendships/375942300/following/?query=miguelse10",
7{
16const isFollowing = following.users.some((user) => user.username === "miguelse10");
1718const pushNotification = await fetchCookie("https://ntfy.sh/alEMfLpdpoXMe6jB", {
19method: "POST",
20body: `Mafalda ${isFollowing ? "lo estΓ‘ siguiendo" : "no lo estΓ‘ siguiendo"} a Miguel.`,
139const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
140141const response = await fetch(url, {
142method: "PATCH",
143headers: {
77console.log("Current PR labels:", currentLabels);
7879// Fetch labels from all linked issues
80const repo = payload.repository.full_name;
81let allIssueLabels: string[] = [];
8283for (const issueNumber of issueNumbers) {
84console.log(`Fetching labels for issue #${issueNumber}`);
85try {
86const issue = await fetchIssue(repo, issueNumber);
87const issueLabels = issue.labels.map(label => label.name);
88console.log(`Labels for issue #${issueNumber}:`, issueLabels);
95}
96} catch (error) {
97console.error(`Error fetching issue #${issueNumber}:`, error);
98}
99}
154}
155156// Fetch issue details
157async function fetchIssue(repo: string, issueNumber: number): Promise<GitHubIssue> {
158const token = Deno.env.get("GITHUB_TOKEN");
159164const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}`;
165166const response = await fetch(url, {
167headers: {
168"Authorization": `token ${token}`,
180// If we can't parse the error as JSON, use the status text
181}
182throw new Error(`Failed to fetch issue: ${errorMessage}`);
183}
184197const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/labels`;
198199const response = await fetch(url, {
200method: "POST",
201headers: {
108// Get detailed PR info including checks status
109try {
110const prDetails = await fetchPRDetails(payload.repository.full_name, payload.pull_request.number);
111console.log(`PR mergeable status: ${prDetails.mergeable}, state: ${prDetails.mergeable_state}`);
112130return new Response("Notification sent to Slack", { status: 200 });
131} catch (prError) {
132console.error("Error fetching PR details or sending notification:", prError);
133return new Response(`Error: ${prError.message}`, { status: 500 });
134}
211}
212213// Fetch detailed PR information including checks status
214async function fetchPRDetails(repo: string, prNumber: number) {
215const token = Deno.env.get("GITHUB_TOKEN");
216if (!token) {
223let response;
224try {
225response = await fetch(url, {
226headers: {
227"Authorization": `token ${token}`,
230},
231});
232} catch (fetchError) {
233throw new Error(`Network error fetching PR details: ${fetchError.message}`);
234}
235236if (!response.ok) {
237throw new Error(`Failed to fetch PR details: ${response.status} ${response.statusText}`);
238}
239255// First, verify the PR is still mergeable
256try {
257const prDetails = await fetchPRDetails(repo, prNumber);
258259if (!prDetails.mergeable) {
284const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/merge`;
285286const response = await fetch(url, {
287method: "PUT",
288headers: {
415416// Send message to Slack
417const response = await fetch(slackWebhookUrl, {
418method: "POST",
419headers: {
101const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/assignees`;
102103const response = await fetch(url, {
104method: "POST",
105headers: {
132console.log("π Sending assignee request to:", url);
133134const response = await fetch(url, {
135method: "POST",
136headers: {
170171// Get detailed PR info including checks status
172console.log("π Fetching detailed PR info...");
173try {
174const prDetails = await fetchPRDetails(repository.full_name, pull_request.number);
175console.log("π PR details fetched successfully");
176console.log("π PR mergeable status:", prDetails.mergeable);
177console.log("π PR mergeable state:", prDetails.mergeable_state);
202return new Response("Notification sent to Slack", { status: 200 });
203} catch (prError) {
204console.error("β Error fetching PR details or sending notification:", prError);
205console.error("β Error stack:", prError.stack);
206return new Response(`Error: ${prError.message}\nStack: ${prError.stack}`, { status: 500 });
311}
312313// Fetch detailed PR information including checks status
314async function fetchPRDetails(repo: string, prNumber: number) {
315console.log(`π Starting fetchPRDetails for PR #${prNumber} in ${repo}`);
316317const token = Deno.env.get("GITHUB_TOKEN");
324// Get PR details
325const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
326console.log("π Fetching from GitHub API URL:", url);
327328let response;
329try {
330response = await fetch(url, {
331headers: {
332"Authorization": `token ${token}`,
339console.log("π Response status text:", response.statusText);
340console.log("π Response headers:", JSON.stringify(Object.fromEntries([...response.headers])));
341} catch (fetchError) {
342console.error("β Network error fetching PR details:", fetchError);
343console.error("β Error stack:", fetchError.stack);
344throw new Error(`Network error fetching PR details: ${fetchError.message}`);
345}
346364}
365366throw new Error(`Failed to fetch PR details: ${response.status} ${response.statusText}`);
367}
368415console.log("π Verifying PR is still mergeable before attempting merge");
416try {
417const prDetails = await fetchPRDetails(repo, prNumber);
418console.log("π PR current mergeable status:", prDetails.mergeable);
419console.log("π PR current mergeable state:", prDetails.mergeable_state);
458let response;
459try {
460response = await fetch(url, {
461method: "PUT",
462headers: {
472console.log("π Response status text:", response.statusText);
473console.log("π Response headers:", JSON.stringify(Object.fromEntries([...response.headers])));
474} catch (fetchError) {
475console.error("β Network error during merge request:", fetchError);
476console.error("β Error stack:", fetchError.stack);
477return {
478success: false,
479message: `Network error during merge: ${fetchError.message}`,
480};
481}
631let response;
632try {
633response = await fetch(slackWebhookUrl, {
634method: "POST",
635headers: {
642console.log("π Response status text:", response.statusText);
643console.log("π Response headers:", JSON.stringify(Object.fromEntries([...response.headers])));
644} catch (fetchError) {
645console.error("β Network error sending to Slack:", fetchError);
646console.error("β Error stack:", fetchError.stack);
647throw new Error(`Network error sending to Slack: ${fetchError.message}`);
648}
649
110console.log("π Current PR labels:", currentLabels);
111112// Fetch labels from all linked issues
113const repo = payload.repository.full_name;
114let allIssueLabels: string[] = [];
115116for (const issueNumber of issueNumbers) {
117console.log(`π Fetching labels for issue #${issueNumber}`);
118try {
119const issue = await fetchIssue(repo, issueNumber);
120const issueLabels = issue.labels.map(label => label.name);
121console.log(`π Labels for issue #${issueNumber}:`, issueLabels);
128}
129} catch (error) {
130console.error(`β Error fetching issue #${issueNumber}:`, error);
131}
132}
190}
191192// Fetch issue details
193async function fetchIssue(repo: string, issueNumber: number): Promise<GitHubIssue> {
194const token = Deno.env.get("GITHUB_TOKEN");
195199200const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}`;
201console.log("π Fetching issue from:", url);
202203const response = await fetch(url, {
204headers: {
205"Authorization": `token ${token}`,
221console.error("β GitHub API error text:", errorText);
222}
223throw new Error(`Failed to fetch issue: ${errorMessage}`);
224}
225240console.log("π Sending labels update request to:", url);
241242const response = await fetch(url, {
243method: "POST",
244headers: {
166console.log("π Sending title update request to:", url);
167168const response = await fetch(url, {
169method: "PATCH",
170headers: {