mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
set remote push notification to post
This commit is contained in:
parent
df64fef322
commit
aae3104457
@ -102,22 +102,12 @@ 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
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
body, err = json.Marshal(notification.Revision)
|
|
||||||
if err != nil {
|
|
||||||
ErrMsg(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "https://" + notification.Node + "/contact/" + module + "?contact=" + notification.GUID + "." + notification.Token
|
url := "https://" + notification.Node + "/contact/" + module + "?contact=" + notification.GUID + "." + notification.Token
|
||||||
req, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(body))
|
req, err := http.NewRequest(http.MethodPut, url, bytes.NewBuffer(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -133,6 +123,28 @@ func sendRemoteNotification(notification *store.Notification) {
|
|||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
LogMsg("failed to notify contact")
|
LogMsg("failed to notify contact")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
body, err := json.Marshal(notification.Revision)
|
||||||
|
if err != nil {
|
||||||
|
ErrMsg(err)
|
||||||
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//SetProfileNotification notifies all connected contacts of profile changes
|
//SetProfileNotification notifies all connected contacts of profile changes
|
||||||
|
Loading…
Reference in New Issue
Block a user