mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
feat(push): ring incoming calls on Apple PushKit devices (#2911)
This commit is contained in:
1 parent
c9754ac11a
commit
b16989d567
25 files changed
+878
-83
No files matched your search
@@ -5,6 +5,7 @@ use thiserror::Error;
|
||||
|
||||
pub const SUBJECT_MESSAGE: &str = "push.job.message";
|
||||
pub const SUBJECT_CLEAR: &str = "push.job.clear";
|
||||
pub const SUBJECT_RING: &str = "push.job.ring";
|
||||
pub const QUEUE_GROUP: &str = "fluxer-push";
|
||||
|
||||
const SUPPORTED_VERSION: u8 = 1;
|
||||
@@ -43,6 +44,17 @@ pub struct ClearJob {
|
||||
pub message_id: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
|
||||
pub struct RingJob {
|
||||
pub v: u8,
|
||||
pub config_version: u64,
|
||||
pub user_id: String,
|
||||
pub channel_id: String,
|
||||
pub message_id: String,
|
||||
pub started_at_ms: i64,
|
||||
pub expires_at_ms: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum JobError {
|
||||
#[error("push job version {0} is not supported")]
|
||||
@@ -69,6 +81,12 @@ pub fn decode_clear(bytes: &[u8]) -> Result<ClearJob, JobError> {
|
||||
Ok(job)
|
||||
}
|
||||
|
||||
pub fn decode_ring(bytes: &[u8]) -> Result<RingJob, JobError> {
|
||||
let job: RingJob = serde_json::from_slice(bytes)?;
|
||||
supported(job.v)?;
|
||||
Ok(job)
|
||||
}
|
||||
|
||||
fn supported(version: u8) -> Result<(), JobError> {
|
||||
if version == SUPPORTED_VERSION {
|
||||
return Ok(());
|
||||
|
||||
Reference in new issue
Block a user