MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / insertNoteChildComment

Function insertNoteChildComment

shared-edge/src/kysely.ts:792–828  ·  view source on GitHub ↗
(
	parentCommentId: CommentId,
	text: string,
	authorId: UserId,
)

Source from the content-addressed store, hash-verified

790}
791
792export async function insertNoteChildComment(
793 parentCommentId: CommentId,
794 text: string,
795 authorId: UserId,
796) {
797 const parentCommentDbId = fromBase64Url(parentCommentId)
798 const parent = await db
799 .selectFrom('noteComment')
800 .select(['level', 'noteId'])
801 .where('id', '=', parentCommentDbId)
802 .executeTakeFirst()
803 if (parent == null) throwExp(`Comment ${parentCommentId} not found.`)
804 await db.transaction().execute(
805 async (tx) =>
806 await Promise.all([
807 tx
808 .updateTable('note')
809 .set({
810 commentsCount: (x) => sql`${x.ref('commentsCount')} + 1`,
811 })
812 .where('note.id', '=', parent.noteId)
813 .execute(),
814 await tx
815 .insertInto('noteComment')
816 .values({
817 id: unhex(hexId()),
818 authorId,
819 level: parent.level + 1,
820 noteId: parent.noteId,
821 votes: '',
822 text,
823 parentId: parentCommentDbId,
824 })
825 .execute(),
826 ]),
827 )
828}
829
830export async function userOwnsNoteAndHasMedia(
831 ids: RemoteNoteId[],

Callers 1

noteRouter.tsFile · 0.90

Calls 4

throwExpFunction · 0.90
hexIdFunction · 0.90
fromBase64UrlFunction · 0.85
unhexFunction · 0.85

Tested by

no test coverage detected