Added user check to not notify user sending message
This commit is contained in:
		
							parent
							
								
									fcc2d7b748
								
							
						
					
					
						commit
						94b9d2c63b
					
				@ -62,17 +62,18 @@ class NotificationService(BaseService):
 | 
			
		||||
            except Exception:
 | 
			
		||||
                raise Exception(f"Failed to create notification: {model.errors}.")
 | 
			
		||||
 | 
			
		||||
            try:
 | 
			
		||||
                await self.app.services.push.notify_user(
 | 
			
		||||
                    user_uid=channel_member["user_uid"],
 | 
			
		||||
                    payload={
 | 
			
		||||
                        "title": f"New message in {channel_member['label']}",
 | 
			
		||||
                        "message": f"{user['nick']}: {channel_message['message']}",
 | 
			
		||||
                        "icon": "/image/snek192.png",
 | 
			
		||||
                        "url": f"/channel/{channel_message['channel_uid']}.html",
 | 
			
		||||
                    },
 | 
			
		||||
                )
 | 
			
		||||
            except Exception as e:
 | 
			
		||||
                print(f"Failed to send push notification:", e)
 | 
			
		||||
            if channel_member["user_uid"] != user["uid"]:
 | 
			
		||||
                try:
 | 
			
		||||
                    await self.app.services.push.notify_user(
 | 
			
		||||
                        user_uid=channel_member["user_uid"],
 | 
			
		||||
                        payload={
 | 
			
		||||
                            "title": f"New message in {channel_member['label']}",
 | 
			
		||||
                            "message": f"{user['nick']}: {channel_message['message']}",
 | 
			
		||||
                            "icon": "/image/snek192.png",
 | 
			
		||||
                            "url": f"/channel/{channel_message['channel_uid']}.html",
 | 
			
		||||
                        },
 | 
			
		||||
                    )
 | 
			
		||||
                except Exception as e:
 | 
			
		||||
                    print(f"Failed to send push notification:", e)
 | 
			
		||||
 | 
			
		||||
        self.app.db.commit()
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user