mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 11:39:17 +00:00
set remote push notification to post
This commit is contained in:
parent
df64fef322
commit
aae3104457
@ -102,37 +102,49 @@ func sendRemoteNotification(notification *store.Notification) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var body []byte
|
|
||||||
var err error
|
|
||||||
if module == "notification" {
|
if module == "notification" {
|
||||||
body, err = json.Marshal(notification.Event)
|
body, err := json.Marshal(notification.Event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrMsg(err)
|
ErrMsg(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
url := "https://" + notification.Node + "/contact/" + module + "?contact=" + notification.GUID + "." + notification.Token
|
||||||
|
req, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(body))
|
||||||
|
if err != nil {
|
||||||
|
ErrMsg(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
ErrMsg(err)
|
||||||
|
}
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
LogMsg("failed to notify contact")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
body, err = json.Marshal(notification.Revision)
|
body, err := json.Marshal(notification.Revision)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ErrMsg(err)
|
ErrMsg(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
url := "https://" + notification.Node + "/contact/" + module + "?contact=" + notification.GUID + "." + notification.Token
|
||||||
|
req, err := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(body))
|
||||||
|
if err != nil {
|
||||||
|
ErrMsg(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||||
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
ErrMsg(err)
|
||||||
|
}
|
||||||
|
if resp.StatusCode != 200 {
|
||||||
|
LogMsg("failed to notify contact")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
url := "https://" + notification.Node + "/contact/" + module + "?contact=" + notification.GUID + "." + notification.Token
|
|
||||||
req, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(body))
|
|
||||||
if err != nil {
|
|
||||||
ErrMsg(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.Header.Set("Content-Type", "application/json; charset=utf-8")
|
|
||||||
client := &http.Client{}
|
|
||||||
resp, err := client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
ErrMsg(err)
|
|
||||||
}
|
|
||||||
if resp.StatusCode != 200 {
|
|
||||||
LogMsg("failed to notify contact")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//SetProfileNotification notifies all connected contacts of profile changes
|
//SetProfileNotification notifies all connected contacts of profile changes
|
||||||
|
Loading…
Reference in New Issue
Block a user