]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
remove string-checks from code using Notice::saveNew()
authorEvan Prodromou <evan@status.net>
Tue, 29 Sep 2009 21:25:52 +0000 (17:25 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 29 Sep 2009 21:25:52 +0000 (17:25 -0400)
actions/newnotice.php
actions/twitapistatuses.php
lib/facebookaction.php
lib/oauthstore.php
scripts/maildaemon.php
scripts/xmppdaemon.php

index 23ec2a1b5827c3aca92ecb4f20d36c7e6da10718..d5b0332f4878bd58984b0425614a802beb0d04f6 100644 (file)
@@ -255,13 +255,6 @@ class NewnoticeAction extends Action
         $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
                                   ($replyto == 'false') ? null : $replyto);
 
-        if (is_string($notice)) {
-            if (isset($filename)) {
-                $this->deleteFile($filename);
-            }
-            $this->clientError($notice);
-        }
-
         if (isset($mimetype)) {
             $this->attachFile($notice, $fileRecord);
         }
index 2f10ff966c8113a34477e4b7e2832945f447b385..87043b1821cb47672af710706b63c901014cd9bc 100644 (file)
@@ -297,11 +297,6 @@ class TwitapistatusesAction extends TwitterapiAction
                 html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'),
                     $source, 1, $reply_to);
 
-            if (is_string($notice)) {
-                $this->serverError($notice);
-                return;
-            }
-
             common_broadcast_notice($notice);
             $apidata['api_arg'] = $notice->id;
         }
index 411f795945a7de10737cbb3eab89a0dce2e5af41..3f3a8d3b094b44cde2f94385d60247e49257eef1 100644 (file)
@@ -468,11 +468,11 @@ class FacebookAction extends Action
 
         $replyto = $this->trimmed('inreplyto');
 
-        $notice = Notice::saveNew($user->id, $content,
-            'web', 1, ($replyto == 'false') ? null : $replyto);
-
-        if (is_string($notice)) {
-            $this->showPage($notice);
+        try {
+            $notice = Notice::saveNew($user->id, $content,
+                                      'web', 1, ($replyto == 'false') ? null : $replyto);
+        } catch (Exception $e) {
+            $this->showPage($e->getMessage());
             return;
         }
 
index e69a00f55f2ab61e588a763e882e926d2c962c06..d617a7df7e6216f52d72d0beec8892487256f94b 100644 (file)
@@ -156,7 +156,6 @@ class StatusNetOAuthDataStore extends OAuthDataStore
         return $this->new_access_token($consumer);
     }
 
-
     /**
      * Revoke specified OAuth token
      *
@@ -363,9 +362,7 @@ class StatusNetOAuthDataStore extends OAuthDataStore
                                   false,
                                   null,
                                   $omb_notice->getIdentifierURI());
-        if (is_string($notice)) {
-            throw new Exception($notice);
-        }
+
         common_broadcast_notice($notice, true);
     }
 
index 5705cfd50e300fcf095d5cb55cc281bb957bc707..586bef624ea154d2a53d60c7a71d7313cd18bf83 100755 (executable)
@@ -260,10 +260,11 @@ class MailerDaemon
 
     function add_notice($user, $msg, $fileRecords)
     {
-        $notice = Notice::saveNew($user->id, $msg, 'mail');
-        if (is_string($notice)) {
-            $this->log(LOG_ERR, $notice);
-            return $notice;
+        try {
+            $notice = Notice::saveNew($user->id, $msg, 'mail');
+        } catch (Exception $e) {
+            $this->log(LOG_ERR, $e->getMessage());
+            return $e->getMessage();
         }
         foreach($fileRecords as $fileRecord){
             $this->attachFile($notice, $fileRecord);
index 1b1aec3e6eded1030b368ddff41a6c5bddf3bb95..b2efc07c38c644092b4a1549761efb01af99c330 100755 (executable)
@@ -323,12 +323,15 @@ class XMPPDaemon extends Daemon
                                           mb_strlen($content_shortened)));
           return;
         }
-        $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp');
-        if (is_string($notice)) {
-            $this->log(LOG_ERR, $notice);
-            $this->from_site($user->jabber, $notice);
+
+        try {
+            $notice = Notice::saveNew($user->id, $content_shortened, 'xmpp');
+        } catch (Exception $e) {
+            $this->log(LOG_ERR, $e->getMessage());
+            $this->from_site($user->jabber, $e->getMessage());
             return;
         }
+
         common_broadcast_notice($notice);
         $this->log(LOG_INFO,
                    'Added notice ' . $notice->id . ' from user ' . $user->nickname);