import { RoomEvent } from "./RoomEvent" ; import { EventRedactedError } from "./InvalidEventError" ; category see MessageEventContent export type MessageType = "m.text" | "m.emote" | "m.notice" | "m.image" | "m.file" | "m.audio" | "m.location" | "m.video" | string ; category see MessageEventContent export interface FileInfo { /**
     * The size of the file in bytes.
     */ size ? : number ; /**
     * The type of file.
     */ mimetype ? : string ; } category see MessageEventContent export interface ThumbnailInfo { /**
     * The size of the thumbnail in bytes.
     */ size ? : number ; /**
     * The type of thumbnail.
     */ mimetype ? : string ; /**
     * The intended height of the thumbnail in pixels.
     */ h : number ; /**
     * The intended width of the thumbnail in pixels.
     */ w : number ; } category see MessageEventContent export interface ThumbnailedFileInfo { /**
     * A URL to a thumbnail for the file, if unencrypted.
     */ thumbnail_url ? : string ; /**
     * The encrypted thumbnail file information, if encrypted.
     */ thumbnail_file ? : EncryptedFile ; /**
     * Information about the thumbnail. Optionally included if a thumbnail_url is specified.
     */ thumbnail_info ? : ThumbnailInfo ; } category see MessageEventContent export interface FileWithThumbnailInfo extends FileInfo , ThumbnailedFileInfo { } category see MessageEventContent export interface DimensionalFileInfo extends FileWithThumbnailInfo { /**
     * The intended height of the media in pixels.
     */ h : number ; /**
     * The intended width of the media in pixels.
     */ w : number ; } category see MessageEventContent export interface TimedFileInfo extends FileInfo { /**
     * The duration of the media in milliseconds.
     */ duration : number ; } category see MessageEventContent export interface VideoFileInfo extends DimensionalFileInfo , TimedFileInfo { } category see MessageEvent export interface AudioMessageEventContent extends FileMessageEventContent { /**
     * Information about the file.
     */ info ? : TimedFileInfo ; } category see MessageEvent export interface VideoMessageEventContent extends FileMessageEventContent { /**
     * Information about the file.
     */ info ? : VideoFileInfo ; } category see MessageEvent export interface ImageMessageEventContent extends FileMessageEventContent { /**
     * Information about the file.
     */ info ? : DimensionalFileInfo ; } category see MessageEvent export interface FileMessageEventContent extends MessageEventContent { /**
     * Information about the file.
     */ info ? : FileWithThumbnailInfo ; /**
     * URL to the file, if unencrypted.
     */ url : string ; /**
     * The encrypted file, if encrypted.
     */ file : EncryptedFile ; } category see MessageEvent export interface EncryptedFile { url : string ; key : { kty : "oct" ; key_ops : string [ ] ; alg : "A256CTR" ; k : string ; ext : true ; } ; iv : string ; hashes : { sha256 : string ; } ; v : "v2" ; } category see MessageEvent export interface LocationMessageEventContent extends MessageEventContent { /**
     * Information about the location.
     */ info ? : ThumbnailedFileInfo ; /**
     * A geo URI of the location.
     */ geo_uri ? : string ; } category see MessageEvent export interface TextualMessageEventContent extends MessageEventContent { format ? : string ; formatted_body ? : string ; } category see MessageEvent export interface MessageEventContent { body : string ; msgtype : MessageType ; external_url ? : string ; } category export class MessageEvent < T extends MessageEventContent > extends RoomEvent < T > { constructor ( event ) { super ( event ) ; } /**
     * Whether or not the event is redacted (or looked redacted).
     */ public get isRedacted ( ) : boolean { const noContent = ! this . content . body && this . content . body !== "" ; const noMsgtype = ! this . content . msgtype && this . content . msgtype !== "" ; return noContent || noMsgtype ; } /**
     * The message's type.
     */ public get messageType ( ) : MessageType { const type = this . content . msgtype ; if ( ! type && type !== "" ) throw new EventRedactedError ( "missing msgtype" ) ; return type ; } /**
     * The `body` of the message.
     */ public get textBody ( ) : string { const body = this . content . body ; if ( ! body && body !== "" ) throw new EventRedactedError ( "missing body" ) ; return body ; } /**
     * The `external_url` of the message, if it exists
     */ public get externalUrl ( ) : string | undefined { return this . content . external_url || undefined ; } }