浏览代码

Merge pull request #2253 from pixelfed/staging

Add status ancestor and descendant context
daniel 5 年之前
父节点
当前提交
9bf4917fd3
共有 4 个文件被更改,包括 42 次插入36 次删除
  1. 0 31
      .dependabot/config.yml
  2. 18 0
      .github/dependabot.yml
  3. 1 0
      CHANGELOG.md
  4. 23 5
      app/Http/Controllers/Api/ApiV1Controller.php

+ 0 - 31
.dependabot/config.yml

@@ -1,31 +0,0 @@
-version: 1
-
-update_configs:
-  - package_manager: "php:composer"
-    directory: "/"
-    update_schedule: "daily"
-    # Supported update schedule: live daily weekly monthly
-    target_branch: "staging"
-    version_requirement_updates: "auto"
-    # Supported version requirements: auto widen_ranges increase_versions increase_versions_if_necessary
-    allowed_updates:
-      - match:
-          dependency_type: "all"
-          # Supported dependency types: all indirect direct production development
-          update_type: "all"
-          # Supported update types: all security
-
-  - package_manager: "javascript"
-    directory: "/"
-    update_schedule: "daily"
-    # Supported update schedule: live daily weekly monthly
-    target_branch: "staging"
-    version_requirement_updates: "auto"
-    # Supported version requirements: auto widen_ranges increase_versions increase_versions_if_necessary
-    allowed_updates:
-      - match:
-          dependency_type: "all"
-          # Supported dependency types: all indirect direct production development
-          update_type: "all"
-          # Supported update types: all security
-    

+ 18 - 0
.github/dependabot.yml

@@ -0,0 +1,18 @@
+version: 2
+updates:
+- package-ecosystem: composer
+  directory: "/"
+  schedule:
+    interval: daily
+  open-pull-requests-limit: 99
+  target-branch: staging
+  allow:
+  - dependency-type: all
+- package-ecosystem: npm
+  directory: "/"
+  schedule:
+    interval: daily
+  open-pull-requests-limit: 99
+  target-branch: staging
+  allow:
+  - dependency-type: all

+ 1 - 0
CHANGELOG.md

@@ -50,6 +50,7 @@
 - Updated AP Helpers, update bio + name ([4bee8397](https://github.com/pixelfed/pixelfed/commit/4bee8397))
 - Updated AP Helpers, update bio + name ([4bee8397](https://github.com/pixelfed/pixelfed/commit/4bee8397))
 - Updated Profile component, add bookmark loader ([c8d5edc9](https://github.com/pixelfed/pixelfed/commit/c8d5edc9))
 - Updated Profile component, add bookmark loader ([c8d5edc9](https://github.com/pixelfed/pixelfed/commit/c8d5edc9))
 - Updated PostComponent, add recent posts ([b289f2f6](https://github.com/pixelfed/pixelfed/commit/b289f2f6))
 - Updated PostComponent, add recent posts ([b289f2f6](https://github.com/pixelfed/pixelfed/commit/b289f2f6))
+- Updated ApiV1Controller, add status ancestor and descendant context ([a0bde855](https://github.com/pixelfed/pixelfed/commit/a0bde855))
 
 
 
 
 ## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)
 ## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)

+ 23 - 5
app/Http/Controllers/Api/ApiV1Controller.php

@@ -1525,11 +1525,29 @@ class ApiV1Controller extends Controller
             }
             }
         }
         }
 
 
-        // Return empty response since we don't handle threading like this
-        $res = [
-            'ancestors' => [],
-            'descendants' => []
-        ];
+        if($status->comments_disabled) {
+            $res = [
+                'ancestors' => [],
+                'descendants' => []
+            ];
+        } else {
+            $ancestors = $status->parent();
+            if($ancestors) {
+                $ares = new Fractal\Resource\Item($ancestors, new StatusTransformer());
+                $ancestors = [
+                    $this->fractal->createData($ares)->toArray()
+                ];
+            } else {
+                $ancestors = [];
+            }
+            $descendants = Status::whereInReplyToId($id)->latest()->limit(20)->get();
+            $dres = new Fractal\Resource\Collection($descendants, new StatusTransformer());
+            $descendants = $this->fractal->createData($dres)->toArray();
+            $res = [
+                'ancestors' => $ancestors,
+                'descendants' => $descendants
+            ];
+        }
 
 
         return response()->json($res);
         return response()->json($res);
     }
     }