mirror of
https://github.com/rzuasti/oott.git
synced 2026-07-08 19:21:54 +02:00
Implement push notifications Phase 1 (FCM + project relay)
Backend (Rust): - push_tokens migration, model (PushToken/PushPlatform), and db layer (upsert/list/delete/delete_many) - PUT/DELETE /api/push_tokens endpoints wired into the router + OpenAPI - "push" notification method: relay sender (reqwest) that forwards only the sanitized title/body and prunes dead tokens, plus settings with a default relay_url - 164 tests pass, clippy clean Relay (push_relay/, TypeScript Firebase Cloud Function): - POST /v1/push (firebase-admin sendEach + per-token status mapping), GET /healthz, payload validation, per-IP Firestore rate limiting - Jest tests + README documenting the manual project-owned setup Frontend (Flutter): - oott_api_push.dart (register/unregister), push_service.dart behind a PushService abstraction, and a per-device push toggle in settings - firebase_core/firebase_messaging/flutter_local_notifications deps - 145 tests pass, dart analyze clean Dev shell: - add nodejs_22 to the Nix dev shell so the relay tests/build run locally Remaining (manual, project-owned): create the Firebase project, deploy the relay and set the real default_relay_url, add native Firebase config, and test on real devices. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
fa54361198
commit
4f3fe10332
@@ -1,8 +1,12 @@
|
||||
use std::{error, fmt};
|
||||
|
||||
use crate::db::error::DbError;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum DeliveryError {
|
||||
ParsePushover(pushover::Error),
|
||||
Http(reqwest::Error),
|
||||
Db(DbError),
|
||||
}
|
||||
|
||||
impl fmt::Display for DeliveryError {
|
||||
@@ -11,6 +15,12 @@ impl fmt::Display for DeliveryError {
|
||||
DeliveryError::ParsePushover(..) => {
|
||||
write!(f, "Error delivering notification via Pushover")
|
||||
}
|
||||
DeliveryError::Http(..) => {
|
||||
write!(f, "Error delivering notification via the push relay")
|
||||
}
|
||||
DeliveryError::Db(..) => {
|
||||
write!(f, "Database error while delivering a push notification")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +29,8 @@ impl error::Error for DeliveryError {
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
match *self {
|
||||
DeliveryError::ParsePushover(ref e) => Some(e),
|
||||
DeliveryError::Http(ref e) => Some(e),
|
||||
DeliveryError::Db(ref e) => Some(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,3 +40,15 @@ impl From<pushover::Error> for DeliveryError {
|
||||
DeliveryError::ParsePushover(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<reqwest::Error> for DeliveryError {
|
||||
fn from(err: reqwest::Error) -> DeliveryError {
|
||||
DeliveryError::Http(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DbError> for DeliveryError {
|
||||
fn from(err: DbError) -> DeliveryError {
|
||||
DeliveryError::Db(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user