fix: create post error when related post

This commit is contained in:
Innei 2023-07-30 13:43:43 +08:00
parent a0a5a3dc27
commit 72f78a2004
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
7 changed files with 497 additions and 63 deletions

View File

@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-checkout'.\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-checkout' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs post-checkout "$@"

View File

@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-commit'.\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-commit' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs post-commit "$@"

View File

@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/post-merge'.\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'post-merge' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs post-merge "$@"

View File

@ -1,3 +1,3 @@
#!/bin/sh
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'.\n"; exit 2; }
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; }
git lfs pre-push "$@"

View File

@ -63,10 +63,8 @@ export class PostService {
const relatedIds = await this.checkRelated(post)
post.related = relatedIds as any
// 双向关联
await this.relatedEachOther(post, relatedIds)
const res = await this.postModel.create({
const newPost = await this.postModel.create({
...post,
slug,
categoryId: category.id,
@ -74,7 +72,10 @@ export class PostService {
modified: null,
})
const doc = res.toJSON()
const doc = newPost.toJSON()
// 双向关联
await this.relatedEachOther(doc, relatedIds)
scheduleManager.schedule(async () => {
await Promise.all([
@ -82,8 +83,8 @@ export class PostService {
doc.text,
doc.images,
(images) => {
res.images = images
return res.save()
newPost.images = images
return newPost.save()
},
),
this.eventManager.emit(EventBusEvents.CleanAggregateCache, null, {

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ecb3ac122ac74009fdd1655b3b2fe8339da445f8a2706c0e5c31b824030444bd
size 108212
oid sha256:143ff7ee824ee8d3ff5265d0a91b594787c8026af05ee34e19d5906b2b7f2e2f
size 108992

File diff suppressed because it is too large Load Diff