@@ -540,17 +540,25 @@ const CreateMessageBubble = (TypingIndicator = false, MessageJSON = {}, Message
540
540
if ( MessageJSON . text == "\ufffc" ) {
541
541
const Attachments = MessageJSON . attachments
542
542
for ( const Attachment of Attachments ) {
543
- let MessageContentItem = document . createElement ( "img" )
543
+ let Type = Attachment [ 1 ] . includes ( "image" ) ? "img" : ( Attachment [ 1 ] . includes ( "video" ) ? "video" : "div" ) ;
544
+ let MessageContentItem = document . createElement ( Type )
544
545
MessageContentItem . addEventListener ( "load" , ( ) => {
545
546
MessageContainer . scrollTop = MessageContainer . scrollHeight ;
546
547
} )
547
548
MessageContentItem . setAttribute ( "rawJSON" , JSON . stringify ( MessageJSON ) )
548
549
MessageContentItem . className = "message"
549
550
MessageContentItem . classList . add ( "message-media" )
550
551
MessageContentItem . classList . add ( Sender ? "message-sender" : "message-recipient" )
551
- if ( ServerSettings ) {
552
+ if ( ServerSettings && Type == "img" ) {
552
553
MessageContentItem . src = `${ ServerSettings . useHttps ? "https" : "http" } ://${ ServerSettings . host } :${ ServerSettings . port } /attachments?path=${ encodeURIComponent ( Attachment [ 0 ] ) } &type=${ encodeURIComponent ( Attachment [ 1 ] ) } &auth=${ ServerSettings . password } &transcode=1`
553
554
}
555
+ else if ( ServerSettings && Type == "video" ) {
556
+ let SourceObject = document . createElement ( "source" )
557
+ SourceObject . src = `${ ServerSettings . useHttps ? "https" : "http" } ://${ ServerSettings . host } :${ ServerSettings . port } /attachments?path=${ encodeURIComponent ( Attachment [ 0 ] ) } &type=${ encodeURIComponent ( Attachment [ 1 ] ) } &auth=${ ServerSettings . password } &transcode=1`
558
+ SourceObject . type = Attachment [ 1 ]
559
+ MessageContentItem . appendChild ( SourceObject )
560
+ MessageContentItem . setAttribute ( "controls" , true )
561
+ }
554
562
OutMessages . push ( MessageContentItem )
555
563
}
556
564
}
0 commit comments