@@ -258,6 +258,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
258
258
this . converters = [
259
259
[ ScryptedMimeTypes . LocalUrl , ScryptedMimeTypes . Url ] ,
260
260
[ ScryptedMimeTypes . PushEndpoint , ScryptedMimeTypes . Url ] ,
261
+ [ '*/*' , ScryptedMimeTypes . ServerId ] ,
261
262
] ;
262
263
// legacy cleanup
263
264
this . fromMimeType = undefined ;
@@ -723,10 +724,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
723
724
}
724
725
725
726
async convertMedia ( data : string | Buffer | any , fromMimeType : string , toMimeType : string , options ?: MediaObjectOptions ) : Promise < MediaObject | Buffer | any > {
726
- if ( ! toMimeType . startsWith ( ScryptedMimeTypes . Url ) )
727
- throw new Error ( 'unsupported cloud url conversion' ) ;
728
-
729
- if ( fromMimeType . startsWith ( ScryptedMimeTypes . LocalUrl ) ) {
727
+ if ( toMimeType . startsWith ( ScryptedMimeTypes . Url ) && fromMimeType . startsWith ( ScryptedMimeTypes . LocalUrl ) ) {
730
728
// if cloudflare is enabled and the plugin isn't set up as a custom domain, try to use the cloudflare url for
731
729
// short lived urls.
732
730
if ( this . cloudflareTunnel && this . storageSettings . values . forwardingMode !== 'Custom Domain' ) {
@@ -740,14 +738,17 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
740
738
}
741
739
return this . whitelist ( data . toString ( ) , 10 * 365 * 24 * 60 * 60 * 1000 , `https://${ this . getHostname ( ) } ` ) ;
742
740
}
743
- else if ( fromMimeType . startsWith ( ScryptedMimeTypes . PushEndpoint ) ) {
741
+ else if ( toMimeType . startsWith ( ScryptedMimeTypes . Url ) && fromMimeType . startsWith ( ScryptedMimeTypes . PushEndpoint ) ) {
744
742
const validDomain = this . getSSLHostname ( ) ;
745
743
if ( validDomain )
746
744
return Buffer . from ( `https://${ validDomain } ${ await this . getCloudMessagePath ( ) } /${ data } ` ) ;
747
745
748
746
const url = `http://127.0.0.1/push/${ data } ` ;
749
747
return this . whitelist ( url , 10 * 365 * 24 * 60 * 60 * 1000 , `https://${ this . getHostname ( ) } ${ SCRYPTED_CLOUD_MESSAGE_PATH } ` ) ;
750
748
}
749
+ else if ( toMimeType === ScryptedMimeTypes . ServerId ) {
750
+ return this . storageSettings . values . serverId ;
751
+ }
751
752
752
753
throw new Error ( 'unsupported cloud url conversion' ) ;
753
754
}
0 commit comments