File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -164,8 +164,10 @@ public function deleteNotification(int $id): DataResponse {
164164			return  new  DataResponse (null , Http::STATUS_NOT_FOUND );
165165		}
166166
167- 		$ this handler ->deleteById ($ id$ this getCurrentUser ());
168- 		$ this push ->pushDeleteToDevice ($ this getCurrentUser (), $ id
167+ 		$ deleted$ this handler ->deleteById ($ id$ this getCurrentUser ());
168+ 		if  ($ deleted
169+ 			$ this push ->pushDeleteToDevice ($ this getCurrentUser (), $ id
170+ 		}
169171		return  new  DataResponse ();
170172	}
171173
@@ -175,8 +177,10 @@ public function deleteNotification(int $id): DataResponse {
175177	 * @return DataResponse 
176178	 */ 
177179	public  function  deleteAllNotifications (): DataResponse 
178- 		$ this handler ->deleteByUser ($ this getCurrentUser ());
179- 		$ this push ->pushDeleteToDevice ($ this getCurrentUser (), 0 );
180+ 		$ deletedSomething$ this handler ->deleteByUser ($ this getCurrentUser ());
181+ 		if  ($ deletedSomething
182+ 			$ this push ->pushDeleteToDevice ($ this getCurrentUser (), 0 );
183+ 		}
180184		return  new  DataResponse ();
181185	}
182186
Original file line number Diff line number Diff line change @@ -117,29 +117,31 @@ public function delete(INotification $notification): array {
117117	 * Delete the notification of a given user 
118118	 * 
119119	 * @param string $user 
120+ 	 * @return bool 
120121	 */ 
121- 	public  function  deleteByUser (string  $ user
122+ 	public  function  deleteByUser (string  $ user:  bool  {
122123		$ notification$ this manager ->createNotification ();
123124		try  {
124125			$ notificationsetUser ($ user
125126		} catch  (\InvalidArgumentException   $ e
126- 			return ;
127+ 			return   false ;
127128		}
128- 		$ this delete ($ notification
129+ 		return  ! empty ( $ this delete ($ notification) );
129130	}
130131
131132	/** 
132133	 * Delete the notification matching the given id 
133134	 * 
134135	 * @param int $id 
135136	 * @param string $user 
137+ 	 * @return bool 
136138	 */ 
137- 	public  function  deleteById (int  $ idstring  $ user
139+ 	public  function  deleteById (int  $ idstring  $ user:  bool  {
138140		$ sql$ this connection ->getQueryBuilder ();
139141		$ sqldelete ('notifications ' )
140142			->where ($ sqlexpr ()->eq ('notification_id ' , $ sqlcreateNamedParameter ($ id
141143			->andWhere ($ sqlexpr ()->eq ('user ' , $ sqlcreateNamedParameter ($ user
142- 		$ sqlexecute ();
144+ 		return  ( bool )  $ sqlexecute ();
143145	}
144146
145147	/** 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments