binwiederhier пре 8 месеци
родитељ
комит
6d15b9face
4 измењених фајлова са 29 додато и 35 уклоњено
  1. 1 1
      cmd/webpush_test.go
  2. 1 1
      docs/integrations.md
  3. 2 0
      docs/releases.md
  4. 25 33
      server/server_firebase.go

+ 1 - 1
cmd/webpush_test.go

@@ -16,7 +16,7 @@ func TestCLI_WebPush_GenerateKeys(t *testing.T) {
 
 func TestCLI_WebPush_WriteKeysToFile(t *testing.T) {
 	app, _, _, stderr := newTestApp()
-	require.Nil(t, runWebPushCommand(app, server.NewConfig(), "keys", "--key-file=key-file.yaml"))
+	require.Nil(t, runWebPushCommand(app, server.NewConfig(), "keys", "--output-file=key-file.yaml"))
 	require.Contains(t, stderr.String(), "Web Push keys written to key-file.yaml")
 	require.FileExists(t, "key-file.yaml")
 }

+ 1 - 1
docs/integrations.md

@@ -18,6 +18,7 @@ I've added a ⭐ to projects or posts that have a significant following, or had
 ## Official integrations
 
 - [changedetection.io](https://changedetection.io) ⭐ - Website change detection and notification
+- [Home Assistant](https://www.home-assistant.io/integrations/ntfy) ⭐ - Home Assistant is an open-source platform for automating and controlling smart home devices.
 - [Healthchecks.io](https://healthchecks.io/) ⭐ - Online service for monitoring regularly running tasks such as cron jobs
 - [Apprise](https://github.com/caronc/apprise/wiki/Notify_ntfy) ⭐ - Push notifications that work with just about every platform
 - [Uptime Kuma](https://uptime.kuma.pet/) ⭐ - A self-hosted monitoring tool
@@ -39,7 +40,6 @@ I've added a ⭐ to projects or posts that have a significant following, or had
 - [HetrixTools](https://docs.hetrixtools.com/ntfy-sh-notifications/) - Uptime monitoring
 - [EasyMorph](https://help.easymorph.com/doku.php?id=transformations:sendntfymessage) - Visual data transformation and automation tool
 - [Monibot](https://monibot.io/) - Monibot monitors your websites, servers and applications and notifies you if something goes wrong.
-- [Home Assistant](https://www.home-assistant.io/integrations/ntfy) - Home Assistant is an open-source platform for automating and controlling smart home devices.
 
 ## Integration via HTTP/SMTP/etc.
 

+ 2 - 0
docs/releases.md

@@ -1383,11 +1383,13 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
 **Bug fixes + maintenance:**
 
 * Security updates for dependencies and Docker images ([#1341](https://github.com/binwiederhier/ntfy/pull/1341))
+* Fix iOS delivery issues for read-protected topics ([#1207](https://github.com/binwiederhier/ntfy/pull/1287), thanks a lot to [@barart](https://github.com/barart)!)
 * Add `Date` header to outgoing emails to avoid rejection ([#1141](https://github.com/binwiederhier/ntfy/pull/1141), thanks to [@pcouy](https://github.com/pcouy))
 * Fix IP address parsing when behind a proxy ([#1266](https://github.com/binwiederhier/ntfy/pull/1266), thanks to [@mmatuska](https://github.com/mmatuska))
 * Make sure UnifiedPush messages are not treated as attachments ([#1312](https://github.com/binwiederhier/ntfy/pull/1312), thanks to [@vkrause](https://github.com/vkrause))
 * Add OCI image version to Docker image ([#1307](https://github.com/binwiederhier/ntfy/pull/1307), thanks to [@jlssmt](https://github.com/jlssmt))
 * WebSocket returning incorrect HTTP error code ([#1338](https://github.com/binwiederhier/ntfy/pull/1338) / [#1337](https://github.com/binwiederhier/ntfy/pull/1337), thanks to [@wunter8](https://github.com/wunter8) for debugging and implementing)
+* Make Markdown in web app scrollable horizontally ([#1262](https://github.com/binwiederhier/ntfy/pull/1262), thanks to [@rake5k](https://github.com/rake5k) for fixing)
 
 **Documentation:**
 

+ 25 - 33
server/server_firebase.go

@@ -50,7 +50,7 @@ func (c *firebaseClient) Send(v *visitor, m *message) error {
 		ev.Field("firebase_message", util.MaybeMarshalJSON(fbm)).Trace("Firebase message")
 	}
 	err = c.sender.Send(fbm)
-	if err == errFirebaseQuotaExceeded {
+	if errors.Is(err, errFirebaseQuotaExceeded) {
 		logvm(v, m).
 			Tag(tagFirebase).
 			Err(err).
@@ -133,7 +133,7 @@ func toFirebaseMessage(m *message, auther user.Auther) (*messaging.Message, erro
 			"time":    fmt.Sprintf("%d", m.Time),
 			"event":   m.Event,
 			"topic":   m.Topic,
-			"message": m.Message,
+			"message": newMessageBody,
 			"poll_id": m.PollID,
 		}
 		apnsConfig = createAPNSAlertConfig(m, data)
@@ -173,28 +173,29 @@ func toFirebaseMessage(m *message, auther user.Auther) (*messaging.Message, erro
 			}
 			apnsConfig = createAPNSAlertConfig(m, data)
 		} else {
-			// If anonymous read for a topic is not allowed, we cannot send the message along
+			// If "anonymous read" for a topic is not allowed, we cannot send the message along
 			// via Firebase. Instead, we send a "poll_request" message, asking the client to poll.
-			//App function needs all the data to create a message object, if not, it fails,
-			//so we set it but put a placeholders to not to send the actual message
-			//but generic title and message instead, we also add the poll_id so client knowns
-			//what message is goint to "decode" (retrieve)
+			//
+			// The data map needs to contain all the fields for it to function properly. If not all
+			// fields are set, the iOS app fails to decode the message.
+			//
+			// See https://github.com/binwiederhier/ntfy/pull/1345
 			data = map[string]string{
-                                "id":    m.ID,
-                                "time":  fmt.Sprintf("%d", m.Time),
-                                "event": pollRequestEvent,
-                                "topic": m.Topic,
-                                "priority":     fmt.Sprintf("%d", m.Priority),                                            
-                                "tags":         strings.Join(m.Tags, ","),                                                
-                                "click":        m.Click,                                                                  
-                                "icon":         m.Icon,                                                                      
-                                "title":        "Private",                                                                     
-                                "message":      "Message",                                                                
-                                "content_type": m.ContentType,                                                            
-                                "encoding":     m.Encoding,
-                                "poll_id": m.ID,
-                        }
-                        apnsConfig = createAPNSAlertConfig(m, data)
+				"id":           m.ID,
+				"time":         fmt.Sprintf("%d", m.Time),
+				"event":        pollRequestEvent,
+				"topic":        m.Topic,
+				"priority":     fmt.Sprintf("%d", m.Priority),
+				"tags":         "",
+				"click":        "",
+				"icon":         "",
+				"title":        "",
+				"message":      newMessageBody,
+				"content_type": m.ContentType,
+				"encoding":     m.Encoding,
+				"poll_id":      m.ID,
+			}
+			apnsConfig = createAPNSAlertConfig(m, data)
 		}
 	}
 	var androidConfig *messaging.AndroidConfig
@@ -238,23 +239,14 @@ func createAPNSAlertConfig(m *message, data map[string]string) *messaging.APNSCo
 	for k, v := range data {
 		apnsData[k] = v
 	}
-	alertTitle := m.Title
-        alertBody := maybeTruncateAPNSBodyMessage(m.Message)
-        // If the event is pollRequestEvent (server/topic is restricted) we dont want to
-	//send the actual message to Firebase/APNS, so we send a generic text
-	//if for some reason, client cant retrieve the message, it shows this as the message and title
-        if event, ok := data["event"]; ok && event == pollRequestEvent {
-                alertTitle = "New Notification received"
-                alertBody = "Message cant be retrieved, open the app and refresh content"
-        }
 	return &messaging.APNSConfig{
 		Payload: &messaging.APNSPayload{
 			CustomData: apnsData,
 			Aps: &messaging.Aps{
 				MutableContent: true,
 				Alert: &messaging.ApsAlert{
-					Title: alertTitle,
-					Body:  alertBody,
+					Title: m.Title,
+					Body:  maybeTruncateAPNSBodyMessage(m.Message),
 				},
 			},
 		},