[gnome-software/wip/rancell/reviews] Simplify set_review_usefulness ()



commit 4ff9047ed15614adf482bff79de12f73bb223d85
Author: William Hua <william hua canonical com>
Date:   Thu Feb 11 16:32:43 2016 -0500

    Simplify set_review_usefulness ()

 src/plugins/gs-plugin-ubuntu-reviews.c |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/src/plugins/gs-plugin-ubuntu-reviews.c b/src/plugins/gs-plugin-ubuntu-reviews.c
index 3969d24..be5a9fa 100644
--- a/src/plugins/gs-plugin-ubuntu-reviews.c
+++ b/src/plugins/gs-plugin-ubuntu-reviews.c
@@ -964,22 +964,26 @@ set_review_usefulness (GsPlugin *plugin,
 {
        GsPluginPrivate *priv = plugin->priv;
        g_autofree gchar *uri;
-       g_autoptr(SoupMessage) msg;
        guint status_code;
 
-       /* Create message for reviews.ubuntu.com */
-       uri = g_strdup_printf ("%s/api/1.0/reviews/%s/recommendations/?useful=%s", UBUNTU_REVIEWS_SERVER, 
review_id, is_useful ? "True" : "False");
-       msg = soup_message_new (SOUP_METHOD_POST, uri);
-       sign_message (msg,
-                     OA_PLAINTEXT,
-                     priv->consumer_key,
-                     priv->consumer_secret,
-                     priv->token_key,
-                     priv->token_secret);
+       /* Send message to reviews server */
+       uri = g_strdup_printf ("/api/1.0/reviews/%s/recommendations/?useful=%s", review_id, is_useful ? 
"True" : "False");
+       send_signed_request (priv->session,
+                            UBUNTU_REVIEWS_SERVER,
+                            SOUP_METHOD_POST,
+                            uri,
+                            NULL,
+                            NULL,
+                            OA_PLAINTEXT,
+                            priv->consumer_key,
+                            priv->consumer_secret,
+                            priv->token_key,
+                            priv->token_secret,
+                            error);
 
-       /* Send to the server */
-       status_code = soup_session_send_message (priv->session, msg);
-       if (status_code != SOUP_STATUS_OK) {
+       if (error != NULL && *error != NULL) {
+               return FALSE;
+       } else if (status_code != SOUP_STATUS_OK) {
                g_set_error (error,
                             GS_PLUGIN_ERROR,
                             GS_PLUGIN_ERROR_FAILED,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]