Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content.teaser is not optional when Typescript is used #3

Closed
plankter opened this issue Oct 26, 2016 · 2 comments
Closed

content.teaser is not optional when Typescript is used #3

plankter opened this issue Oct 26, 2016 · 2 comments
Assignees
Labels

Comments

@plankter
Copy link

plankter commented Oct 26, 2016

If one does not provide content.teaser in getContent hook, then there is an exception:

stack":"TypeError: Cannot read property 'length' of 
  at Object.truncate (/app/node_modules/redis-notifications/lib/utils.js:135:14
  at Object.default (/app/node_modules/redis-notifications/lib/schemas/message-content.js:32:22
  at MessageContentSchema.module.exports.ObjSchema._validateKey (/app/node_modules/obj-schema/lib/main.js:157:33
  at MessageContentSchema._validateKey (/app/node_modules/obj-schema/lib/main.js:5:59
  at MessageContentSchema.module.exports.ObjSchema.validate (/app/node_modules/obj-schema/lib/main.js:123:21
  at MessageContentSchema.validate (/app/node_modules/obj-schema/lib/main.js:5:59
  at MessageContentSchema.module.exports.ObjSchema.validateCb (/app/node_modules/obj-schema/lib/main.js:86:19
  at /app/node_modules/obj-schema/lib/main.js:5:
  at /app/node_modules/redis-notifications/lib/tasks.js:181:
  at RedisNotifications.NotificationManager.nf.on (/app/server/utils/NotificationManager.js:82:13
  at emitMany (events.js:127:13
  at RedisNotifications.emit (events.js:201:7
  at RNTasks._getMessageContent (/app/node_modules/redis-notifications/lib/tasks.js:172:17
  at RNTasks._getMessageContent (/app/node_modules/redis-notifications/lib/tasks.js:3:59
  at /app/node_modules/redis-notifications/lib/tasks.js:77:17

it seems that the issue occurs due to the following code in "utils.coffee" file, where "str" argument expected to be defined:

@return { String } the truncated string
    ###
    truncate: ( str, len = 100, add = "...", tolerance = 5 )->
        if str.length > ( len * ( 1 + tolerance/100 ) )
            return str.substr( 0, str.indexOf( " ", len ) ) + ( add or "" )
        return str
@mpneuried mpneuried self-assigned this Oct 27, 2016
@mpneuried mpneuried added the bug label Oct 27, 2016
@mpneuried
Copy link
Owner

i made a small fix with version 0.2.1 bfa9378

@plankter
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants