✨ Notifying
This commit is contained in:
@ -10,7 +10,7 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func NotifyAccount(user models.Account, subject, content string, links ...*proto.NotifyLink) error {
|
||||
func NotifyAccount(user models.Account, subject, content string, realtime bool, links ...*proto.NotifyLink) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
|
||||
@ -21,6 +21,7 @@ func NotifyAccount(user models.Account, subject, content string, links ...*proto
|
||||
Content: content,
|
||||
Links: links,
|
||||
RecipientId: uint64(user.ID),
|
||||
IsRealtime: realtime,
|
||||
IsImportant: false,
|
||||
})
|
||||
|
||||
|
@ -75,8 +75,9 @@ func NewMessage(message models.Message) (models.Message, error) {
|
||||
return message, err
|
||||
} else if err = database.C.Where(models.ChannelMember{
|
||||
ChannelID: message.ChannelID,
|
||||
}).Find(&members).Error; err == nil {
|
||||
}).Preload("Account").Find(&members).Error; err == nil {
|
||||
for _, member := range members {
|
||||
_ = NotifyAccount(member.Account, "New message at "+message.Channel.Name, message.Content, true)
|
||||
message, _ = GetMessage(message.Channel, message.ID)
|
||||
PushCommand(member.AccountID, models.UnifiedCommand{
|
||||
Action: "messages.new",
|
||||
|
Reference in New Issue
Block a user