Skip to content

Commit 96b335b

Browse files
committed
refs #12 use permalinks to posts in search results and dashboard, fix dashboard item subtext for direct messages
Signed-off-by: Julien Veyssier <[email protected]>
1 parent a3e03b3 commit 96b335b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/Search/MattermostSearchMessagesProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,18 @@ protected function getFormattedDate(int $timestamp): string {
189189
* @return string
190190
*/
191191
protected function getLinkToMattermost(array $entry, string $url): string {
192+
/*
192193
if ($entry['channel_type'] === 'D') {
194+
// in a direct conversation
193195
return $url . '/' . $entry['team_name'] . '/messages/@' . $entry['direct_message_user_name'];
194196
}
195-
return $url . '/' . $entry['team_name'] . '/channels/' . $entry['channel_name'];
197+
*/
198+
// in a channel
199+
// return $url . '/' . $entry['team_name'] . '/channels/' . $entry['channel_name'];
200+
201+
// most generic way: permalinks
202+
// https://mm.org/teamID/pl/postID
203+
return $url . '/' . $entry['team_name'] . '/pl/' . $entry['id'];
196204
}
197205

198206
/**

src/views/Dashboard.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ export default {
224224
})
225225
},
226226
getNotificationTarget(n) {
227-
return this.mattermostUrl + '/' + n.team_name + '/channels/' + n.channel_name
227+
return this.mattermostUrl + '/' + n.team_name + '/pl/' + n.id
228228
},
229229
getUniqueKey(n) {
230230
return n.id + ':' + n.create_at
@@ -241,6 +241,9 @@ export default {
241241
return imagePath('integration_mattermost', 'mention.svg')
242242
},
243243
getSubline(n) {
244+
if (n.channel_type === 'D') {
245+
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) })
246+
}
244247
return t('integration_mattermost', '{name} in #{channel} at {date}', { name: n.user_name, channel: n.channel_name, date: this.getFormattedDate(n) })
245248
},
246249
getTargetTitle(n) {

0 commit comments

Comments
 (0)