Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 5x 5x 5x 25x 23x 23x 23x 23x 20x 23x 24x | import { User } from './User';
import { Util } from '../internal/Util';
import { Moment } from 'moment';
/**
* Represents a Seamail message.
* @module SeamailMessage
*/
export class SeamailMessage {
public static fromRest(data: any) {
Util.assertHasProperties(data, 'id', 'text', 'timestamp');
const ret = new SeamailMessage();
Util.setProperties(ret, data, 'id', 'text');
Util.setDateProperties(ret, data, 'timestamp');
if (!Util.isEmpty(data.author)) {
ret.author = User.fromRest(data.author);
}
if (!Util.isEmpty(data.read_users)) {
ret.read_users = data.read_users.map(user => User.fromRest(user));
}
return ret;
}
/** The unique id. */
public id: string;
/** The user that wrote the message. */
public author: User;
/** The text (contents) of the message. */
public text: string;
/** The time the message was created. */
public timestamp: Moment;
/** The users who have read the message. */
public read_users: User[] = [];
public toJSON() {
return {
author: this.author.toJSON(),
id: this.id,
read_users: this.read_users.map(user => user.toJSON()),
text: this.text,
timestamp: this.timestamp,
};
}
}
|