Skip to content

Commit e37c9dd

Browse files
committed
Make watch optional
1 parent 787037e commit e37c9dd

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

OpenFlow/src/Config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export class Config {
2626
Config.stripe_api_key = Config.getEnv("stripe_api_key", "");
2727
Config.stripe_api_secret = Config.getEnv("stripe_api_secret", "");
2828

29+
Config.supports_watch = Config.parseBoolean(Config.getEnv("supports_watch", "false"));
30+
2931
Config.auto_create_users = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));
3032
Config.auto_create_domains = Config.parseArray(Config.getEnv("auto_create_domains", ""));
3133
Config.allow_user_registration = Config.parseBoolean(Config.getEnv("allow_user_registration", "false"));
@@ -95,6 +97,8 @@ export class Config {
9597
public static stripe_api_key: string = Config.getEnv("stripe_api_key", "");
9698
public static stripe_api_secret: string = Config.getEnv("stripe_api_secret", "");
9799

100+
public static supports_watch: boolean = Config.parseBoolean(Config.getEnv("supports_watch", "false"));
101+
98102
public static auto_create_users: boolean = Config.parseBoolean(Config.getEnv("auto_create_users", "false"));
99103
public static auto_create_domains: string[] = Config.parseArray(Config.getEnv("auto_create_domains", ""));
100104
public static allow_user_registration: boolean = Config.parseBoolean(Config.getEnv("allow_user_registration", "false"));

OpenFlow/src/Messages/Message.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,11 @@ export class Message {
476476
try {
477477
msg = WatchMessage.assign(this.data);
478478
if (NoderedUtil.IsNullEmpty(msg.jwt)) { msg.jwt = cli.jwt; }
479-
msg.id = await cli.Watch(msg.aggregates, msg.collectionname, msg.jwt);
479+
if (Config.supports_watch) {
480+
msg.id = await cli.Watch(msg.aggregates, msg.collectionname, msg.jwt);
481+
} else {
482+
msg.error = "Watch is not supported by this openflow";
483+
}
480484
msg.result = null;
481485
} catch (error) {
482486
if (NoderedUtil.IsNullUndefinded(msg)) { (msg as any) = {}; }
@@ -781,6 +785,7 @@ export class Message {
781785
if (msg.impersonate === undefined || msg.impersonate === null || msg.impersonate === "") {
782786
user.lastseen = new Date(new Date().toISOString());
783787
}
788+
msg.supports_watch = Config.supports_watch;
784789
user._lastclientagent = cli.clientagent;
785790
user._lastclientversion = cli.clientversion;
786791
if (cli.clientagent == "openrpa") {

0 commit comments

Comments
 (0)