ctucx.git: travelynx2fedi

Automaticly post travelynx checkins on the fediverse

commit 862af0f1de3e7eb2a2224c3561ddaddaade13fa6
parent 4a6ca4ce7500fd35da90ad5532019d2f1cb30943
Author: Leah (ctucx) <git@ctu.cx>
Date: Fri, 11 Aug 2023 12:41:57 +0200

src/requestHandler: add token to status-url
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/requestHandler.nim b/src/requestHandler.nim
@@ -1,6 +1,6 @@
 import std/[asyncdispatch, asynchttpserver]
 import std/[parseutils, strutils]
-import std/times
+import std/[times, math]
 import std/[json, options]
 
 import threadvars, types, utils, fedi

@@ -95,7 +95,8 @@ proc requestHandler* (req: Request) {.async.} =
 
 
         if config.TravelynxUsername.isSome:
-          statusUrl = "http://travelynx.de/status/" & config.TravelynxUsername.get & "/" & $entityBodyJson["status"]["fromStation"]["scheduledTime"]
+          let token = $entityBodyJson["status"]["fromStation"]["uic"] & "-" & $floorMod( entityBodyJson["status"]["actionTime"].getInt , 337 ) 
+          statusUrl = "http://travelynx.de/status/" & config.TravelynxUsername.get & "/" & $entityBodyJson["status"]["fromStation"]["scheduledTime"] & "?token=" & token
 
         let vehicle = entityBodyJson["status"]["train"]["type"].getStr & " " & entityBodyJson["status"]["train"]["no"].getStr