Skip to content

Commit 222b771

Browse files
committed
Fix ack
1 parent 66c28b0 commit 222b771

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/MattermostMessenger/Controller/MattermostChatController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,12 @@ public function isAckAction()
281281
$json = array();
282282
$postId = $this->params()->fromQuery('postid', null);
283283
$myReactions = $this->mattermost->getMyReactions($postId);
284-
$ok = array_filter($myReactions, function($v){
285-
return strcmp($v['emoji_name'], 'ok') == 0;
286-
});
284+
$ok = array();
285+
if($myReactions !== null) {
286+
$ok = array_filter($myReactions, function ($v) {
287+
return strcmp($v['emoji_name'], 'ok') == 0;
288+
});
289+
}
287290
$json['ack'] = count($ok) == 1;
288291
return new JsonModel($json);
289292
}

src/MattermostMessenger/Service/MattermostService.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,13 @@ public function getMyReactions($postId)
317317
$result = $this->getClient()->getPostModel()->getReactions($postId);
318318
if($result->getStatusCode() == 200) {
319319
$reactions = json_decode($result->getBody(), true);
320-
$myReactions = array_filter($reactions, function($v){
321-
return strcmp($v['user_id'], $this->getMyId()) == 0;
322-
});
320+
if($reactions !== null) {
321+
$myReactions = array_filter($reactions, function($v){
322+
return strcmp($v['user_id'], $this->getMyId()) == 0;
323+
});
324+
} else {
325+
return null;
326+
}
323327
return $myReactions;
324328
} else {
325329
error_log(print_r(json_decode($result->getBody()), true));

0 commit comments

Comments
 (0)