cli: use model scope for hook calls
authorFelix Fietkau <nbd@nbd.name>
Wed, 26 Feb 2025 09:35:02 +0000 (10:35 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 28 Feb 2025 16:36:01 +0000 (17:36 +0100)
Make the scope consistent with other callbacks

Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/services/unetd/files/unet.uc
package/utils/cli/files/usr/share/ucode/cli/datamodel.uc

index b884e23f60dd4b7cb54cbe498a650062567866f7..023ea3e6b8c149a8994a2e1df17e5ca02446375a 100644 (file)
@@ -151,7 +151,7 @@ function network_sign_data(ctx, name, network, pw_file, upload)
        return true;
 }
 
-function network_create_uci(name, iface)
+function network_create_uci(model, name, iface)
 {
        let cur = uci.cursor();
        cur.set("network", name, "interface");
@@ -344,7 +344,7 @@ function network_create(ctx, argv, named) {
        if (!network_sign_data(ctx, named.network, network, pw_file))
                return;
 
-       network_create_uci(named.network, {
+       network_create_uci(ctx.model, named.network, {
                proto: "unet",
                metric: named.metric,
                zone: named.zone,
@@ -580,7 +580,7 @@ function network_join_peer_update(model, ctx, msg)
        if (joinreq.connect)
                iface.connect = joinreq.connect;
 
-       network_create_uci(name, iface);
+       network_create_uci(model, name, iface);
 
        model.status_msg("Configuration added for interface " + name);
 
index bc78a7b12bbc65c94ca39dbaae77730576027145..f6d9454dd7e3db5cb3ef575f09e5f8f2ed435bbf 100644 (file)
@@ -122,7 +122,7 @@ function run_hook(name, ...args)
                return;
 
        for (let hook in hooks)
-               call(hook, this, {}, ...args);
+               call(hook, this, this.scope, ...args);
 }
 
 function init()