import { MessageTweakerPlugin } from "./basePlugin" ; export default class HideGDrivePreviews extends MessageTweakerPlugin { protected processXHRMessages ( messages ) { messages = messages . map ( m => { if ( m . files ) { if ( ! m . text ) { const urls = m . files . filter ( f => f . external_type === "gdrive" && f . url_private ) . map ( f => `<${ f . url_private }|${ f . url_private }>` ) ; m . text = urls . join ( ", " ) ; } m . files = m . files . filter ( f => f . external_type !== "gdrive" ) ; if ( ! m . files . length ) { delete m . files ; } } return m ; } ) ; return messages ; } protected processWSMessage ( data ) { const message = data . message ? data . message : data ; if ( message . files ) { if ( ! message . text ) { const urls = message . files . filter ( f => f . external_type === "gdrive" && f . url_private ) . map ( f => `<${ f . url_private }|${ f . url_private }>` ) ; message . text = urls . join ( ", " ) ; } message . files = message . files . filter ( f => f . external_type !== "gdrive" ) ; if ( ! message . files . length ) { delete message . files ; } } return data ; } }