Browse Source
			
			
			Util is a bad name and static is awkward
			
				Signed-off-by: Joas Schilling <coding@schilljs.com>
			
			
				pull/198/head
			
			
		 
		
			
				
					
						 Joas Schilling
					
					9 years ago
						Joas Schilling
					
					9 years ago
					
				 
				
			 
		 
		
			
				
				  
				  No known key found for this signature in database
				  
				  	
						GPG Key ID: E166FD8976B3BAC8
				  	
				  
				
			
		
		
		
	
		
			
				 2 changed files with 
16 additions and 
7 deletions
			 
			
		 
		
			
				- 
					
					
					 
					appinfo/app.php
				
- 
					
					
					 
					lib/HookListener.php
				
					
					
						
							
								
									
										
											
	
		
			
				
					|  |  | @ -35,7 +35,7 @@ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | $manager = \OC::$server->getNotificationManager(); | 
			
		
	
		
			
				
					|  |  |  | $manager->registerNotifier(function() { | 
			
		
	
		
			
				
					|  |  |  | 	return \OC::$server->query('OCA\Spreed\Notification\Notifier'); | 
			
		
	
		
			
				
					|  |  |  | 	return \OC::$server->query(\OCA\Spreed\Notification\Notifier::class); | 
			
		
	
		
			
				
					|  |  |  | }, function() { | 
			
		
	
		
			
				
					|  |  |  | 	$l = \OC::$server->getL10N('spreed'); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -46,5 +46,6 @@ $manager->registerNotifier(function() { | 
			
		
	
		
			
				
					|  |  |  | }); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | \OC::$server->getUserManager()->listen('\OC\User', 'postDelete', function ($user) { | 
			
		
	
		
			
				
					|  |  |  | 	\OCA\Spreed\Util::deleteUser($user); | 
			
		
	
		
			
				
					|  |  |  | 	$listener = \OC::$server->query(\OCA\Spreed\HookListener::class); | 
			
		
	
		
			
				
					|  |  |  | 	$listener->deleteUser($user); | 
			
		
	
		
			
				
					|  |  |  | }); | 
			
		
	
										
									
								
							
						 
					 
				 
			
		
			
				
					
					
						
							
								
									
										
											
	
		
			
				
					|  |  | @ -23,15 +23,23 @@ namespace OCA\Spreed; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | use OCP\IUser; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | class Util { | 
			
		
	
		
			
				
					|  |  |  | class HookListener { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** @var Manager */ | 
			
		
	
		
			
				
					|  |  |  | 	protected $manager; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @param Manager $manager | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function __construct(Manager $manager) { | 
			
		
	
		
			
				
					|  |  |  | 		$this->manager = $manager; | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @param IUser $user | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public static function deleteUser(IUser $user) { | 
			
		
	
		
			
				
					|  |  |  | 		/** @var Manager $manager */ | 
			
		
	
		
			
				
					|  |  |  | 		$manager = \OC::$server->query(Manager::class); | 
			
		
	
		
			
				
					|  |  |  | 		$rooms = $manager->getRoomsForParticipant($user->getUID()); | 
			
		
	
		
			
				
					|  |  |  | 	public function deleteUser(IUser $user) { | 
			
		
	
		
			
				
					|  |  |  | 		$rooms = $this->manager->getRoomsForParticipant($user->getUID()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		foreach ($rooms as $room) { | 
			
		
	
		
			
				
					|  |  |  | 			if ($room->getType() === Room::ONE_TO_ONE_CALL || $room->getNumberOfParticipants() === 1) { |