INNER CODE UNIT · Python
get_sip_return_code
arnonym/ha-plugins · ha-sip/src/account.py:140
def get_sip_return_code(
self,
mode: call.CallHandling,
allowed_numbers: Optional[list[str]],
blocked_numbers: Optional[list[str]],
parsed_number: Optional[str],
) -> call.CallHandling:
if allowed_numbers and blocked_numbers:
log(self.config.index, 'Error: cannot specify both of allowed and blocked numbers. Call won\'t be accepted!')
return call.CallHandling.LISTEN
if mode == call.CallHandling.ACCEPT and allowed_numbers:
return call.CallHandling.ACCEPT if Account.is_number_in_list(parsed_number, allowed_numbers) else call.CallHandling.LISTEN
if mode == call.CallHandling.ACCEPT and blocked_numbers:
return call.CallHandling.ACCEPT if not Account.is_number_in_list(parsed_number, blocked_numbers) else call.CallHandling.LISTEN
return mode
@staticmethod
def parse_sip_headers(whole_msg: str, header_names: List[str]) -> Dict[str, Optional[str]]: