2019-11-30 14:17:47 +00:00
|
|
|
import { pathUserData } from "../utils/UserDataUtils";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Single conversation message
|
|
|
|
*
|
|
|
|
* @author Pierre HUBERT
|
|
|
|
*/
|
|
|
|
|
2019-11-30 16:13:36 +00:00
|
|
|
// Used directly when creating a new message
|
|
|
|
export interface BaseConversationMessage {
|
2019-11-30 14:17:47 +00:00
|
|
|
convID: number,
|
|
|
|
userID: number,
|
|
|
|
imagePath: string,
|
|
|
|
message: string
|
|
|
|
}
|
|
|
|
|
2019-11-30 16:13:36 +00:00
|
|
|
export interface ConversationMessageInfo extends BaseConversationMessage {
|
|
|
|
id: number,
|
|
|
|
timeSent: number,
|
|
|
|
}
|
|
|
|
|
2019-11-30 14:17:47 +00:00
|
|
|
export class ConversationMessage implements ConversationMessageInfo {
|
|
|
|
public id: number;
|
|
|
|
public convID: number;
|
|
|
|
public userID: number;
|
|
|
|
public timeSent: number;
|
|
|
|
public imagePath: string;
|
|
|
|
public message: string;
|
|
|
|
|
|
|
|
constructor(info: ConversationMessageInfo) {
|
|
|
|
this.id = info.id;
|
|
|
|
this.convID = info.convID;
|
|
|
|
this.userID = info.userID;
|
|
|
|
this.timeSent = info.timeSent;
|
|
|
|
this.imagePath = info.imagePath;
|
|
|
|
this.message = info.message;
|
|
|
|
}
|
|
|
|
|
|
|
|
get hasImage() : boolean {
|
|
|
|
return this.imagePath.length > 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
get imageURL() : string {
|
|
|
|
return pathUserData(this.imagePath);
|
|
|
|
}
|
2019-12-07 17:06:41 +00:00
|
|
|
|
|
|
|
get imageSysPath() : string {
|
|
|
|
return pathUserData(this.imagePath, true);
|
|
|
|
}
|
2019-11-30 14:17:47 +00:00
|
|
|
}
|