feat: Support disabling message previews
authorKyle Fuller <redacted>
Thu, 13 Apr 2017 15:16:39 +0000 (16:16 +0100)
committerKyle Fuller <redacted>
Thu, 13 Apr 2017 15:48:53 +0000 (16:48 +0100)
CHANGELOG.md
palaver.cpp

index 723124b1cf4e3250b4f7c1a430842e195deff478..7f296f9dc1c036647e2301af3f4bcb3f0d64e95b 100644 (file)
@@ -20,6 +20,9 @@
 - We no longer mention you with private NOTICEs, these are usually server or
   service notices and rarely from a real user.
 
+- You can now disable showing message previews in the Palaver app which will
+  prevent the message contents from being sent as a push notification.
+
 ### Bug Fixes
 
 - We now detect when building the module with an unsupported compiler and will
index 2907f61a0766661798aa0bac37edbb8f9f50ab36..8a592432ab92b159ff8c0cb0e6e0b7d0b1bae9bc 100644 (file)
@@ -40,6 +40,7 @@ const char *kPLVMentionNickKey = "MENTION-NICK";
 const char *kPLVIgnoreKeywordKey = "IGNORE-KEYWORD";
 const char *kPLVIgnoreChannelKey = "IGNORE-CHANNEL";
 const char *kPLVIgnoreNickKey = "IGNORE-NICK";
+const char *kPLVShowMessagePreviewKey = "SHOW-MESSAGE-PREVIEW";
 
 
 #ifdef HAS_REGEX
@@ -245,6 +246,14 @@ public:
                return m_sPushEndpoint;
        }
 
+       void SetShowMessagePreview(bool bShowMessagePreview) {
+               m_bShowMessagePreview = bShowMessagePreview;
+       }
+
+       bool GetShowMessagePreview() const {
+               return m_bShowMessagePreview;
+       }
+
        bool HasClient(const CClient& client) const {
                bool bHasClient = false;
 
@@ -392,6 +401,7 @@ public:
                m_bInNegotiation = false;
                m_sVersion = "";
                m_sPushEndpoint = "";
+               m_bShowMessagePreview = true;
 
                m_vMentionKeywords.clear();
                m_vMentionChannels.clear();
@@ -570,6 +580,8 @@ public:
                                SetVersion(sValue);
                        } else if (sKey.Equals(kPLVPushEndpointKey)) {
                                SetPushEndpoint(sValue);
+                       } else if (sKey.Equals(kPLVShowMessagePreviewKey)) {
+                               SetShowMessagePreview(sValue.Equals("true"));
                        }
                } else if (sCommand.Equals("ADD")) {
                        CString sKey = sLine.Token(1);
@@ -607,6 +619,12 @@ public:
                        File.Write("SET VERSION " + GetVersion() + "\n");
                }
 
+               if (GetShowMessagePreview()) {
+                       File.Write("SET " + CString(kPLVShowMessagePreviewKey) + " true\n");
+               } else {
+                       File.Write("SET " + CString(kPLVShowMessagePreviewKey) + " false\n");
+               }
+
                if (GetPushEndpoint().empty() == false) {
                        File.Write("SET " + CString(kPLVPushEndpointKey) + " " + GetPushEndpoint() + "\n");
                }
@@ -681,7 +699,13 @@ public:
 
                CString sJSON = "{";
                sJSON += "\"badge\": " + CString(m_uiBadge);
-               sJSON += ",\"message\": \"" + sNotification.Replace_n("\"", "\\\"") + "\"";
+
+               if (GetShowMessagePreview()) {
+                       sJSON += ",\"message\": \"" + sNotification.Replace_n("\"", "\\\"") + "\"";
+               } else {
+                       sJSON += ",\"private\": true";
+               }
+
                sJSON += ",\"sender\": \"" + sSender.Replace_n("\"", "\\\"") + "\"";
                if (pChannel) {
                        sJSON += ",\"channel\": \"" + pChannel->GetName().Replace_n("\"", "\\\"") + "\"";
@@ -737,6 +761,7 @@ private:
        VCString m_vIgnoreChannels;
        VCString m_vIgnoreNicks;
 
+       bool m_bShowMessagePreview;
        bool m_bInNegotiation;
        unsigned int m_uiBadge;
 };
git clone https://git.99rst.org/PROJECT