Skip to content

Commit 092f4be

Browse files
committed
feat: fix mapping
1 parent 9c94bdf commit 092f4be

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class PostsService {
162162
const getImageList = await Promise.all(
163163
(
164164
await Promise.all(
165-
imagesList.map(async (p: any) => {
165+
(imagesList || []).map(async (p: any) => {
166166
if (!p.path && p.id) {
167167
imageUpdateNeeded = true;
168168
return this._mediaService.getMediaById(p.id);
@@ -260,7 +260,7 @@ export class PostsService {
260260
const list = {
261261
group: posts?.[0]?.group,
262262
posts: await Promise.all(
263-
posts.map(async (post) => ({
263+
(posts || []).map(async (post) => ({
264264
...post,
265265
image: await this.updateMedia(
266266
post.id,
@@ -377,7 +377,7 @@ export class PostsService {
377377
return post;
378378
}
379379

380-
const ids = extract.map((e) => e.replace('(post:', '').replace(')', ''));
380+
const ids = (extract || []).map((e) => e.replace('(post:', '').replace(')', ''));
381381
const urls = await this._postRepository.getPostUrls(orgId, ids);
382382
const newPlainText = ids.reduce((acc, value) => {
383383
const findUrl = urls?.find?.((u) => u.id === value)?.releaseURL || '';
@@ -464,7 +464,7 @@ export class PostsService {
464464
integration.internalId,
465465
integration.token,
466466
await Promise.all(
467-
newPosts.map(async (p) => ({
467+
(newPosts || []).map(async (p) => ({
468468
id: p.id,
469469
message: p.content,
470470
settings: JSON.parse(p.settings || '{}'),
@@ -678,12 +678,12 @@ export class PostsService {
678678
async createPost(orgId: string, body: CreatePostDto): Promise<any[]> {
679679
const postList = [];
680680
for (const post of body.posts) {
681-
const messages = post.value.map((p) => p.content);
681+
const messages = (post.value || []).map((p) => p.content);
682682
const updateContent = !body.shortLink
683683
? messages
684684
: await this._shortLinkService.convertTextToShortLinks(orgId, messages);
685685

686-
post.value = post.value.map((p, i) => ({
686+
post.value = (post.value || []).map((p, i) => ({
687687
...p,
688688
content: updateContent[i],
689689
}));

0 commit comments

Comments
 (0)