[Pkg-owncloud-commits] [owncloud-client] 101/135: Notifications: Propagate "Dismiss" as DELETE to server #5922

Sandro Knauß hefee at debian.org
Sat Sep 9 14:28:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

hefee pushed a commit to branch master
in repository owncloud-client.

commit e86416fff7c74174e699802cec46da8ca3c3aad5
Author: Markus Goetz <markus at woboq.com>
Date:   Thu Aug 3 18:03:58 2017 +0200

    Notifications: Propagate "Dismiss" as DELETE to server #5922
---
 src/gui/activitywidget.cpp            |  3 +--
 src/gui/notificationwidget.cpp        |  4 ++--
 src/gui/ocsjob.cpp                    |  1 +
 src/gui/ocsjob.h                      |  2 ++
 src/gui/servernotificationhandler.cpp | 14 +++++++++++++-
 5 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp
index 8d0efef..9006890 100644
--- a/src/gui/activitywidget.cpp
+++ b/src/gui/activitywidget.cpp
@@ -438,14 +438,13 @@ void ActivityWidget::slotNotifyServerFinished( const QString& reply, int replyCo
     }
 
     endNotificationRequest(job->widget(), replyCode);
-    // FIXME: remove the  widget after a couple of seconds
     qDebug() << Q_FUNC_INFO << "Server Notification reply code"<< replyCode << reply;
 
     // if the notification was successful start a timer that triggers
     // removal of the done widgets in a few seconds
     // Add 200 millisecs to the predefined value to make sure that the timer in
     // widget's method readyToClose() has elapsed.
-    if( replyCode == OCS_SUCCESS_STATUS_CODE ) {
+    if( replyCode == OCS_SUCCESS_STATUS_CODE || replyCode == OCS_SUCCESS_STATUS_CODE_V2 ) {
         scheduleWidgetToRemove( job->widget() );
     }
 }
diff --git a/src/gui/notificationwidget.cpp b/src/gui/notificationwidget.cpp
index 7aa3178..107b02f 100644
--- a/src/gui/notificationwidget.cpp
+++ b/src/gui/notificationwidget.cpp
@@ -125,8 +125,8 @@ void NotificationWidget::slotNotificationRequestFinished(int statusCode)
 
     QString timeStr = locale.toString(QTime::currentTime());
 
-    // the ocs API returns stat code 100 if it succeeded.
-    if( statusCode != OCS_SUCCESS_STATUS_CODE  ) {
+    // the ocs API returns stat code 100 or 200 inside the xml if it succeeded.
+    if( statusCode != OCS_SUCCESS_STATUS_CODE && statusCode != OCS_SUCCESS_STATUS_CODE_V2 ) {
         qDebug() << Q_FUNC_INFO << "Notification Request to Server failed, leave button visible.";
         for( i = 0; i < _buttons.count(); i++ ) {
             _buttons.at(i)->setEnabled(true);
diff --git a/src/gui/ocsjob.cpp b/src/gui/ocsjob.cpp
index b6f9f4e..82b31dd 100644
--- a/src/gui/ocsjob.cpp
+++ b/src/gui/ocsjob.cpp
@@ -25,6 +25,7 @@ OcsJob::OcsJob(AccountPtr account)
 : AbstractNetworkJob(account, "")
 {
     _passStatusCodes.append(OCS_SUCCESS_STATUS_CODE);
+    _passStatusCodes.append(OCS_SUCCESS_STATUS_CODE_V2);
     setIgnoreCredentialFailure(true);
 }
 
diff --git a/src/gui/ocsjob.h b/src/gui/ocsjob.h
index 602b305..889ef7b 100644
--- a/src/gui/ocsjob.h
+++ b/src/gui/ocsjob.h
@@ -24,6 +24,8 @@
 #include <QUrl>
 
 #define OCS_SUCCESS_STATUS_CODE 100
+// Apparantly the v2.php URLs can return that
+#define OCS_SUCCESS_STATUS_CODE_V2 200
 
 namespace OCC {
 
diff --git a/src/gui/servernotificationhandler.cpp b/src/gui/servernotificationhandler.cpp
index bd91e8a..27d4d43 100644
--- a/src/gui/servernotificationhandler.cpp
+++ b/src/gui/servernotificationhandler.cpp
@@ -21,6 +21,8 @@
 namespace OCC
 {
 
+const QString notificationsPath = QLatin1String("ocs/v2.php/apps/notifications/api/v1/notifications");
+
 ServerNotificationHandler::ServerNotificationHandler(QObject *parent)
     : QObject(parent)
 {
@@ -47,7 +49,7 @@ void ServerNotificationHandler::slotFetchNotifications(AccountState *ptr)
     }
 
     // if the previous notification job has finished, start next.
-    _notificationJob = new JsonApiJob( ptr->account(), QLatin1String("ocs/v2.php/apps/notifications/api/v1/notifications"), this );
+    _notificationJob = new JsonApiJob( ptr->account(), notificationsPath, this );
     QObject::connect(_notificationJob.data(), SIGNAL(jsonReceived(QVariantMap, int)),
                      this, SLOT(slotNotificationsReceived(QVariantMap, int)));
     _notificationJob->setProperty("AccountStatePtr", QVariant::fromValue<AccountState*>(ptr));
@@ -94,6 +96,16 @@ void ServerNotificationHandler::slotNotificationsReceived(const QVariantMap& jso
 
             a._links.append(al);
         }
+
+        // Add another action to dismiss notification on server
+        // https://github.com/owncloud/notifications/blob/master/docs/ocs-endpoint-v1.md#deleting-a-notification-for-a-user
+        ActivityLink al;
+        al._label = tr("Dismiss");
+        al._link  = Utility::concatUrlPath(ai->account()->url(), notificationsPath + "/" + json.value("notification_id").toString()).toString();
+        al._verb  = "DELETE";
+        al._isPrimary = false;
+        a._links.append(al);
+
         list.append(a);
     }
     emit newNotificationList( list );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list