diff --git a/e2e-tests/pass/http.go b/e2e-tests/pass/http.go index aac4206..3214335 100644 --- a/e2e-tests/pass/http.go +++ b/e2e-tests/pass/http.go @@ -156,14 +156,14 @@ func browserExtensionRequestSync(token string) (RequestSyncResponse, error) { return resp, nil } -func browserExtensionPush(token, body string) (string, error) { +func browserExtensionPush(token string, data map[string]string) (string, error) { var resp struct { Response string `json:"response"` } req := struct { - Body string `json:"push_body"` + Data map[string]string `json:"data"` }{ - Body: body, + Data: data, } if err := request("POST", "/browser_extension/sync/push", token, req, &resp); err != nil { diff --git a/e2e-tests/pass/sync_test.go b/e2e-tests/pass/sync_test.go index 1cbf19c..13447d1 100644 --- a/e2e-tests/pass/sync_test.go +++ b/e2e-tests/pass/sync_test.go @@ -33,7 +33,7 @@ func TestSyncHappyFlow(t *testing.T) { return } - pushResp, err := browserExtensionPush(requestSyncResp.BrowserExtensionWaitToken, "body") + pushResp, err := browserExtensionPush(requestSyncResp.BrowserExtensionWaitToken, map[string]string{"hello": "world!"}) if err != nil { t.Errorf("Error when Browser Extension tried to send push notification: %v", err) return diff --git a/internal/pass/sync/handlers.go b/internal/pass/sync/handlers.go index 4130663..3df09eb 100644 --- a/internal/pass/sync/handlers.go +++ b/internal/pass/sync/handlers.go @@ -39,7 +39,7 @@ func ExtensionRequestSync(syncingApp *Syncing) gin.HandlerFunc { } type PushToMobileRequest struct { - Body string `json:"push_body"` + DataMessage map[string]string `json:"data_message"` } func ExtensionRequestPush(syncingApp *Syncing) gin.HandlerFunc { @@ -64,7 +64,7 @@ func ExtensionRequestPush(syncingApp *Syncing) gin.HandlerFunc { return } - resp, err := syncingApp.SendPush(gCtx, fcmToken, req.Body) + resp, err := syncingApp.SendPush(gCtx, fcmToken, req.DataMessage) if err != nil { log.Errorf("Failed to send push message: %v", err) gCtx.Status(http.StatusInternalServerError) diff --git a/internal/pass/sync/sync.go b/internal/pass/sync/sync.go index ab86dee..689e5c5 100644 --- a/internal/pass/sync/sync.go +++ b/internal/pass/sync/sync.go @@ -183,16 +183,11 @@ func (s *Syncing) RequestSync(ctx *gin.Context, token string) (RequestSyncRespon }, nil } -func (s *Syncing) SendPush(ctx *gin.Context, token string, body string) (fcm.Response, error) { +func (s *Syncing) SendPush(ctx *gin.Context, token string, body map[string]string) (fcm.Response, error) { msg := &messaging.Message{ Token: token, Android: &messaging.AndroidConfig{ - Notification: &messaging.AndroidNotification{ - Title: "2pass push request", - }, - Data: map[string]string{ - "data": body, - }, + Data: body, }, } return s.fcmClient.Send(ctx, msg)