Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/domain/orchestrator/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,13 @@ export class SyncOrchestrator {
throw ErrorMarkTypeError()
}

// 从 metadata 中提取 root_id、parent_id、source_id
let rootUuid = ''
let parentUuid = ''
let sourceId = ''
if (change.data['metadata']) {
try {
const metadata = JSON.parse(change.data['metadata']) as { root_id?: string; parent_id?: string; source_id?: string }
const metadata = JSON.parse(change.data['metadata']) as { root_id?: string; parent_id?: string }
rootUuid = metadata.root_id || ''
parentUuid = metadata.parent_id || ''
sourceId = metadata.source_id || ''
} catch {
// metadata parse failure
}
Expand All @@ -237,8 +234,8 @@ export class SyncOrchestrator {
parentUuid,
approxSource: change.data['approx_source'] || '',
content: change.data['content'] || '',
sourceType: sourceId ? 'bookmark' : '',
sourceId
sourceType: 'bookmark',
sourceId: ''
}
})
return
Expand Down
7 changes: 5 additions & 2 deletions src/infra/repository/dbSyncBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ export class DBSyncBatchOperation {
if (parentComment.root_id > 0) rootId = parentComment.root_id
}

const finalSourceType = sourceType || 'bookmark'
const finalSourceId = sourceId || userBookmark.id.toString()

const created = await tx.sr_bookmark_comment.create({
data: {
uuid: operation.commentUuid,
Expand All @@ -308,8 +311,8 @@ export class DBSyncBatchOperation {
parent_id: parentId,
approx_source: approxSource,
content,
source_type: sourceType,
source_id: sourceId,
source_type: finalSourceType,
source_id: finalSourceId,
is_deleted: false,
created_at: new Date(),
updated_at: new Date()
Expand Down
Loading