Skip to content

Commit 8060251

Browse files
committed
fix test
1 parent c40b7c2 commit 8060251

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Ushahidi/Modules/V5/Http/Controllers/MessageController.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,24 @@ public function update(int $id, MessageRequest $request)
8787
return $this->show($id);
8888
}// end update
8989

90+
private function getPost(int $id, ?array $fields = null, ?array $haydrates = null)
91+
{
92+
if (!$fields) {
93+
$fields = Post::ALLOWED_FIELDS;
94+
}
95+
if (!$haydrates) {
96+
$haydrates = array_keys(Post::ALLOWED_RELATIONSHIPS);
97+
}
98+
$find_post_query = new FindPostByIdQuery($id);
99+
$find_post_query->addOnlyValues(
100+
$fields,
101+
$haydrates,
102+
Post::ALLOWED_RELATIONSHIPS,
103+
Post::REQUIRED_FIELDS
104+
);
105+
return $this->queryBus->handle($find_post_query);
106+
}
107+
90108
/**
91109
* Display the specified resource.
92110
*
@@ -99,7 +117,7 @@ public function showPost(int $id)
99117
$message = $this->queryBus->handle(new FetchMessageByIdQuery($id));
100118
$this->authorize('show', $message);
101119
if ($message->post_id) {
102-
$post = $this->queryBus->handle(new FindPostByIdQuery($message->post_id, Post::ALLOWED_FIELDS));
120+
$post = $this->getPost($message->post_id);
103121
return new postResource($post);
104122
}
105123
throw new NotFoundException("Post does not exist for this message");

0 commit comments

Comments
 (0)