Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F7159773
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/message.js b/lib/message.js
index 004b72a..ae37f36 100644
--- a/lib/message.js
+++ b/lib/message.js
@@ -1,105 +1,106 @@
import debug from 'debug';
import { v4 as uuidv4 } from 'uuid';
import utils from './utils';
import { EventEmitter } from 'events';
const DEBUG = debug('sylkrtc:Message');
class Message extends EventEmitter {
constructor(message, identity, state=null) {
super();
this._id = message.message_id || uuidv4();
this._contentType = message.content_type || message.contentType;
this._sender = identity;
this._receiver = message.account || null;
this._type = message.type;
this._dispositionNotification = message.disposition_notification || message.disposition || [];
this._timestamp = new Date(message.timestamp);
this._dispositionState = null;
this._state = state;
this._isSecure = false;
if (message.content_type === 'text/html') {
this._content = utils.sanatizeHtml(message.content);
} else {
this._content = message.content;
}
}
get id() {
return this._id;
}
get content() {
return this._content;
}
get contentType() {
return this._contentType;
}
get dispositionNotification() {
return this._dispositionNotification;
}
get sender() {
return this._sender;
}
get receiver() {
return this._receiver;
}
get timestamp() {
return this._timestamp;
}
get type() {
return this._type;
}
get dispositionState() {
return this._dispositionState;
}
get state() {
return this._state;
}
get isSecure() {
return this._isSecure;
}
toJSON() {
return {
id: this._id,
content: this._content,
contentType: this._contentType,
dispositionNotification: this._dispositionNotification,
dispositionState: this.dispositionState,
sender: {uri: this._sender.uri, displayName: this._sender.displayName},
receiver: this._receiver,
timestamp: this._timestamp,
type: this._type,
- state: this._state
+ state: this._state,
+ isSecure: this._isSecure
};
}
_setState(newState) {
const oldState = this._state;
this._state = newState;
DEBUG(`Message ${this.id} state change: ${oldState} -> ${newState}`);
this.emit('stateChanged', oldState, newState);
}
_setDispositionState(newState) {
const oldState = this._dispositionState;
this._dispositionState = newState;
DEBUG(`Message ${this.id} dispositionState state change: ${oldState} -> ${newState}`);
this.emit('dispositionStateChanged', oldState, newState);
}
}
export { Message };
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 23, 11:27 AM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3409151
Default Alt Text
(2 KB)
Attached To
Mode
rSYLKRTC SylkRTC.js
Attached
Detach File
Event Timeline
Log In to Comment