]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
fix scope for replies to group-private notices
authorEvan Prodromou <evan@status.net>
Tue, 5 Apr 2011 02:34:47 +0000 (22:34 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 5 Apr 2011 02:34:47 +0000 (22:34 -0400)
classes/Notice.php

index 835d9af53e85f0c1e9b7844ea78e47c6106bdb1b..a4f530c44facfe768ed9aec178a5a749d8249448 100644 (file)
@@ -342,6 +342,12 @@ class Notice extends Memcached_DataObject
         $notice->uri = $uri;
         $notice->url = $url;
 
+        // Get the groups here so we can figure out replies and such
+
+        if (!isset($groups)) {
+            $groups = self::groupsFromText($notice->content, $profile);
+        }
+
         $reply = null;
 
         // Handle repeat case
@@ -394,6 +400,20 @@ class Notice extends Memcached_DataObject
 
                 $notice->reply_to     = $reply->id;
                 $notice->conversation = $reply->conversation;
+
+                // If the original is private to a group, and notice has no group specified,
+                // make it to the same group(s)
+
+                if (empty($groups) && ($reply->scope | Notice::GROUP_SCOPE)) {
+                    $groups = array();
+                    $replyGroups = $reply->getGroups();
+                    foreach ($replyGroups as $group) {
+                        if ($profile->isMember($group)) {
+                            $groups[] = $group->id;
+                        }
+                    }
+                }
+
                 // Scope set below
             }
         }
@@ -444,10 +464,6 @@ class Notice extends Memcached_DataObject
 
         // Force the scope for private groups
 
-        if (!isset($groups)) {
-            $groups = self::groupsFromText($notice->content, $profile);
-        }
-
         foreach ($groups as $groupId) {
             $group = User_group::staticGet('id', $groupId);
             if (!empty($group)) {