Skip to content

Commit

Permalink
Remove default value for post table invalid attrs (#1601)
Browse files Browse the repository at this point in the history
remove default value for post table attrs
  • Loading branch information
dholms authored Sep 14, 2023
1 parent cf6002a commit 79867d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ export async function up(db: Kysely<unknown>): Promise<void> {
.execute()
await db.schema
.alterTable('post')
.addColumn('invalidReplyRoot', 'boolean', (col) =>
col.notNull().defaultTo(false),
)
.addColumn('invalidReplyRoot', 'boolean')
.execute()
await db.schema
.alterTable('post')
.addColumn('violatesThreadGate', 'boolean', (col) =>
col.notNull().defaultTo(false),
)
.addColumn('violatesThreadGate', 'boolean')
.execute()
}

Expand Down
6 changes: 3 additions & 3 deletions packages/bsky/src/db/tables/post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Generated, GeneratedAlways } from 'kysely'
import { GeneratedAlways } from 'kysely'

export const tableName = 'post'

Expand All @@ -12,8 +12,8 @@ export interface Post {
replyParent: string | null
replyParentCid: string | null
langs: string[] | null
invalidReplyRoot: Generated<boolean>
violatesThreadGate: Generated<boolean>
invalidReplyRoot: boolean | null
violatesThreadGate: boolean | null
createdAt: string
indexedAt: string
sortAt: GeneratedAlways<string>
Expand Down
8 changes: 7 additions & 1 deletion packages/bsky/src/services/feed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ export class FeedService {
return posts.reduce((acc, cur) => {
const { recordJson, ...post } = cur
const record = jsonStringToLex(recordJson) as PostRecord
const info: PostInfo = { ...post, record, viewer }
const info: PostInfo = {
...post,
invalidReplyRoot: post.invalidReplyRoot ?? false,
violatesThreadGate: post.violatesThreadGate ?? false,
record,
viewer,
}
return Object.assign(acc, { [post.uri]: info })
}, {} as PostInfoMap)
}
Expand Down

0 comments on commit 79867d2

Please sign in to comment.