Skip to content

Commit

Permalink
minimal support for channels method=tree
Browse files Browse the repository at this point in the history
  • Loading branch information
martymcguire committed Nov 4, 2023
1 parent c56e8e3 commit bb1ab6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion aperture/app/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function excluded_types() {
return $types;
}

public function to_array() {
public function to_array($include_sources = false) {
$array = [
'uid' => $this->uid,
'name' => $this->name,
Expand All @@ -49,6 +49,18 @@ public function to_array() {
if($this->default_destination) {
$array['destination'] = $this->default_destination;
}
if($include_sources) {
$sources = $this->sources()->get();
$array['sources'] = [];
foreach($sources as $source) {
$source_array = $source->to_array();

$array['sources'][] = array_merge([
'_id' => $source->id,
'url' => $source->url
], $source_array);
}
}
return $array;
}

Expand Down
3 changes: 2 additions & 1 deletion aperture/app/Http/Controllers/MicrosubController.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ public function post(Request $request) {
//////////////////////////////////////////////////////////////////////////////////

private function get_channels() {
$include_sources = (Request::input('method') == 'tree');
$channels = [];

foreach(Auth::user()->channels()->get() as $channel) {
$channels[] = $channel->to_array();
$channels[] = $channel->to_array($include_sources);
}

return [
Expand Down

0 comments on commit bb1ab6d

Please sign in to comment.