1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-11-26 23:39:22 +00:00
comunicapiv2/src/entities/ConversationMessage.ts

50 lines
1.0 KiB
TypeScript
Raw Normal View History

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);
}
get imageSysPath() : string {
return pathUserData(this.imagePath, true);
}
2019-11-30 14:17:47 +00:00
}