phonecalls: do not consider existing calls on call start (#69972)
This commit is contained in:
parent
78df755c13
commit
1d8bcee706
|
@ -58,17 +58,9 @@ class PhoneCalls(BaseResource):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
def call_start(self, request, callee, caller, redirect=None, newtab=None, **kwargs):
|
def call_start(self, request, callee, caller, redirect=None, newtab=None, **kwargs):
|
||||||
existing_call = Call.objects.filter(
|
new_call = Call(resource=self, callee=callee, caller=caller, details=kwargs)
|
||||||
resource=self, callee=callee, caller=caller, end_timestamp=None
|
new_call.save()
|
||||||
).last()
|
response = {'data': new_call.json()}
|
||||||
if existing_call:
|
|
||||||
existing_call.details = kwargs
|
|
||||||
existing_call.save()
|
|
||||||
response = {'data': existing_call.json()}
|
|
||||||
else:
|
|
||||||
new_call = Call(resource=self, callee=callee, caller=caller, details=kwargs)
|
|
||||||
new_call.save()
|
|
||||||
response = {'data': new_call.json()}
|
|
||||||
|
|
||||||
redirect_url = self.redirect_url
|
redirect_url = self.redirect_url
|
||||||
if redirect_url:
|
if redirect_url:
|
||||||
|
|
|
@ -63,45 +63,6 @@ def test_phonecalls_start_stop(app, phonecalls):
|
||||||
assert call.caller == '0612345678'
|
assert call.caller == '0612345678'
|
||||||
assert call.end_timestamp is None
|
assert call.end_timestamp is None
|
||||||
assert call.details == {}
|
assert call.details == {}
|
||||||
json_start = resp.json['data']['start']
|
|
||||||
start = call.start_timestamp
|
|
||||||
|
|
||||||
# same call, do nothing
|
|
||||||
resp = app.get(
|
|
||||||
start_endpoint, status=200, params={'apikey': '123', 'callee': '42', 'caller': '0612345678'}
|
|
||||||
)
|
|
||||||
assert resp.json['err'] == 0
|
|
||||||
assert resp.json['data']['callee'] == '42'
|
|
||||||
assert resp.json['data']['caller'] == '0612345678'
|
|
||||||
assert resp.json['data']['start'] == json_start
|
|
||||||
assert resp.json['data']['end'] is None
|
|
||||||
assert resp.json['data']['is_current'] is True
|
|
||||||
assert Call.objects.count() == 1
|
|
||||||
call = Call.objects.first()
|
|
||||||
assert call.callee == '42'
|
|
||||||
assert call.caller == '0612345678'
|
|
||||||
assert call.end_timestamp is None
|
|
||||||
assert call.start_timestamp == start
|
|
||||||
assert call.details == {}
|
|
||||||
resp = app.get(
|
|
||||||
start_endpoint,
|
|
||||||
status=200,
|
|
||||||
params={'apikey': '123', 'callee': '42', 'caller': '0612345678', 'foo': 'bar'},
|
|
||||||
) # add details
|
|
||||||
assert resp.json['err'] == 0
|
|
||||||
assert resp.json['data']['callee'] == '42'
|
|
||||||
assert resp.json['data']['caller'] == '0612345678'
|
|
||||||
assert resp.json['data']['start'] == json_start
|
|
||||||
assert resp.json['data']['end'] is None
|
|
||||||
assert resp.json['data']['is_current'] is True
|
|
||||||
assert resp.json['data']['details'] == {'foo': 'bar'}
|
|
||||||
assert Call.objects.count() == 1
|
|
||||||
call = Call.objects.first()
|
|
||||||
assert call.callee == '42'
|
|
||||||
assert call.caller == '0612345678'
|
|
||||||
assert call.end_timestamp is None
|
|
||||||
assert call.start_timestamp == start
|
|
||||||
assert call.details == {'foo': 'bar'}
|
|
||||||
|
|
||||||
resp = app.get(calls_endpoint, status=200, params={'apikey': '123'})
|
resp = app.get(calls_endpoint, status=200, params={'apikey': '123'})
|
||||||
assert resp.json['err'] == 0
|
assert resp.json['err'] == 0
|
||||||
|
|
Loading…
Reference in New Issue