commit 41faf5fe9bb27f5e3bc8b235ed74ed12b84c209b
parent f01c9f9c2ee4a7f0a65e23d731a1b9b186f8744d
Author: Leah (ctucx) <git@ctu.cx>
Date: Wed, 20 Sep 2023 13:10:41 +0200
parent f01c9f9c2ee4a7f0a65e23d731a1b9b186f8744d
Author: Leah (ctucx) <git@ctu.cx>
Date: Wed, 20 Sep 2023 13:10:41 +0200
requestHandler: check for visibility-change on updates
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/requestHandler.nim b/src/requestHandler.nim @@ -67,9 +67,10 @@ proc requestHandler* (req: Request) {.async.} = if state.hasKey("checkin_id") and state.hasKey("to_station"): if ( - state["checkin_id"].getStr == entityBodyJson["status"]["fromStation"]["scheduledTime"].getStr and - state["to_station"].getStr == entityBodyJson["status"]["toStation"]["name"].getStr and - state["comment"].getStr == entityBodyJson["status"]["comment"].getStr + state["checkin_id"].getStr == entityBodyJson["status"]["fromStation"]["scheduledTime"].getStr and + state["to_station"].getStr == entityBodyJson["status"]["toStation"]["name"].getStr and + state["comment"].getStr == entityBodyJson["status"]["comment"].getStr and + state["visibilityLevel"].getInt == entityBodyJson["status"]["visibility"]["level"].getInt ): await req.respond(Http200, "[checkin] Already posted!" & response, headers.newHttpHeaders()) return @@ -127,11 +128,12 @@ proc requestHandler* (req: Request) {.async.} = if post["responseCode"].getStr != "200 OK": response = "[fedi-create-post] error: " & post["error"].getStr else: - state["checkin_id"] = entityBodyJson["status"]["fromStation"]["scheduledTime"] - state["to_station"] = entityBodyJson["status"]["toStation"]["name"] - state["post_id"] = post["id"] - state["post_time"] = newJInt(toUnix(getTime())) - state["comment"] = entityBodyJson["status"]["comment"] + state["checkin_id"] = entityBodyJson["status"]["fromStation"]["scheduledTime"] + state["to_station"] = entityBodyJson["status"]["toStation"]["name"] + state["post_id"] = post["id"] + state["post_time"] = newJInt(toUnix(getTime())) + state["comment"] = entityBodyJson["status"]["comment"] + state["visibilityLevel"] = entityBodyJson["status"]["visibility"]["level"] saveState(state) response = "[fedi-create-post] created post " & $post["id"] & ": " & $post["content"]