Public | Automated Build

Last pushed: 2 years ago
Short Description
Django application that manages incoming call APNS and GCM notification for Vialer app
Full Description

Incoming Call Notifier

Main purpose for now to send notification to APNS or GCM, and wait for the client to report back and give the webhook
feedback about the status of that roundtrip.

General workings

Todo

API

Few calls possible:

/api/

Main entry point

/api/call/ (GET)

Sends call message to first device in the list. No params required.

/api/incoming-call/ (POST)

Send call to device.
Params:

  • sip_user_id: The SIP ID of the user
  • caller_id: For use in the app
  • phonenumber: For use in the app

/api/call-response/ (POST)

If a call is received by the device, it must check back in here. POST params are: unique_key (as you got with the
notification)

/api/apns-device-checkin/ & /api/gcm-device-checkin/ (POST)

You can POST the token and it will store the current time in the last_seen field of the device. That way you
can see if it is probable that it's still reachable.

/api/register-apns-device/ & /api/register-gcm-device/ (POST)

You need to send the following:

  • name: Pretty name of the device (for administration purposes)
  • token: push token, also your primairy key
  • sip_user_id: used for finding it back when you get called
  • os_version: current operating system
  • client_version: version of the Vialer app

Response is 200 if updated and 201 for created.

/api/unregister-apns-device/ & /api/unregister-gcm-device/ (POST)

You need to send the following:

  • token push token, also your primairy key
  • sip_user_id - used for finding it back when you get called

Reponse is 404 when it can't find your registration (also fine I guess) and a 200 if the registration was successfully
deleted.

Notification

The notifications have a payload. Here the structure explained.

Incoming calls

The phonenumber is the number of the person trying to call, caller_id can be text name. The
response_api is the location you should check in to when receiving the notification and AFTER a successful SIP
registration.

payload = {
    'type': 'call',
    'unique_key': unique_key,
    'phonenumber': phonenumber,
    'caller_id': caller_id,
    'response_api': 'htp:/server/api/call-response/'
}

Checkin request

NOT IMPLEMENTED
This is required to stay reachable. If a checkin is longer than one hour, you will not be reachable anymore.
You need to post the following parameter:

  • token: your push token

Response is 200 if successful.

Sample payload (apns):

payload = {
    'type': 'checkin',
    'response_api': 'htp:/server/api/apns-device-checkin/'
}

Message

Client app must display this message when received.

payload = {
    'type': 'message',
    'message': 'message_body'
}

/api/write-to-log/ (POST)

You can add a line to the middleware log by supplying the following:

  • token: your push token (APNS or GCM)
  • log_message: the message you would like to be included in the log

    OPTIONAL:

  • unique_key: A calls 'unique key' recommended to be sent when available

  • message_start_time: A time stamp received by the server, if available, return it unchanged

Response is a 200 on success or 400 when not all required parameters supplied

Running the Middleware

Run local:

docker rm incommingcallnotifier_app_1 && docker rm incommingcallnotifier_worker_1 && docker rmi incommingcallnotifier_app && docker rmi incommingcallnotifier_worker && docker-compose up -d

Rebuild and push

docker-compose build app && docker tag -f incommingcallnotifier_app:latest registry.peperzaken.nl/incomingcallnotifier:latest && docker push registry.peperzaken.nl/incomingcallnotifier:latest
Docker Pull Command
Owner
voipgrid

Comments (0)