From 02475e05ccd1aa15c6a6163834f28bfebbef796f Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Mon, 30 Nov 2026 11:47:36 +0100 Subject: RWGPS webhook and such --- server/src/database.cppm | 64 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 3 deletions(-) (limited to 'server/src/database.cppm') diff --git a/server/src/database.cppm b/server/src/database.cppm index ff5cae4..83616d2 100644 --- a/server/src/database.cppm +++ b/server/src/database.cppm @@ -2,21 +2,79 @@ export module routemon:database; import std; import :sqlite3; +import :time; namespace routemon::database { +namespace schema { + +enum class rwgps_notification_cause +{ + unknown, + created, + updated, + deleted, + added, + removed, +}; + +enum class rwgps_notification_item_type +{ + unknown, + trip, + route, + event, + event_participant, + club_member, + authorization, +}; + +enum rwgps_notification_target_collection_type +{ + unknown, + pinned, +}; + +struct rwgps_notification_target_collection +{ + std::int64_t notification_id = 0; + std::int64_t id; + rwgps_notification_target_collection_type type; + std::optional url; +}; + +struct rwgps_notification +{ + std::int64_t id = 0; + time::timestamp rwgps_timestamp; + // User that took the action + std::int64_t user_id; + rwgps_notification_item_type item_type; + std::optional item_id; + // User that owns the item + std::optional item_user_id; + std::optional item_url; + rwgps_notification_cause action; +}; + +} // namespace schema + export class connection { sqlite3::connection dbc_; explicit connection(sqlite3::connection dbc) : dbc_{std::move(dbc)} {} - friend auto open(std::string const& filename) -> std::shared_ptr; + friend auto open(util::zstring_view filename) -> std::shared_ptr; public: - // Nothing here yet + auto insert_rwgps_notifications( + std::vector + >>& notifs) -> void; }; -export auto open(std::string const& filename) -> std::shared_ptr; +export auto open(util::zstring_view filename) -> std::shared_ptr; } // namespace routemon::database -- cgit v1.3.1