feat: set body
This commit is contained in:
parent
910bff624b
commit
894cb33c97
|
|
@ -265,14 +265,16 @@ export class PostsRepository {
|
|||
});
|
||||
}
|
||||
|
||||
async changeState(id: string, state: State, err?: string) {
|
||||
async changeState(id: string, state: State, err?: any, body?: any) {
|
||||
const update = await this._post.model.post.update({
|
||||
where: {
|
||||
id,
|
||||
},
|
||||
data: {
|
||||
state,
|
||||
error: typeof err === 'string' ? err : JSON.stringify(err),
|
||||
...(err
|
||||
? { error: typeof err === 'string' ? err : JSON.stringify(err) }
|
||||
: {}),
|
||||
},
|
||||
include: {
|
||||
integration: {
|
||||
|
|
@ -283,7 +285,7 @@ export class PostsRepository {
|
|||
},
|
||||
});
|
||||
|
||||
if (state === 'ERROR') {
|
||||
if (state === 'ERROR' && err && body) {
|
||||
try {
|
||||
await this._errors.model.errors.create({
|
||||
data: {
|
||||
|
|
@ -291,6 +293,7 @@ export class PostsRepository {
|
|||
organizationId: update.organizationId,
|
||||
platform: update.integration.providerIdentifier,
|
||||
postId: update.id,
|
||||
body: typeof body === 'string' ? body : JSON.stringify(body),
|
||||
},
|
||||
});
|
||||
} catch (err) {}
|
||||
|
|
|
|||
|
|
@ -282,7 +282,8 @@ export class PostsService {
|
|||
}
|
||||
|
||||
async post(id: string) {
|
||||
const [firstPost, ...morePosts] = await this.getPostsRecursively(id, true);
|
||||
const allPosts = await this.getPostsRecursively(id, true);
|
||||
const [firstPost, ...morePosts] = allPosts;
|
||||
if (!firstPost) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -337,7 +338,7 @@ export class PostsService {
|
|||
return;
|
||||
}
|
||||
} catch (err: any) {
|
||||
await this._postRepository.changeState(firstPost.id, 'ERROR', err);
|
||||
await this._postRepository.changeState(firstPost.id, 'ERROR', err, allPosts);
|
||||
if (err instanceof BadBody) {
|
||||
await this._notificationService.inAppNotification(
|
||||
firstPost.organizationId,
|
||||
|
|
|
|||
|
|
@ -643,6 +643,7 @@ model ThirdParty {
|
|||
model Errors {
|
||||
id String @id @default(uuid())
|
||||
message String
|
||||
body String @default("{}")
|
||||
platform String
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id])
|
||||
|
|
|
|||
Loading…
Reference in New Issue