Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

Commit

Permalink
fix conversation content max length
Browse files Browse the repository at this point in the history
  • Loading branch information
BatAmar Battulga committed Nov 29, 2019
1 parent 9127c7c commit 467d074
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"nodemailer": "^4.0.1",
"q": "^1.5.1",
"snyk": "^1.239.5",
"strip": "^3.0.0",
"underscore": "^1.8.3",
"validator": "^10.9.0"
},
Expand Down
8 changes: 6 additions & 2 deletions src/data/resolvers/mutations/messenger.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as strip from 'strip';

import { Brands, Companies, Conversations, Customers, Integrations, Messages } from '../../../db/models';

import { IBrowserInfo, IVisitorContactInfoParams } from '../../../db/models/Customers';
Expand Down Expand Up @@ -112,12 +114,14 @@ export default {
) {
const { integrationId, customerId, conversationId, message, attachments } = args;

const conversationContent = strip(message || '').substring(0, 100);

// get or create conversation
const conversation = await Conversations.getOrCreateConversation({
conversationId,
integrationId,
customerId,
content: message,
content: conversationContent,
});

// create message
Expand All @@ -136,7 +140,7 @@ export default {
status: Conversations.getConversationStatuses().OPEN,

// setting conversation's content to last message
content: message,
content: conversationContent,

// Mark as unread
readUserIds: [],
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7878,6 +7878,11 @@ strip-json-comments@^2.0.0, strip-json-comments@~2.0.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=

strip@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/strip/-/strip-3.0.0.tgz#750fc933152a7d35af0b7420e651789b914cc35e"
integrity sha1-dQ/JMxUqfTWvC3Qg5lF4m5FMw14=

subarg@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/subarg/-/subarg-1.0.0.tgz#f62cf17581e996b48fc965699f54c06ae268b8d2"
Expand Down

0 comments on commit 467d074

Please sign in to comment.