mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
implemented contact ring endpoint
This commit is contained in:
parent
016154bdf1
commit
123227ce05
20
doc/api.oa3
20
doc/api.oa3
@ -3745,7 +3745,12 @@ paths:
|
||||
description: account disabled
|
||||
'500':
|
||||
description: internal server error
|
||||
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Ring'
|
||||
|
||||
/talk/signal:
|
||||
get:
|
||||
tags:
|
||||
@ -4599,7 +4604,18 @@ components:
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
|
||||
Ring:
|
||||
type: object
|
||||
required:
|
||||
- calleeToken
|
||||
- index
|
||||
properties:
|
||||
calleeToken:
|
||||
type: string
|
||||
index:
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
securitySchemes:
|
||||
|
||||
basicAuth:
|
||||
|
@ -4,6 +4,27 @@ import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
//AddRing adds ring event from contact
|
||||
//AddRing notifies users of requested call
|
||||
func AddRing(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
card, code, err := ParamContactToken(r, false)
|
||||
if err != nil {
|
||||
ErrResponse(w, code, err)
|
||||
return
|
||||
}
|
||||
|
||||
var ring Ring
|
||||
if err := ParseRequest(r, w, &ring); err != nil {
|
||||
ErrResponse(w, http.StatusBadRequest, err)
|
||||
return
|
||||
}
|
||||
|
||||
// push event on first ring
|
||||
if ring.Index == 0 {
|
||||
SendPushEvent(card.Account, "ring");
|
||||
}
|
||||
|
||||
SetRing(card, ring);
|
||||
|
||||
WriteResponse(w, nil)
|
||||
}
|
||||
|
@ -122,6 +122,34 @@ func ExitStatus() {
|
||||
wsExit <- true
|
||||
}
|
||||
|
||||
//SetRing sends ring object on all account websockets
|
||||
func SetRing(card *store.Card, ring Ring) {
|
||||
|
||||
// serialize ring activity
|
||||
var phone Phone
|
||||
phone.CalleeToken = ring.CalleeToken
|
||||
phone.CardID = card.CardSlot.CardSlotID
|
||||
var a Activity
|
||||
a.Phone = phone;
|
||||
msg, err := json.Marshal(a)
|
||||
if err != nil {
|
||||
ErrMsg(err);
|
||||
return
|
||||
}
|
||||
|
||||
// lock access to statusListener
|
||||
wsSync.Lock()
|
||||
defer wsSync.Unlock()
|
||||
|
||||
// notify all listeners
|
||||
chs, ok := statusListener[card.Account.ID]
|
||||
if ok {
|
||||
for _, ch := range chs {
|
||||
ch <- msg
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//SetStatus sends revision object on all account websockets
|
||||
func SetStatus(account *store.Account) {
|
||||
|
||||
|
@ -397,7 +397,7 @@ type ProfileData struct {
|
||||
type Activity struct {
|
||||
Revision Revision `json:"revision,emitempty"`
|
||||
|
||||
Ring Ring `json:"ring",omitempty"`
|
||||
Phone Phone `json:"ring",omitempty"`
|
||||
}
|
||||
|
||||
//Revision revision of each account module
|
||||
@ -416,7 +416,7 @@ type Revision struct {
|
||||
}
|
||||
|
||||
//Ring from contact initiating call
|
||||
type Ring struct {
|
||||
type Phone struct {
|
||||
CardID string `json:"cardId"`
|
||||
|
||||
CalleeToken string `json:"calleeToken"`
|
||||
@ -507,3 +507,25 @@ type TopicDetail struct {
|
||||
|
||||
Transform string `json:"transform,omitempty"`
|
||||
}
|
||||
|
||||
type Call struct {
|
||||
|
||||
Id string `json:"id"`
|
||||
|
||||
CardId string `json:"cardId"`
|
||||
|
||||
CallerToken string `json:"callerToken"`
|
||||
|
||||
CalleeToken string `json:"calleeToken"`
|
||||
|
||||
KeepAlive int32 `json:"keepAlive"`
|
||||
|
||||
SturnPort int32 `json:"sturnPort"`
|
||||
}
|
||||
|
||||
type Ring struct {
|
||||
|
||||
CalleeToken string `json:"calleeToken"`
|
||||
|
||||
Index int32 `json:"index"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user