Skip to content

Commit 3f7b801

Browse files
committed
cloud: server id reporting
1 parent ccb7ae0 commit 3f7b801

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

plugins/cloud/.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
{
3-
"scrypted.debugHost": "scrypted-server",
3+
"scrypted.debugHost": "scrypted-nvr",
44
}

plugins/cloud/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/cloud/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@
5353
"@types/node": "^22.5.2",
5454
"ts-node": "^10.9.2"
5555
},
56-
"version": "0.2.43"
56+
"version": "0.2.44"
5757
}

plugins/cloud/src/main.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
258258
this.converters = [
259259
[ScryptedMimeTypes.LocalUrl, ScryptedMimeTypes.Url],
260260
[ScryptedMimeTypes.PushEndpoint, ScryptedMimeTypes.Url],
261+
['*/*', ScryptedMimeTypes.ServerId],
261262
];
262263
// legacy cleanup
263264
this.fromMimeType = undefined;
@@ -723,10 +724,7 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
723724
}
724725

725726
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)) {
730728
// if cloudflare is enabled and the plugin isn't set up as a custom domain, try to use the cloudflare url for
731729
// short lived urls.
732730
if (this.cloudflareTunnel && this.storageSettings.values.forwardingMode !== 'Custom Domain') {
@@ -740,14 +738,17 @@ class ScryptedCloud extends ScryptedDeviceBase implements OauthClient, Settings,
740738
}
741739
return this.whitelist(data.toString(), 10 * 365 * 24 * 60 * 60 * 1000, `https://${this.getHostname()}`);
742740
}
743-
else if (fromMimeType.startsWith(ScryptedMimeTypes.PushEndpoint)) {
741+
else if (toMimeType.startsWith(ScryptedMimeTypes.Url) && fromMimeType.startsWith(ScryptedMimeTypes.PushEndpoint)) {
744742
const validDomain = this.getSSLHostname();
745743
if (validDomain)
746744
return Buffer.from(`https://${validDomain}${await this.getCloudMessagePath()}/${data}`);
747745

748746
const url = `http://127.0.0.1/push/${data}`;
749747
return this.whitelist(url, 10 * 365 * 24 * 60 * 60 * 1000, `https://${this.getHostname()}${SCRYPTED_CLOUD_MESSAGE_PATH}`);
750748
}
749+
else if (toMimeType === ScryptedMimeTypes.ServerId) {
750+
return this.storageSettings.values.serverId;
751+
}
751752

752753
throw new Error('unsupported cloud url conversion');
753754
}

sdk/types/scrypted_python/scrypted_sdk/types.py

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class ScryptedMimeTypes(str, Enum):
214214
RequestMediaObject = "x-scrypted/x-scrypted-request-media-object"
215215
RequestMediaStream = "x-scrypted/x-scrypted-request-stream"
216216
SchemePrefix = "x-scrypted/x-scrypted-scheme-"
217+
ServerId = "text/x-server-id"
217218
Url = "text/x-uri"
218219

219220
class SecuritySystemMode(str, Enum):

sdk/types/src/types.input.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2478,6 +2478,7 @@ export enum ScryptedMimeTypes {
24782478
Url = 'text/x-uri',
24792479
InsecureLocalUrl = 'text/x-insecure-local-uri',
24802480
LocalUrl = 'text/x-local-uri',
2481+
ServerId = 'text/x-server-id',
24812482

24822483
PushEndpoint = 'text/x-push-endpoint',
24832484

0 commit comments

Comments
 (0)