From 2e19e04e67b6983dda8c9c1339b8272d76166c81 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Thu, 5 Sep 2024 20:39:17 +0200 Subject: [PATCH] simplify --- command/push.go | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/command/push.go b/command/push.go index 488927f..ee400dd 100644 --- a/command/push.go +++ b/command/push.go @@ -80,8 +80,7 @@ func doPush(ctx *cli.Context) { Priority: priority, } - msg.Extras = map[string]interface{}{ - } + msg.Extras = map[string]interface{}{} if contentType != "" { msg.Extras["client::display"] = map[string]interface{}{ @@ -89,22 +88,15 @@ func doPush(ctx *cli.Context) { } } + clientNotifications := map[string]interface{}{} if clickUrl != "" { - msg.Extras["client::notification"] = map[string]interface{}{ - "click": map[string]string{ - "url": clickUrl, - }, - } + clientNotifications["click"] = map[string]string{"url": clickUrl} } - if bigImageUrl != "" { - if _, clientNotification := msg.Extras["client::notification"]; clientNotification { - msg.Extras["client::notification"].(map[string]interface{})["bigImageUrl"] = bigImageUrl; - } else { - msg.Extras["client::notification"] = map[string]interface{}{ - "bigImageUrl": bigImageUrl, - } - } + clientNotifications["bigImageUrl"] = bigImageUrl + } + if len(clientNotifications) > 0 { + msg.Extras["client::notification"] = clientNotifications } parsedURL, err := url.Parse(stringURL)