Browse Source

SendLink can send link to specific device

Piotr Czajkowski 3 years ago
parent
commit
40e0102289
3 changed files with 7 additions and 7 deletions
  1. 3 3
      bullet.go
  2. 2 2
      bullet_test.go
  3. 2 2
      push.go

+ 3 - 3
bullet.go

@@ -96,9 +96,9 @@ func (b Bullet) SendNote(title, text, deviceID string) error {
 	return err
 }
 
-//SendLink sends push link with given title, text and link
-func (b Bullet) SendLink(title, text, link string) error {
-	linkPush := newLinkPush(title, text, link)
+//SendLink sends push link with given title, text and link, use empty string as deviceID to send to all
+func (b Bullet) SendLink(title, text, link, deviceID string) error {
+	linkPush := newLinkPush(title, text, link, deviceID)
 	err := b.send(linkPush)
 
 	return err

+ 2 - 2
bullet_test.go

@@ -65,7 +65,7 @@ func TestSendLink(t *testing.T) {
 
 	b := Bullet{token: "", baseURL: server.URL}
 
-	err := b.SendLink("test", "test", "url")
+	err := b.SendLink("test", "test", "url", "")
 	if err != nil {
 		t.Error(err)
 	}
@@ -78,7 +78,7 @@ func TestSendLinkFail(t *testing.T) {
 
 	b := Bullet{token: "", baseURL: server.URL}
 
-	err := b.SendLink("test", "test", "url")
+	err := b.SendLink("test", "test", "url", "")
 	if err == nil {
 		t.Error("There should be error")
 	}

+ 2 - 2
push.go

@@ -21,7 +21,7 @@ func newNotePush(title, text, deviceID string) pushStruct {
 	return push
 }
 
-func newLinkPush(title, text, link string) pushStruct {
-	push := pushStruct{Type: "note", Title: title, Body: text, Url: link}
+func newLinkPush(title, text, link, deviceID string) pushStruct {
+	push := pushStruct{Type: "note", Title: title, Body: text, Url: link, DeviceID: deviceID}
 	return push
 }