-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotifications.go
56 lines (46 loc) · 1.14 KB
/
notifications.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"github.com/deckarep/gosx-notifier"
"github.com/sadlil/go-trigger"
"io"
"log"
"net/http"
"os"
)
const userSuccess string = "Upload complete"
const userFail string = "Upload fail"
const notifTitle string = "On updemia.com"
const distantLogo string = "http://www.updemia.com/images/logo.png"
const localLogo string = "/tmp/m1UIjW1.png"
func notifyUserSuccess(url string) {
note := gosxnotifier.NewNotification(userSuccess)
note.AppIcon = localLogo
note.Title = notifTitle
note.Link = url
note.Group = "com.unique.updemia.identifier"
err := note.Push()
if err != nil {
log.Println("notification error")
}
trigger.Fire("user-newfile-success")
}
func notifyUserFail() {
note := gosxnotifier.NewNotification(userFail)
note.AppIcon = localLogo
note.Title = notifTitle
note.Group = "com.unique.updemia.identifier"
err := note.Push()
if err != nil {
log.Println("notification error")
}
}
func saveNotificationLogo() {
img, _ := os.Create(localLogo)
defer img.Close()
resp, _ := http.Get(distantLogo)
defer resp.Body.Close()
_, err := io.Copy(img, resp.Body)
if err != nil {
log.Println("Error getting logo")
}
}