Add the ability for on message hooks to see selected files

This commit is contained in:
Carson Coder 2025-10-13 20:52:31 -04:00
parent d099e5e84e
commit 3a69062a82
3 changed files with 23 additions and 5 deletions

View file

@ -2146,8 +2146,18 @@ class HttpCli(object):
try:
zb = unquote(buf.replace(b"+", b" "))
plain = zb.decode("utf-8", "replace")
if buf.startswith(b"msg="):
plain = plain[4:]
_msg_data = plain.split("&")
msg_data = {}
for i in _msg_data:
d = i.split("=")
if d[0] in msg_data.keys():
if type(msg_data[d[0]]) is list:
msg_data[d[0]].append("=".join(d[1:]))
else:
msg_data[d[0]] = [msg_data[d[0]], "=".join(d[1:])]
else:
msg_data[d[0]] = "=".join(d[1:])
if "msg" in msg_data.keys():
xm = self.vn.flags.get("xm")
if xm:
xm_rsp = runhook(
@ -2165,7 +2175,8 @@ class HttpCli(object):
len(buf),
self.ip,
time.time(),
plain,
msg_data["msg"],
{"sel": [self.vn.canonical(i) for i in msg_data.get("sel", [])]}
)
t = "urlform_dec %d @ %r\n %r\n"

View file

@ -3886,6 +3886,7 @@ def _runhook(
ip: str,
at: float,
txt: str,
other: dict
) -> dict[str, Any]:
ret = {"rc": 0}
areq, chk, imp, fork, sin, jtxt, wait, sp_ka, acmd = _parsehook(log, cmd)
@ -3910,6 +3911,7 @@ def _runhook(
"src": src,
"txt": txt,
}
ja.update(other)
if imp:
ja["log"] = log
mod = loadpy(acmd[0], False)
@ -3980,6 +3982,7 @@ def runhook(
ip: str,
at: float,
txt: str,
other: dict,
) -> dict[str, Any]:
assert broker or up2k # !rm
args = (broker or up2k).args # type: ignore
@ -3989,7 +3992,7 @@ def runhook(
for cmd in cmds:
try:
hr = _runhook(
log, verbose, src, cmd, ap, vp, host, uname, perms, mt, sz, ip, at, txt
log, verbose, src, cmd, ap, vp, host, uname, perms, mt, sz, ip, at, txt, other
)
if verbose and log:
log("hook(%s) %r => \033[32m%s" % (src, cmd, hr), 6)

View file

@ -8622,8 +8622,12 @@ var msel = (function () {
xhr.setRequestHeader('Content-Type', ct);
if (xhr.overrideMimeType)
xhr.overrideMimeType('Content-Type', ct);
let selected = msel.getsel()
for (let i=0;i<selected.length;i++) {
selected[i] = selected[i].vp;
}
xhr.send('msg=' + uricom_enc(xhr.msg));
xhr.send('msg=' + uricom_enc(xhr.msg) + "&sel=" + selected.join("&sel="));
return false;
};