🐛 Fix almost everywhere mis-used AccountID as ExternalID
This commit is contained in:
parent
ea94fd7b54
commit
b9a5bdb069
@ -113,7 +113,7 @@ func NewCall(channel models.Channel, founder models.ChannelMember) (models.Call,
|
|||||||
if member.ID != call.Founder.ID {
|
if member.ID != call.Founder.ID {
|
||||||
pendingUsers = append(pendingUsers, member.Account)
|
pendingUsers = append(pendingUsers, member.Account)
|
||||||
}
|
}
|
||||||
PushCommand(member.AccountID, models.UnifiedCommand{
|
PushCommand(member.Account.ExternalID, models.UnifiedCommand{
|
||||||
Action: "calls.new",
|
Action: "calls.new",
|
||||||
Payload: call,
|
Payload: call,
|
||||||
})
|
})
|
||||||
@ -163,7 +163,7 @@ func EndCall(call models.Call) (models.Call, error) {
|
|||||||
}).Preload("Account").Find(&members).Error; err == nil {
|
}).Preload("Account").Find(&members).Error; err == nil {
|
||||||
call, _ = GetCall(call.Channel, call.ID)
|
call, _ = GetCall(call.Channel, call.ID)
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
PushCommand(member.AccountID, models.UnifiedCommand{
|
PushCommand(member.Account.ExternalID, models.UnifiedCommand{
|
||||||
Action: "calls.end",
|
Action: "calls.end",
|
||||||
Payload: call,
|
Payload: call,
|
||||||
})
|
})
|
||||||
|
@ -85,7 +85,7 @@ func NewEvent(event models.Event) (models.Event, error) {
|
|||||||
|
|
||||||
event, _ = GetEvent(event.Channel, event.ID)
|
event, _ = GetEvent(event.Channel, event.ID)
|
||||||
idxList := lo.Map(members, func(item models.ChannelMember, index int) uint64 {
|
idxList := lo.Map(members, func(item models.ChannelMember, index int) uint64 {
|
||||||
return uint64(item.AccountID)
|
return uint64(item.Account.ExternalID)
|
||||||
})
|
})
|
||||||
PushCommandBatch(idxList, models.UnifiedCommand{
|
PushCommandBatch(idxList, models.UnifiedCommand{
|
||||||
Action: "events.new",
|
Action: "events.new",
|
||||||
@ -106,7 +106,7 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
|
|||||||
_ = jsoniter.Unmarshal(raw, &body)
|
_ = jsoniter.Unmarshal(raw, &body)
|
||||||
|
|
||||||
var pendingUsers []models.Account
|
var pendingUsers []models.Account
|
||||||
var metionedUsers []models.Account
|
var mentionedUsers []models.Account
|
||||||
|
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
if member.ID != event.SenderID {
|
if member.ID != event.SenderID {
|
||||||
@ -115,7 +115,7 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
|
|||||||
continue
|
continue
|
||||||
case models.NotifyLevelMentioned:
|
case models.NotifyLevelMentioned:
|
||||||
if len(body.RelatedUsers) != 0 && lo.Contains(body.RelatedUsers, member.Account.ExternalID) {
|
if len(body.RelatedUsers) != 0 && lo.Contains(body.RelatedUsers, member.Account.ExternalID) {
|
||||||
metionedUsers = append(metionedUsers, member.Account)
|
mentionedUsers = append(mentionedUsers, member.Account)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
default:
|
default:
|
||||||
@ -123,7 +123,7 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if lo.Contains(body.RelatedUsers, member.Account.ExternalID) {
|
if lo.Contains(body.RelatedUsers, member.Account.ExternalID) {
|
||||||
metionedUsers = append(metionedUsers, member.Account)
|
mentionedUsers = append(mentionedUsers, member.Account)
|
||||||
} else {
|
} else {
|
||||||
pendingUsers = append(pendingUsers, member.Account)
|
pendingUsers = append(pendingUsers, member.Account)
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(metionedUsers) > 0 {
|
if len(mentionedUsers) > 0 {
|
||||||
if displaySubtitle != nil && len(*displaySubtitle) > 0 {
|
if displaySubtitle != nil && len(*displaySubtitle) > 0 {
|
||||||
*displaySubtitle += ", and metioned you"
|
*displaySubtitle += ", and metioned you"
|
||||||
} else {
|
} else {
|
||||||
@ -192,7 +192,7 @@ func NotifyMessageEvent(members []models.ChannelMember, event models.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := NotifyAccountMessagerBatch(
|
err := NotifyAccountMessagerBatch(
|
||||||
metionedUsers,
|
mentionedUsers,
|
||||||
&proto.NotifyRequest{
|
&proto.NotifyRequest{
|
||||||
Topic: "messaging.message",
|
Topic: "messaging.message",
|
||||||
Title: fmt.Sprintf("%s (%s)", event.Sender.Account.Nick, event.Channel.DisplayText()),
|
Title: fmt.Sprintf("%s (%s)", event.Sender.Account.Nick, event.Channel.DisplayText()),
|
||||||
|
Loading…
Reference in New Issue
Block a user