Schedule posts to Bluesky with Cloudflare workers. skyscheduler.work
cf tool bsky-tool cloudflare bluesky schedule bsky service social-media cloudflare-workers
at main 39 lines 1.9 kB view raw
1import { sql } from "drizzle-orm"; 2import { index, integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; 3import { users } from "./auth.schema"; 4 5// violations of current users of this service 6export const violations = sqliteTable('violations', { 7 id: integer('id', { mode: 'number' }).primaryKey({ autoIncrement: true }), 8 userId: text("user") 9 .notNull() 10 .references(() => users.id, { onDelete: "cascade" }).unique(), 11 // violated skyscheduler TOS 12 tosViolation: integer('tosViolation', { mode: 'boolean' }).default(false), 13 // user has an invalid username/app password from BSKY (self heals upon change) 14 userPassInvalid: integer('userPassInvalid', { mode: 'boolean' }).default(false), 15 // user is currently suspended from BSKY, 16 // tells the scheduler to skip their posts at this time (partially self heals) 17 accountSuspended: integer('accountSuspended', { mode: 'boolean' }).default(false), 18 // account is no longer available on BSKY, usually when the account is deleted from BSKY 19 accountGone: integer('accountGone', { mode: 'boolean' }).default(false), 20 // rare, when BSKY tells us that the media is not allowed to be posted. 21 // mostly for older posts, as new code handles these states better 22 // (self heals upon post deletion) 23 mediaTooBig: integer('mediaTooBig', { mode: 'boolean' }).default(false), 24 createdAt: integer('created_at', { mode: 'timestamp_ms' }) 25 .default(sql`CURRENT_TIMESTAMP`) 26 .notNull(), 27}, (table) => [ 28 // joining and querying against the table's data 29 index("violations_user_idx").on(table.userId) 30]); 31 32// banned users from skyscheduler, prevents them from signing up 33export const bannedUsers = sqliteTable('bans', { 34 did: text('account_did').primaryKey().notNull(), 35 reason: text('banReason').notNull().default(""), 36 createdAt: integer('created_at', { mode: 'timestamp_ms' }) 37 .default(sql`CURRENT_TIMESTAMP`) 38 .notNull(), 39});