PLT-2990 Clicking on a desktop notification from another team opens the team (#3253)
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
6ab893dcba
Коммит
6cee1f87f2
@@ -473,6 +473,7 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
|
|||||||
message := model.NewMessage(c.TeamId, post.ChannelId, post.UserId, model.ACTION_POSTED)
|
message := model.NewMessage(c.TeamId, post.ChannelId, post.UserId, model.ACTION_POSTED)
|
||||||
message.Add("post", post.ToJson())
|
message.Add("post", post.ToJson())
|
||||||
message.Add("channel_type", channel.Type)
|
message.Add("channel_type", channel.Type)
|
||||||
|
message.Add("team_id", team.Id)
|
||||||
|
|
||||||
if len(post.Filenames) != 0 {
|
if len(post.Filenames) != 0 {
|
||||||
message.Add("otherFile", "true")
|
message.Add("otherFile", "true")
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class NotificationStoreClass extends EventEmitter {
|
|||||||
if (msgProps.mentions) {
|
if (msgProps.mentions) {
|
||||||
mentions = JSON.parse(msgProps.mentions);
|
mentions = JSON.parse(msgProps.mentions);
|
||||||
}
|
}
|
||||||
|
const teamId = msgProps.team_id;
|
||||||
|
|
||||||
const channel = ChannelStore.get(post.channel_id);
|
const channel = ChannelStore.get(post.channel_id);
|
||||||
const user = UserStore.getCurrentUser();
|
const user = UserStore.getCurrentUser();
|
||||||
@@ -67,14 +68,14 @@ class NotificationStoreClass extends EventEmitter {
|
|||||||
|
|
||||||
if (notifyText.length === 0) {
|
if (notifyText.length === 0) {
|
||||||
if (msgProps.image) {
|
if (msgProps.image) {
|
||||||
Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedImage', ' uploaded an image'), channel);
|
Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedImage', ' uploaded an image'), channel, teamId);
|
||||||
} else if (msgProps.otherFile) {
|
} else if (msgProps.otherFile) {
|
||||||
Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedFile', ' uploaded a file'), channel);
|
Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedFile', ' uploaded a file'), channel, teamId);
|
||||||
} else {
|
} else {
|
||||||
Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.something', ' did something new'), channel);
|
Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.something', ' did something new'), channel, teamId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.wrote', ' wrote: ') + notifyText, channel);
|
Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.wrote', ' wrote: ') + notifyText, channel, teamId);
|
||||||
}
|
}
|
||||||
if (!user.notify_props || user.notify_props.desktop_sound === 'true') {
|
if (!user.notify_props || user.notify_props.desktop_sound === 'true') {
|
||||||
Utils.ding();
|
Utils.ding();
|
||||||
|
|||||||
@@ -109,6 +109,15 @@ class TeamStoreClass extends EventEmitter {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTeamUrl(id) {
|
||||||
|
const team = this.get(id);
|
||||||
|
if (team) {
|
||||||
|
return getWindowLocationOrigin() + '/' + team.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
saveTeam(team) {
|
saveTeam(team) {
|
||||||
this.teams[team.id] = team;
|
this.teams[team.id] = team;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export function getCookie(name) {
|
|||||||
|
|
||||||
var requestedNotificationPermission = false;
|
var requestedNotificationPermission = false;
|
||||||
|
|
||||||
export function notifyMe(title, body, channel) {
|
export function notifyMe(title, body, channel, teamId) {
|
||||||
if (!('Notification' in window)) {
|
if (!('Notification' in window)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,9 @@ export function notifyMe(title, body, channel) {
|
|||||||
notification.onclick = () => {
|
notification.onclick = () => {
|
||||||
window.focus();
|
window.focus();
|
||||||
if (channel) {
|
if (channel) {
|
||||||
browserHistory.push(getTeamURLNoOriginFromAddressBar() + '/channels/' + channel.name);
|
browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/' + channel.name);
|
||||||
|
} else if (teamId) {
|
||||||
|
browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/town-square');
|
||||||
} else {
|
} else {
|
||||||
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square');
|
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square');
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user