mirror of
				https://github.com/nerzhul/ocsms.git
				synced 2025-10-31 10:27:42 +00:00 
			
		
		
		
	Register conversations & add configMapper to smsmapper to use the phone number formatter
This commit is contained in:
		
							parent
							
								
									ed380fd09e
								
							
						
					
					
						commit
						68971b1d33
					
				| @ -33,6 +33,7 @@ class OcSmsApp extends App { | |||||||
| 	/** | 	/** | ||||||
| 	 * OcSmsApp constructor. | 	 * OcSmsApp constructor. | ||||||
| 	 * @param array $urlParams | 	 * @param array $urlParams | ||||||
|  | 	 * @throws \OCP\AppFramework\QueryException | ||||||
| 	 */ | 	 */ | ||||||
| 	public function __construct (array $urlParams=array()) { | 	public function __construct (array $urlParams=array()) { | ||||||
| 		parent::__construct('ocsms', $urlParams); | 		parent::__construct('ocsms', $urlParams); | ||||||
| @ -60,7 +61,7 @@ class OcSmsApp extends App { | |||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		$container->registerService('Sms', function(IContainer $c) use ($server) { | 		$container->registerService('Sms', function(IContainer $c) use ($server) { | ||||||
| 			return new Sms($server->getDb()); | 			return new Sms(); | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		$container->registerService('ConversationStateMapper', function(IContainer $c) use ($server) { | 		$container->registerService('ConversationStateMapper', function(IContainer $c) use ($server) { | ||||||
| @ -70,7 +71,8 @@ class OcSmsApp extends App { | |||||||
| 		$container->registerService('SmsMapper', function(IContainer $c) use ($server) { | 		$container->registerService('SmsMapper', function(IContainer $c) use ($server) { | ||||||
| 			return new SmsMapper( | 			return new SmsMapper( | ||||||
| 				$server->getDatabaseConnection(), | 				$server->getDatabaseConnection(), | ||||||
| 				$c->query('ConversationStateMapper') | 				$c->query('ConversationStateMapper'), | ||||||
|  | 				$c->query('ConfigMapper') | ||||||
| 			); | 			); | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| @ -117,10 +119,10 @@ class OcSmsApp extends App { | |||||||
| 		/** | 		/** | ||||||
| 		 * Migration services | 		 * Migration services | ||||||
| 		 */ | 		 */ | ||||||
| 		$container->registerService('OCA\OcSms\Migration\FixConversationReadStates', function ($c) { | 		$container->registerService('OCA\OcSms\Migration\FixConversationReadStates', function (IContainer $c) use($server) { | ||||||
| 			return new FixConversationReadStates( | 			return new FixConversationReadStates( | ||||||
| 				$c->query('ConversationStateMapper'), | 				$c->query('ConversationStateMapper'), | ||||||
| 				$c->getServer()->getUserManager() | 				$server->getUserManager() | ||||||
| 			); | 			); | ||||||
| 		}); | 		}); | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -42,9 +42,10 @@ class SmsController extends Controller { | |||||||
| 	 * @param IRequest $request | 	 * @param IRequest $request | ||||||
| 	 * @param $userId | 	 * @param $userId | ||||||
| 	 * @param SmsMapper $mapper | 	 * @param SmsMapper $mapper | ||||||
|  | 	 * @param ConversationStateMapper $cmapper | ||||||
| 	 * @param ConfigMapper $cfgMapper | 	 * @param ConfigMapper $cfgMapper | ||||||
| 	 * @param IContactsManager $contactsManager | 	 * @param IContactsManager $contactsManager | ||||||
| 	 * @param $urlGenerator | 	 * @param IURLGenerator $urlGenerator | ||||||
| 	 */ | 	 */ | ||||||
| 	public function __construct ($appName, IRequest $request, $userId, | 	public function __construct ($appName, IRequest $request, $userId, | ||||||
| 			SmsMapper $mapper, ConversationStateMapper $cmapper, | 			SmsMapper $mapper, ConversationStateMapper $cmapper, | ||||||
|  | |||||||
| @ -33,10 +33,12 @@ class SmsMapper extends Mapper { | |||||||
| 		6 => "queued" | 		6 => "queued" | ||||||
| 	); | 	); | ||||||
| 	private $convStateMapper; | 	private $convStateMapper; | ||||||
|  | 	private $configMapper; | ||||||
| 
 | 
 | ||||||
| 	public function __construct (IDBConnection $db, ConversationStateMapper $cmapper) { | 	public function __construct (IDBConnection $db, ConversationStateMapper $cmapper, ConfigMapper $configMapper) { | ||||||
| 		parent::__construct($db, 'ocsms_smsdatas'); | 		parent::__construct($db, 'ocsms_smsdatas'); | ||||||
| 		$this->convStateMapper = $cmapper; | 		$this->convStateMapper = $cmapper; | ||||||
|  | 		$this->configMapper = $configMapper; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public function getAllIds ($userId) { | 	public function getAllIds ($userId) { | ||||||
| @ -379,12 +381,13 @@ class SmsMapper extends Mapper { | |||||||
| 				(int) $sms["type"] | 				(int) $sms["type"] | ||||||
| 			)); | 			)); | ||||||
| 
 | 
 | ||||||
| 			/* | 			$configuredCountry = $this->configMapper->getCountry(); | ||||||
| 			$conversation = $this->getConversationForUserAndPhone($userId, $sms["address"]); | 			$fmtPhoneNumber = PhoneNumberFormatter::format($configuredCountry, $sms["address"]); | ||||||
|  | 
 | ||||||
|  | 			$conversation = $this->getConversationForUserAndPhone($userId, $fmtPhoneNumber); | ||||||
| 			if ($conversation === null) { | 			if ($conversation === null) { | ||||||
| 				$this->registerConversation($userId, $sms["address"]); | 				$this->registerConversation($userId, $fmtPhoneNumber); | ||||||
| 			} | 			} | ||||||
| 			*/ |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		$this->db->commit(); | 		$this->db->commit(); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user