mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(iot): emit retained message timestamps in milliseconds (#6365)
Match the IoT Data Long response contract instead of emitting floating-point seconds. Cover both retained read responses with fixed values, missing-timestamp controls, and SDK wire round trips.
This commit is contained in:
1 parent
1b8548a0af
commit
4093694451
4 files changed
+114
-5
No files matched your search
@@ -21,6 +21,7 @@ import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Base64;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -163,7 +164,7 @@ public class IotDataController {
|
||||
response.put("topic", retained.getTopic());
|
||||
response.put("payload", retained.getPayload());
|
||||
response.put("qos", retained.getQos());
|
||||
putEpoch(response, "lastModifiedTime", retained.getLastModifiedTime());
|
||||
putEpochMillis(response, "lastModifiedTime", retained.getLastModifiedTime());
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
@@ -179,7 +180,7 @@ public class IotDataController {
|
||||
item.put("topic", retained.getTopic());
|
||||
item.put("payloadSize", Base64.getDecoder().decode(retained.getPayload()).length);
|
||||
item.put("qos", retained.getQos());
|
||||
putEpoch(item, "lastModifiedTime", retained.getLastModifiedTime());
|
||||
putEpochMillis(item, "lastModifiedTime", retained.getLastModifiedTime());
|
||||
}
|
||||
if (page.nextToken() != null) {
|
||||
response.put("nextToken", page.nextToken());
|
||||
@@ -187,9 +188,9 @@ public class IotDataController {
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
private void putEpoch(ObjectNode node, String field, java.time.Instant instant) {
|
||||
private void putEpochMillis(ObjectNode node, String field, Instant instant) {
|
||||
if (instant != null) {
|
||||
node.put(field, instant.toEpochMilli() / 1000.0);
|
||||
node.put(field, instant.toEpochMilli());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user