✨ Notifying
This commit is contained in:
parent
3956547619
commit
9c7d0a167d
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module git.solsynth.dev/hydrogen/messaging
|
||||
go 1.21.6
|
||||
|
||||
require (
|
||||
git.solsynth.dev/hydrogen/identity v0.0.0-20240320131628-6ac77f36957f
|
||||
git.solsynth.dev/hydrogen/identity v0.0.0-20240331080359-e8aac7bb6627
|
||||
github.com/go-playground/validator/v10 v10.17.0
|
||||
github.com/gofiber/fiber/v2 v2.52.4
|
||||
github.com/gofiber/template/html/v2 v2.1.1
|
||||
|
2
go.sum
2
go.sum
@ -1,5 +1,7 @@
|
||||
git.solsynth.dev/hydrogen/identity v0.0.0-20240320131628-6ac77f36957f h1:6vRGU5bSb7Za6HUhpX1bYMsKElRbUyL/qB5fAs5IDE0=
|
||||
git.solsynth.dev/hydrogen/identity v0.0.0-20240320131628-6ac77f36957f/go.mod h1:rmh5biOQLvoIE2iRFbOfD0TITMP1orYpqzhUw50Z4ck=
|
||||
git.solsynth.dev/hydrogen/identity v0.0.0-20240331080359-e8aac7bb6627 h1:BUhDqy/Whw1yVbDpmGk7clzRAC1jo+AOsCwuwhCVwkg=
|
||||
git.solsynth.dev/hydrogen/identity v0.0.0-20240331080359-e8aac7bb6627/go.mod h1:GxcduEpQWQ2mO37A9uRtseS680uMLi957GDywRBAJHg=
|
||||
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs=
|
||||
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user