You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I am trying to attach other fields other than just a string to a message (i.e. other headers that will be used to be displayed with the message) and found in the MessagesCollection schema that the message body can accept either a string or an object.
But attempting to execute this:
let convo = ConversationsCollection.findOne()
convo.sendMessage({a:1, b:2})
Note: A conversation document does exist and is failing on sendMessage.
this error was thrown:
Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' http://*.googleapis.com https://*.googleapis.com http://*.gstatic.com https://*.gstatic.com http://testing-zuus-mobile.s3.amazonaws.com https://testing-zuus-mobile.s3.amazonaws.com http://zuus-profile.s3.amazonaws.com https://zuus-profile.s3.amazonaws.com http://meteor.local http://*.meteor.com https://*.meteor.com http://*.cloudfront.net https://*.cloudfront.net".
modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:43834
at Function (<anonymous>)
at modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:43834
at apply (modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:42819)
at modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:43871
at apply (modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:42821)
at modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:43062
at template (modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:43833)
at MessageBox.message (modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:40676)
at SimpleSchema.messageForError (modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:29982)
at ValidationContext.keyErrorMessage (modules.js?hash=c55094c9810325902eeae61b1408a9880de63896:30516)
Am I making the wrong assuming that it is possible to pass in an object?
I know a workaround is to wrap the object with JSON.stringify and JSON.parse but I really don't want to do this unless I have to.
The text was updated successfully, but these errors were encountered:
Strange. sendMessage should accept object (though for a different reason than you want to use, still that is fine). The error is also strange as it pertains to your browser-policy. Try disabling it for a test if that changes anything.
The error in this case is definitely weird, but I do think that issue lies in both in the definition for body, and a bug in SimpleSchema. Looking into this, the schema definition for body is specified as SimpleSchema.oneOf(String, Object) which would lead to the thought that it would accept either, except that objects have keys that would also need to either be defined in the schema so they can be validated, or blackbox needs to be specified in the field definition to allow any key in that field to pass validation.
I initially thought that I could just set add blackbox:true to the definition for the body field and SimpleSchema would use that when it encountered an object instead of a string. This however does not appear to be the case. If I change the definition to just be a type of object and specify blackbox to be true, then everything works fine.
Fortunately this is easily mitigated just by extending the schema with a new definition for the body field in you project..
This will replace the body definition and leave the rest of the schema in tact.
I'll look into how simple schema handles oneOf and see about opening an issue and PR to fix it and then once that gets merged I'll issue a patch for this package.
So I am trying to attach other fields other than just a string to a message (i.e. other headers that will be used to be displayed with the message) and found in the MessagesCollection schema that the message body can accept either a string or an object.
But attempting to execute this:
Note: A conversation document does exist and is failing on sendMessage.
this error was thrown:
Am I making the wrong assuming that it is possible to pass in an object?
I know a workaround is to wrap the object with JSON.stringify and JSON.parse but I really don't want to do this unless I have to.
The text was updated successfully, but these errors were encountered: