mirror of
https://github.com/balzack/databag.git
synced 2025-02-11 19:19:16 +00:00
30 lines
517 B
Go
30 lines
517 B
Go
package databag
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
//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)
|
|
}
|