Skip to content

Commit

Permalink
refs #12 use permalinks to posts in search results and dashboard, fix…
Browse files Browse the repository at this point in the history
… dashboard item subtext for direct messages

Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Nov 10, 2022
1 parent a3e03b3 commit 96b335b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/Search/MattermostSearchMessagesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,18 @@ protected function getFormattedDate(int $timestamp): string {
* @return string
*/
protected function getLinkToMattermost(array $entry, string $url): string {
/*
if ($entry['channel_type'] === 'D') {
// in a direct conversation
return $url . '/' . $entry['team_name'] . '/messages/@' . $entry['direct_message_user_name'];
}
return $url . '/' . $entry['team_name'] . '/channels/' . $entry['channel_name'];
*/
// in a channel
// return $url . '/' . $entry['team_name'] . '/channels/' . $entry['channel_name'];

// most generic way: permalinks
// https://mm.org/teamID/pl/postID
return $url . '/' . $entry['team_name'] . '/pl/' . $entry['id'];
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default {
})
},
getNotificationTarget(n) {
return this.mattermostUrl + '/' + n.team_name + '/channels/' + n.channel_name
return this.mattermostUrl + '/' + n.team_name + '/pl/' + n.id
},
getUniqueKey(n) {
return n.id + ':' + n.create_at
Expand All @@ -241,6 +241,9 @@ export default {
return imagePath('integration_mattermost', 'mention.svg')
},
getSubline(n) {
if (n.channel_type === 'D') {
return t('integration_mattermost', '{name} in @{direct_username} at {date}', { name: n.user_name, direct_username: n.direct_message_user_name, date: this.getFormattedDate(n) })
}
return t('integration_mattermost', '{name} in #{channel} at {date}', { name: n.user_name, channel: n.channel_name, date: this.getFormattedDate(n) })
},
getTargetTitle(n) {
Expand Down

0 comments on commit 96b335b

Please sign in to comment.