Skip to content

Commit efdd068

Browse files
Peter Kubovxkubov
authored andcommitted
fix(sms_operator): Fix message format for voice SMS messages
1 parent 79677b7 commit efdd068

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

pymess/backend/sms/sms_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def _serialize_messages(self, messages, request_type):
111111
# Determine the base template and type based on request type
112112
if request_type in [RequestType.VOICE_MESSAGE, RequestType.VOICE_MESSAGE_DELIVERY_REQUEST]:
113113
base_template = self.TEMPLATES['base_voice']
114-
type_value = 'Voice' if request_type == RequestType.VOICE_MESSAGE else 'Voice-Status'
114+
type_value = 'VoiceMessage' if request_type == RequestType.VOICE_MESSAGE else 'VoiceMessage-Status'
115115
else:
116116
base_template = self.TEMPLATES['base_sms']
117117
type_value = 'SMS' if request_type == RequestType.SMS else 'SMS-Status'
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
<DataTemplate>
2-
{% for message in messages %}
3-
<DataItem>
4-
{% if message.sender %}
5-
<PhoneNumberMo>{{ message.sender }}</PhoneNumberMo>
6-
{% endif %}
7-
<MobileTerminate>{{ message.recipient }}</MobileTerminate>
8-
<Text>{{ message.content }}</Text>
9-
<MsgId>{{ prefix }}{{ message.pk }}</MsgId>
10-
</DataItem>
11-
{% endfor %}
12-
</DataTemplate>
1+
{% for message in messages %}
2+
<DataItem>
3+
<MsgId>{{ prefix }}{{ message.pk }}</MsgId>
4+
<PhoneNumber>{{ message.recipient }}</PhoneNumber>
5+
<VoiceMsg>
6+
<Text>{{ message.content }}</Text>
7+
</VoiceMsg>
8+
</DataItem>
9+
{% endfor %}

tests/test_sms_operator_backend.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ def test_serialize_voice_message_should_use_voice_template(self, backend):
3636

3737
assert root.tag == 'VoiceServices'
3838
header = root.find('./DataHeader/DataType')
39-
assert header.text == 'Voice'
39+
assert header.text == 'VoiceMessage'
4040
item = root.find('.//DataItem')
41-
assert item.find('MobileTerminate').text == '+420111111111'
42-
assert item.find('Text').text == 'Voice content'
41+
assert item.find('PhoneNumber').text == '+420111111111'
42+
assert item.find('./VoiceMsg/Text').text == 'Voice content'
4343
assert item.find('MsgId').text.endswith(str(message.pk))
44-
assert item.find('PhoneNumberMo').text == 'CallerID'
4544

4645
def test_serialize_sms_message_should_use_sms_template(self, backend):
4746
message = OutputSMSMessage.objects.create(

0 commit comments

Comments
 (0)