💄 Better notify
This commit is contained in:
parent
066fc78b84
commit
1b68faf8ba
@ -1,6 +1,7 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"git.solsynth.dev/hydrogen/messaging/pkg/database"
|
"git.solsynth.dev/hydrogen/messaging/pkg/database"
|
||||||
"git.solsynth.dev/hydrogen/messaging/pkg/models"
|
"git.solsynth.dev/hydrogen/messaging/pkg/models"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
@ -82,14 +83,17 @@ func NewMessage(message models.Message) (models.Message, error) {
|
|||||||
ChannelID: message.ChannelID,
|
ChannelID: message.ChannelID,
|
||||||
}).Preload("Account").Find(&members).Error; err == nil {
|
}).Preload("Account").Find(&members).Error; err == nil {
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
|
message, _ = GetMessage(message.Channel, message.ID)
|
||||||
if member.ID != message.Sender.ID {
|
if member.ID != message.Sender.ID {
|
||||||
err = NotifyAccount(member.Account, "New message at "+message.Channel.Name, message.Content, true)
|
err = NotifyAccount(member.Account,
|
||||||
|
fmt.Sprintf("New Message #%s", message.Channel.Alias),
|
||||||
|
fmt.Sprintf("%s: %s", message.Sender.Account.Name, message.Content),
|
||||||
|
true,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("An error occurred when trying notify user.")
|
log.Warn().Err(err).Msg("An error occurred when trying notify user.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message, _ = GetMessage(message.Channel, message.ID)
|
|
||||||
PushCommand(member.AccountID, models.UnifiedCommand{
|
PushCommand(member.AccountID, models.UnifiedCommand{
|
||||||
Action: "messages.new",
|
Action: "messages.new",
|
||||||
Payload: message,
|
Payload: message,
|
||||||
|
Loading…
Reference in New Issue
Block a user