Skip to content

Commit

Permalink
Merge pull request #1159 from Kisuke-CZE/fix-dlr-interception
Browse files Browse the repository at this point in the history
Moved setting DLR mas from HTTP request before interception is done.
  • Loading branch information
farirat authored Mar 27, 2024
2 parents 7c1f406 + bb1c6ac commit 6a29aeb
Showing 1 changed file with 32 additions and 35 deletions.
67 changes: 32 additions & 35 deletions jasmin/protocols/http/endpoints/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,38 @@ def route_routable(self, updated_request):
routable.addTag(tag)
self.log.debug('Tagged routable %s: +%s', routable, tag)

# Set DLR bit mask on the last pdu
_last_pdu = routable.pdu
while hasattr(_last_pdu, 'nextPdu'):
_last_pdu = _last_pdu.nextPdu
# DLR setting is clearly described in #107
_last_pdu.params['registered_delivery'] = RegisteredDelivery(
RegisteredDeliveryReceipt.NO_SMSC_DELIVERY_RECEIPT_REQUESTED)
if updated_request.args[b'dlr'][0] == b'yes':
_last_pdu.params['registered_delivery'] = RegisteredDelivery(
RegisteredDeliveryReceipt.SMSC_DELIVERY_RECEIPT_REQUESTED)
self.log.debug(
"SubmitSmPDU registered_delivery is set to %s",
str(_last_pdu.params['registered_delivery']))

dlr_level = int(updated_request.args[b'dlr-level'][0])
if b'dlr-url' in updated_request.args:
dlr_url = updated_request.args[b'dlr-url'][0]
else:
dlr_url = None
if updated_request.args[b'dlr-level'][0] == b'1':
dlr_level_text = 'SMS-C'
elif updated_request.args[b'dlr-level'][0] == b'2':
dlr_level_text = 'Terminal'
else:
dlr_level_text = 'All'
dlr_method = updated_request.args[b'dlr-method'][0]
else:
dlr_url = None
dlr_level = 0
dlr_level_text = 'No'
dlr_method = None

# Intercept
interceptor = self.RouterPB.getMTInterceptionTable().getInterceptorFor(routable)
if interceptor is not None:
Expand Down Expand Up @@ -257,41 +289,6 @@ def route_routable(self, updated_request):
routable = update_submit_sm_pdu(routable=routable, config=param_updates,
config_update_params=list(param_updates))

# Set DLR bit mask on the last pdu
_last_pdu = routable.pdu
while True:
if hasattr(_last_pdu, 'nextPdu'):
_last_pdu = _last_pdu.nextPdu
else:
break
# DLR setting is clearly described in #107
_last_pdu.params['registered_delivery'] = RegisteredDelivery(
RegisteredDeliveryReceipt.NO_SMSC_DELIVERY_RECEIPT_REQUESTED)
if updated_request.args[b'dlr'][0] == b'yes':
_last_pdu.params['registered_delivery'] = RegisteredDelivery(
RegisteredDeliveryReceipt.SMSC_DELIVERY_RECEIPT_REQUESTED)
self.log.debug(
"SubmitSmPDU registered_delivery is set to %s",
str(_last_pdu.params['registered_delivery']))

dlr_level = int(updated_request.args[b'dlr-level'][0])
if b'dlr-url' in updated_request.args:
dlr_url = updated_request.args[b'dlr-url'][0]
else:
dlr_url = None
if updated_request.args[b'dlr-level'][0] == b'1':
dlr_level_text = 'SMS-C'
elif updated_request.args[b'dlr-level'][0] == b'2':
dlr_level_text = 'Terminal'
else:
dlr_level_text = 'All'
dlr_method = updated_request.args[b'dlr-method'][0]
else:
dlr_url = None
dlr_level = 0
dlr_level_text = 'No'
dlr_method = None

# QoS throttling
if (user.mt_credential.getQuota('http_throughput') and user.mt_credential.getQuota('http_throughput') >= 0) and user.getCnxStatus().httpapi[
'qos_last_submit_sm_at'] != 0:
Expand Down

0 comments on commit 6a29aeb

Please sign in to comment.