daniel-sc / rocketchat-modern-client

Client SDK for https://rocket.chat employing reactive style.
MIT License
11 stars 11 forks source link

Can't send message with attachments to RC 2.2.0 when links are omitted #8

Closed GJKrupa closed 5 years ago

GJKrupa commented 5 years ago

When trying to send an extended message with attachments to RC 2.2.0, the server responds with success but I see a rocket.cat message of "Error" appear immediately and the server shows the following in the logs:

server.js:204 System ➔ error Error sending message: { Error: Invalid href value provided
    at Where.Match.Where.value [as condition] (app/lib/server/functions/sendMessage.js:25:9)
    at testSubtree (packages/check/match.js:308:24)
    at check (packages/check/match.js:34:18)
    at Object.keys.forEach.field (app/lib/server/functions/sendMessage.js:39:5)
    at Array.forEach (<anonymous>)
    at Where.Match.Where.value [as condition] (app/lib/server/functions/sendMessage.js:36:21)
    at testSubtree (packages/check/match.js:308:24)
    at check (packages/check/match.js:34:18)
    at validateAttachment (app/lib/server/functions/sendMessage.js:76:2)
    at Array.map (<anonymous>)
    at validateBodyAttachments (app/lib/server/functions/sendMessage.js:114:62)
    at validateMessage (app/lib/server/functions/sendMessage.js:128:3)
    at sendMessage (app/lib/server/functions/sendMessage.js:137:2)
    at MethodInvocation.sendMessage (app/lib/server/methods/sendMessage.js:86:11)
    at MethodInvocation.methodsMap.(anonymous function) (app/lib/server/lib/debug.js:67:34)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1771:12)
    at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
    at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
    at Promise (packages/ddp-server/livedata_server.js:715:46)
    at new Promise (<anonymous>)
    at Session.method (packages/ddp-server/livedata_server.js:689:23)
    at packages/ddp-server/livedata_server.js:559:43 path: 'author_link' }

This occurs if I don't explicitly set one or more of the following:

The root cause appears to be that RC 2.0.0+ doesn't consider empty string ("") to be an omitted value any more and is running URL validity checks on them. If I explicitly set each of them to null then the message is sent successfully.