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