Schedule posts to Bluesky with Cloudflare workers. skyscheduler.work
cf tool bsky-tool cloudflare bluesky schedule bsky service social-media cloudflare-workers

fix media too big

idk why this queue even fired again several minutes beforehand.

+14 -4
+4 -3
src/utils/bskyApi.ts
··· 371 371 uploadFile = await agent.uploadBlob(fileBlob, {encoding: file.httpMetadata?.contentType }); 372 372 } catch (err) { 373 373 if (err instanceof XRPCError) { 374 - if (err.status === ResponseType.InternalServerError) { 374 + if (err.status === ResponseType.InternalServerError || err.status === ResponseType.UpstreamFailure 375 + || err.status === ResponseType.UpstreamTimeout) { 375 376 console.warn(`Encountered internal server error on ${currentEmbed.content} for post ${postData.postid}`); 376 377 return false; 377 378 } 378 379 } 379 380 // Give violation mediaTooBig if the file is too large. 380 - await createViolationForUser(c, postData.user, AccountStatus.MediaTooBig); 381 - console.warn(`Unable to upload ${currentEmbed.content} for post ${postData.postid} with err ${err}`); 381 + //await createViolationForUser(c, postData.user, AccountStatus.MediaTooBig); 382 + console.error(`Unable to upload ${currentEmbed.content} for post ${postData.postid} with err ${err}`); 382 383 return false; 383 384 } 384 385
+10 -1
src/utils/db/violations.ts
··· 1 1 import { and, eq, ne } from "drizzle-orm"; 2 2 import { DrizzleD1Database } from "drizzle-orm/d1"; 3 + import flatten from "just-flatten-it"; 4 + import isEmpty from "just-is-empty"; 3 5 import { bannedUsers, violations } from "../../db/enforcement.schema"; 4 6 import { AccountStatus, AllContext, LooseObj, Violation } from "../../types.d"; 5 7 import { lookupBskyHandle } from "../bskyApi"; ··· 74 76 console.error("unable to get database to create violations for"); 75 77 return false; 76 78 } 77 - const valuesUpdate:LooseObj = createObjForValuesChange([violationType], true); 79 + let violationsArray = []; 80 + violationsArray.push(violationType); 81 + const valuesUpdate: LooseObj = createObjForValuesChange(flatten(violationsArray), true); 78 82 if (violationType === AccountStatus.TOSViolation) { 79 83 const bskyUsername = await getUsernameForUserId(c, userId); 80 84 if (bskyUsername !== null) { ··· 82 86 } else { 83 87 console.warn(`unable to get bsky username for id ${userId}`); 84 88 } 89 + } 90 + 91 + if (isEmpty(valuesUpdate)) { 92 + console.warn(`Unable to give violations to ${userId}`); 93 + return false; 85 94 } 86 95 87 96 const {success} = await db.insert(violations).values({userId: userId, ...valuesUpdate})