feat(onebot): honour a custom per-node time in merged forward (#209)
Merged-forward nodes always stamped the current time. A custom forward can now set each node's displayed timestamp via the OneBot `data.time` field (unix seconds), matching the field the wire already carries per node. parseForwardNodes reads `data.time` on custom/fake nodes and threads it onto the node payload (the `time?` field already existed for the receive side); buildForwardPushBody uses it for `contentHead.timestamp`, falling back to now when absent. The value is validated to a plausible unix-seconds range — the wire field is uint32, so a millisecond or out-of-range input is rejected (would overflow) and defaults to now rather than corrupting the timestamp. The message_id-reference branch (time from the quoted message) and the c2c-file expireTime (real now) are unchanged. Nested inner nodes honour their own time.
This commit is contained in:
4 files changed
+69
-4
No files matched your search
@@ -1240,6 +1240,12 @@ async function parseForwardNodes(
|
||||
}
|
||||
|
||||
const node: ForwardNodePayload = { userUin, nickname, elements };
|
||||
// Honour an explicit per-node display time (OneBot `data.time`, unix
|
||||
// seconds) so a custom forward can set/back-date each node's timestamp
|
||||
// (#209). The wire field is uint32, so reject a millisecond value or any
|
||||
// out-of-range input (it would overflow/throw) and fall back to now.
|
||||
const nodeTime = toPositiveInt(nodeData.time);
|
||||
if (nodeTime > 0 && nodeTime < 0xffffffff) node.time = nodeTime;
|
||||
if (innerForward) node.innerForward = innerForward;
|
||||
nodes.push(node);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user