Skip to content

Commit 80c508a

Browse files
committed
feat: remove submit
1 parent bdb3a5f commit 80c508a

File tree

1 file changed

+1
-55
lines changed

1 file changed

+1
-55
lines changed

libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -653,42 +653,6 @@ export class PostsService {
653653
return this._postRepository.countPostsFromDay(orgId, date);
654654
}
655655

656-
async submit(
657-
id: string,
658-
order: string,
659-
message: string,
660-
integrationId: string
661-
) {
662-
if (!(await this._messagesService.canAddPost(id, order, integrationId))) {
663-
throw new Error('You can not add a post to this publication');
664-
}
665-
const getOrgByOrder = await this._messagesService.getOrgByOrder(order);
666-
const submit = await this._postRepository.submit(
667-
id,
668-
order,
669-
getOrgByOrder?.messageGroup?.buyerOrganizationId!
670-
);
671-
const messageModel = await this._messagesService.createNewMessage(
672-
submit?.submittedForOrder?.messageGroupId || '',
673-
From.SELLER,
674-
'',
675-
{
676-
type: 'post',
677-
data: {
678-
id: order,
679-
postId: id,
680-
status: 'PENDING',
681-
integration: integrationId,
682-
description: message.slice(0, 300) + '...',
683-
},
684-
}
685-
);
686-
687-
await this._postRepository.updateMessage(id, messageModel.id);
688-
689-
return messageModel;
690-
}
691-
692656
async createPost(orgId: string, body: CreatePostDto): Promise<any[]> {
693657
const postList = [];
694658
for (const post of body.posts) {
@@ -723,16 +687,6 @@ export class PostsService {
723687
previousPost ? previousPost : posts?.[0]?.id
724688
);
725689

726-
if (body.order && body.type !== 'draft') {
727-
await this.submit(
728-
posts[0].id,
729-
body.order,
730-
post.value[0].content,
731-
post.integration.id
732-
);
733-
continue;
734-
}
735-
736690
if (
737691
body.type === 'now' ||
738692
(body.type === 'schedule' && dayjs(body.date).isAfter(dayjs()))
@@ -770,17 +724,9 @@ export class PostsService {
770724

771725
async changeDate(orgId: string, id: string, date: string) {
772726
const getPostById = await this._postRepository.getPostById(id, orgId);
773-
if (
774-
getPostById?.submittedForOrderId &&
775-
getPostById.approvedSubmitForOrder !== 'NO'
776-
) {
777-
throw new Error(
778-
'You can not change the date of a post that has been submitted'
779-
);
780-
}
781727

782728
await this._workerServiceProducer.delete('post', id);
783-
if (getPostById?.state !== 'DRAFT' && !getPostById?.submittedForOrderId) {
729+
if (getPostById?.state !== 'DRAFT') {
784730
this._workerServiceProducer.emit('post', {
785731
id: id,
786732
options: {

0 commit comments

Comments
 (0)