Просмотр исходного кода

Ticket #4148 - Build-in API support: Share feature in Feed.

AntonLV 3 лет назад
Родитель
Сommit
fe58c8cc37

+ 23 - 0
modules/boonex/timeline/classes/BxTimelineMenuItemShare.php

@@ -124,7 +124,30 @@ class BxTimelineMenuItemShare extends BxTemplMenu
             foreach($aItems as $aItem)
                 switch($aItem['name']) {
                     case 'item-repost':
+                        $iOwnerId = $this->_oModule->getUserId();
+                        $sType = $this->_aEvent['type'];
+                        $sAction = $this->_aEvent['action'];
+                        $iObjectId = 0;
+
+                        $sCommonPrefix = $this->_oModule->_oConfig->getPrefix('common_post');
+                        if(str_replace($sCommonPrefix, '', $sType) == BX_TIMELINE_PARSE_TYPE_REPOST) {
+                            $aRepostedData = unserialize($this->_aEvent['content']);
+
+                            $sType = $aRepostedData['type'];
+                            $sAction = $aRepostedData['action'];
+                            $iObjectId = $aRepostedData['object_id'];
+                        }
+                        else
+                            $iObjectId = $this->_oModule->_oConfig->isSystem($sType, $sAction) ? $this->_aEvent['object_id'] : $this->_aEvent['id'];
+
                         $aItemsApi['item-repost'] = array_merge($aItem, [
+                            'data' => [
+                                'author_id' => $iOwnerId,
+                                'owner_id' => $iOwnerId,
+                                'type' => $sType,
+                                'action' => $sAction,
+                                'object_id' => $iObjectId
+                            ]
                         ]);
                         break;
 

+ 8 - 2
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -905,7 +905,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             'GetBlockViewHotOutline' => '',
             'GetBlockViewAccount' => '',
             'GetBlockViewAccountOutline' => '',
-            'GetPosts' => ''
+            'GetPosts' => '',
+            'Repost' => ''
         ));
     }
 
@@ -2827,10 +2828,15 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
      */
     /** 
      * @ref bx_timeline-repost "repost"
+     * @api @ref bx_timeline-repost "repost"
      */
     public function serviceRepost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, $bForce = false)
     {
-        return $this->repost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, false, $bForce);
+        $mixedResult = $this->repost($iAuthorId, $iOwnerId, $sType, $sAction, $iObjectId, false, $bForce);
+        if(bx_is_api() && !is_array($mixedResult))
+            $mixedResult = ['code' => 0, 'id' => $mixedResult];
+
+        return $mixedResult;
     }
     
     /**