From f1b78f9d57262ad494264c310bb59cefa989b3a4 Mon Sep 17 00:00:00 2001 From: m0veax Date: Wed, 22 May 2024 23:05:47 +0200 Subject: [PATCH] add missing infos from original and lastchange timestamp --- src/status.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/status.rs b/src/status.rs index d9d4e44..903d4fd 100644 --- a/src/status.rs +++ b/src/status.rs @@ -1,6 +1,7 @@ +use std::time::{SystemTime, UNIX_EPOCH}; + use spaceapi::{ - sensors::{DoorLockedSensor, SensorMetadataWithLocation, Sensors}, - Contact, Location, State, Status, StatusBuilder, + sensors::{DoorLockedSensor, SensorMetadataWithLocation, Sensors}, Contact, Feed, Feeds, Location, State, Status, StatusBuilder, Link }; const SPACE_NAME: &str = "Chaospott"; @@ -33,8 +34,25 @@ pub fn status(sensors: Sensors, state: State) -> Status { phone: Some("+49 201 85892243".into()), ..Default::default() }) - // .add_issue_report_channel(IssueReportChannel::IssueMail) - // .add_issue_report_channel(IssueReportChannel::Ml) + .feeds(Feeds { + blog: Some(Feed { + type_: Some("application/rss+xml".into()), + url: String::from("https://chaospott.de/feed.xml") + }), + calendar: Some(Feed { + type_: Some("ical".into()), + url: String::from("https://cloud.chaospott.de/remote.php/dav/public-calendars/5HM7B0ZOLEYC3QD0?export") + }), + ..Default::default() + }) + .add_project("https://wiki.chaospott.de/projekte:start") + .add_project("https://git.chaospott.de/") + .add_link(Link { + name: String::from("Sibyllinische Neuigkeiten"), + description: Some("In unserem Podcast berichten wir über unser Clubleben und unterhalten uns über verschiedene Technikthemen.".into()), + url: String::from("https://podcast.chaospott.de/") + }) + // TODO state needs icon URLs for open and closed .state(state) .build() .unwrap(); @@ -74,9 +92,16 @@ pub fn update(the_doors: TheDoors) -> (Sensors, State) { let mut sensors = Sensors::default(); sensors.door_locked.push(get_aerie(the_doors.aerie)); sensors.door_locked.push(get_cellar(the_doors.cellar)); + + let time = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs(); + // Open means that any door is open. let state = State { open: Some(the_doors.aerie || the_doors.cellar), + lastchange: Some(time), ..State::default() }; (sensors, state)