mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-21 17:05:16 +00:00
Implement presence mechanismes
This commit is contained in:
@ -14,6 +14,7 @@ use serde::Serialize;
|
||||
use crate::api_data::http_error::HttpError;
|
||||
use crate::constants::PASSWORD_MIN_LENGTH;
|
||||
use crate::data::comment::Comment;
|
||||
use crate::data::config::conf;
|
||||
use crate::data::conversation::{ConversationMember, ConvID};
|
||||
use crate::data::custom_emoji::CustomEmoji;
|
||||
use crate::data::error::{ExecError, Res, ResultBoxError};
|
||||
@ -484,6 +485,14 @@ pub trait BaseRequestHandler {
|
||||
Ok(self.post_string(name)?.parse::<u64>()?)
|
||||
}
|
||||
|
||||
fn post_u32(&mut self, name: &str) -> Res<u32> {
|
||||
Ok(self.post_u64(name)? as u32)
|
||||
}
|
||||
|
||||
fn post_u16(&mut self, name: &str) -> Res<u16> {
|
||||
Ok(self.post_u64(name)? as u16)
|
||||
}
|
||||
|
||||
fn post_positive_u64_opt(&mut self, name: &str) -> Res<Option<u64>> {
|
||||
match self.post_u64_opt(name, 0)? {
|
||||
0 => Ok(None),
|
||||
@ -796,4 +805,15 @@ pub trait BaseRequestHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a membership to a Forez group
|
||||
fn post_forez_group(&mut self, name: &str) -> Res<GroupID> {
|
||||
let group = self.post_group_id_with_access(name, GroupAccessLevel::MEMBER_ACCESS)?;
|
||||
|
||||
if !conf().forez_groups.contains(&group) {
|
||||
self.bad_request(format!("The group {} is not a Forez group!", group.id()))?;
|
||||
}
|
||||
|
||||
Ok(group)
|
||||
}
|
||||
}
|
@ -39,4 +39,5 @@ pub mod user_ws_message;
|
||||
pub mod user_ws_connection;
|
||||
pub mod call_signal;
|
||||
pub mod new_notifications_settings;
|
||||
pub mod push_notification;
|
||||
pub mod push_notification;
|
||||
pub mod presence;
|
22
src/data/presence.rs
Normal file
22
src/data/presence.rs
Normal file
@ -0,0 +1,22 @@
|
||||
//! # Presence information
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::data::user::UserID;
|
||||
|
||||
pub struct Presence {
|
||||
pub id: u64,
|
||||
pub user_id: UserID,
|
||||
pub year: u32,
|
||||
pub month: u16,
|
||||
pub day: u16,
|
||||
}
|
||||
|
||||
impl PartialEq for Presence {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.user_id == other.user_id &&
|
||||
self.year == other.year &&
|
||||
self.month == other.month &&
|
||||
self.day == other.day
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user