phonecalls: do not consider existing calls on call start (#69972)
gitea-wip/passerelle/pipeline/head Build started... Details
gitea/passerelle/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Thomas NOËL 2022-10-06 18:40:30 +02:00
parent 78df755c13
commit 1d8bcee706
2 changed files with 3 additions and 50 deletions

View File

@ -58,17 +58,9 @@ class PhoneCalls(BaseResource):
},
)
def call_start(self, request, callee, caller, redirect=None, newtab=None, **kwargs):
existing_call = Call.objects.filter(
resource=self, callee=callee, caller=caller, end_timestamp=None
).last()
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()}
new_call = Call(resource=self, callee=callee, caller=caller, details=kwargs)
new_call.save()
response = {'data': new_call.json()}
redirect_url = self.redirect_url
if redirect_url:

View File

@ -63,45 +63,6 @@ def test_phonecalls_start_stop(app, phonecalls):
assert call.caller == '0612345678'
assert call.end_timestamp is None
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'})
assert resp.json['err'] == 0