fix: Added check for null in Message constructor (#253)

Co-authored-by: Walterskirchen <walterskirchen@walter-group.com>
Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
Maximilian Walterskirchen
2020-06-17 00:15:19 +02:00
committed by GitHub
parent d7459eac23
commit 6c7a3f9899

View File

@@ -64,7 +64,7 @@ class Message extends Base {
* ID for the Chat that this message was sent to, except if the message was sent by the current user.
* @type {string}
*/
this.from = typeof (data.from) === 'object' ? data.from._serialized : data.from;
this.from = (typeof (data.from) === 'object' && data.from !== null) ? data.from._serialized : data.from;
/**
* ID for who this message is for.
@@ -73,13 +73,13 @@ class Message extends Base {
* If the message is sent by another user, it will be the ID for the current user.
* @type {string}
*/
this.to = typeof (data.to) === 'object' ? data.to._serialized : data.to;
this.to = (typeof (data.to) === 'object' && data.to !== null) ? data.to._serialized : data.to;
/**
* If the message was sent to a group, this field will contain the user that sent the message.
* @type {string}
*/
this.author = typeof (data.author) === 'object' ? data.author._serialized : data.author;
this.author = (typeof (data.author) === 'object' && data.author !== null) ? data.author._serialized : data.author;
/**
* Indicates if the message was forwarded