<commit_before>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;
        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;
    }

    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,<commit_msg>Added isSecure flag to message object<commit_after>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,
{'fraction_non_alphanumeric': 0.10281964025279533, 'fraction_numerical': 0.0014584346135148275, 'mean_word_length': 2.019075568598679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1946472', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1098, 'n_words': 248}