mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
implemented contact ring endpoint
This commit is contained in:
parent
016154bdf1
commit
123227ce05
16
doc/api.oa3
16
doc/api.oa3
@ -3745,6 +3745,11 @@ paths:
|
|||||||
description: account disabled
|
description: account disabled
|
||||||
'500':
|
'500':
|
||||||
description: internal server error
|
description: internal server error
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Ring'
|
||||||
|
|
||||||
/talk/signal:
|
/talk/signal:
|
||||||
get:
|
get:
|
||||||
@ -4599,6 +4604,17 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
|
|
||||||
|
Ring:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- calleeToken
|
||||||
|
- index
|
||||||
|
properties:
|
||||||
|
calleeToken:
|
||||||
|
type: string
|
||||||
|
index:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
|
|
||||||
|
@ -4,6 +4,27 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
//AddRing adds ring event from contact
|
//AddRing notifies users of requested call
|
||||||
func AddRing(w http.ResponseWriter, r *http.Request) {
|
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
|
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
|
//SetStatus sends revision object on all account websockets
|
||||||
func SetStatus(account *store.Account) {
|
func SetStatus(account *store.Account) {
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ type ProfileData struct {
|
|||||||
type Activity struct {
|
type Activity struct {
|
||||||
Revision Revision `json:"revision,emitempty"`
|
Revision Revision `json:"revision,emitempty"`
|
||||||
|
|
||||||
Ring Ring `json:"ring",omitempty"`
|
Phone Phone `json:"ring",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//Revision revision of each account module
|
//Revision revision of each account module
|
||||||
@ -416,7 +416,7 @@ type Revision struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Ring from contact initiating call
|
//Ring from contact initiating call
|
||||||
type Ring struct {
|
type Phone struct {
|
||||||
CardID string `json:"cardId"`
|
CardID string `json:"cardId"`
|
||||||
|
|
||||||
CalleeToken string `json:"calleeToken"`
|
CalleeToken string `json:"calleeToken"`
|
||||||
@ -507,3 +507,25 @@ type TopicDetail struct {
|
|||||||
|
|
||||||
Transform string `json:"transform,omitempty"`
|
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