]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apigroupleave.php
Consolidate common code in micro-apps custom notice type display actions.
[quix0rs-gnu-social.git] / actions / apigroupleave.php
index 0ceb3523c8483a95f6f45dc1a31a9a4a8d755175..35a4e04d78889358608f2111f79194729dd9016c 100644 (file)
@@ -116,22 +116,15 @@ class ApiGroupLeaveAction extends ApiAuthAction
             return;
         }
 
-        $result = $member->delete();
-
-        if (!$result) {
-            common_log_db_error($member, 'DELETE', __FILE__);
-            $this->serverError(
-                sprintf(
-                    // TRANS: Server error displayed when leaving a group fails.
-                    // TRANS: %1$s is a user nickname, $2$s is a group nickname.
-                    _('Could not remove user %1$s from group %2$s.'),
-                    $this->user->nickname,
-                    $this->group->nickname
-                )
-            );
+        try {
+            $this->user->leaveGroup($this->group);
+        } catch (Exception $e) {
+            // TRANS: Server error displayed when leaving a group failed in the database.
+            // TRANS: %1$s is the leaving user's nickname, $2$s is the group nickname for which the leave failed.
+            $this->serverError(sprintf(_('Could not remove user %1$s from group %2$s.'),
+                                       $cur->nickname, $this->group->nickname));
             return;
         }
-
         switch($this->format) {
         case 'xml':
             $this->showSingleXmlGroup($this->group);