mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 01:24:04 +00:00 
			
		
		
		
	Can create friendship notifications
This commit is contained in:
		@@ -17,7 +17,6 @@ use crate::utils::date_utils;
 | 
			
		||||
/// Create post notification
 | 
			
		||||
pub fn create_post_notification(from_user: &UserID, post_id: u64, action: NotifEventType) -> ResultBoxError {
 | 
			
		||||
    let mut n = PartialNotification::new()
 | 
			
		||||
        .set_time_create(date_utils::time())
 | 
			
		||||
        .set_from_user_id(from_user)
 | 
			
		||||
        .set_on_elem_id(post_id)
 | 
			
		||||
        .set_on_elem_type(NotifElemType::POST)
 | 
			
		||||
@@ -26,8 +25,20 @@ pub fn create_post_notification(from_user: &UserID, post_id: u64, action: NotifE
 | 
			
		||||
    push(&mut n)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Create & push friend notification
 | 
			
		||||
pub fn create_friends_notification(from_user: &UserID, dest_user: &UserID, action: NotifEventType) -> ResultBoxError {
 | 
			
		||||
    let mut n = PartialNotification::new()
 | 
			
		||||
        .set_from_user_id(from_user)
 | 
			
		||||
        .set_dest_user_id(dest_user)
 | 
			
		||||
        .set_on_elem_id(from_user.id())
 | 
			
		||||
        .set_on_elem_type(NotifElemType::FRIENDSHIP_REQUEST)
 | 
			
		||||
        .set_type(action);
 | 
			
		||||
 | 
			
		||||
    push(&mut n)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Push a new notification
 | 
			
		||||
pub fn push(n: &mut PartialNotification) -> ResultBoxError
 | 
			
		||||
fn push(n: &mut PartialNotification) -> ResultBoxError
 | 
			
		||||
{
 | 
			
		||||
    if n.time_create.is_none()
 | 
			
		||||
    {
 | 
			
		||||
@@ -100,6 +111,14 @@ pub fn push(n: &mut PartialNotification) -> ResultBoxError
 | 
			
		||||
        else {
 | 
			
		||||
            unimplemented!();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Friendship notification
 | 
			
		||||
    else if matches!(n.on_elem_type, Some(NotifElemType::FRIENDSHIP_REQUEST)) {
 | 
			
		||||
        n.container_id = None;
 | 
			
		||||
        n.container_type = None;
 | 
			
		||||
 | 
			
		||||
        return push_private(n);
 | 
			
		||||
    } else {
 | 
			
		||||
        unimplemented!();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user