✨ Support localized notification
This commit is contained in:
parent
4fa155cafb
commit
09dddf7721
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.23.2
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
git.solsynth.dev/hypernet/nexus v0.0.0-20250216103838-15c39609b897
|
git.solsynth.dev/hypernet/nexus v0.0.0-20250216103838-15c39609b897
|
||||||
git.solsynth.dev/hypernet/pusher v0.0.0-20241228030233-50ff8304e465
|
git.solsynth.dev/hypernet/pusher v0.0.0-20250216145944-5fb769823a88
|
||||||
git.solsynth.dev/hypernet/wallet v0.0.0-20250129150034-87b94cdb5488
|
git.solsynth.dev/hypernet/wallet v0.0.0-20250129150034-87b94cdb5488
|
||||||
github.com/dgraph-io/ristretto v0.2.0
|
github.com/dgraph-io/ristretto v0.2.0
|
||||||
github.com/eko/gocache/lib/v4 v4.1.6
|
github.com/eko/gocache/lib/v4 v4.1.6
|
||||||
|
2
go.sum
2
go.sum
@ -41,6 +41,8 @@ git.solsynth.dev/hypernet/nexus v0.0.0-20250216103838-15c39609b897 h1:AmLZ/r70e2
|
|||||||
git.solsynth.dev/hypernet/nexus v0.0.0-20250216103838-15c39609b897/go.mod h1:v+rpf1ZDRi8moaThTAkj5DMQU+rw96YTHcN8/7n/p2Y=
|
git.solsynth.dev/hypernet/nexus v0.0.0-20250216103838-15c39609b897/go.mod h1:v+rpf1ZDRi8moaThTAkj5DMQU+rw96YTHcN8/7n/p2Y=
|
||||||
git.solsynth.dev/hypernet/pusher v0.0.0-20241228030233-50ff8304e465 h1:KFtv9lF0JMUGsq1uHwQvop8PTyqdiLuUQuRrd5WmzPk=
|
git.solsynth.dev/hypernet/pusher v0.0.0-20241228030233-50ff8304e465 h1:KFtv9lF0JMUGsq1uHwQvop8PTyqdiLuUQuRrd5WmzPk=
|
||||||
git.solsynth.dev/hypernet/pusher v0.0.0-20241228030233-50ff8304e465/go.mod h1:XHTqFU/vBe4JiuAjl87GUcL8+w/IizSNoqH6n3WkQFc=
|
git.solsynth.dev/hypernet/pusher v0.0.0-20241228030233-50ff8304e465/go.mod h1:XHTqFU/vBe4JiuAjl87GUcL8+w/IizSNoqH6n3WkQFc=
|
||||||
|
git.solsynth.dev/hypernet/pusher v0.0.0-20250216145944-5fb769823a88 h1:2HEENe9KUrdaJeNBzx9lsuXQGyzWqCgnLTKQnr8xFr8=
|
||||||
|
git.solsynth.dev/hypernet/pusher v0.0.0-20250216145944-5fb769823a88/go.mod h1:ildzMtLagNsLK0Rkw4Hgk2TrrwqZnjwJIUx0MNZwcDY=
|
||||||
git.solsynth.dev/hypernet/wallet v0.0.0-20250129150034-87b94cdb5488 h1:/9Ol+PfDQFAYtHo0kk6sxqiEsZ6epb6yUEsZJxy14Mk=
|
git.solsynth.dev/hypernet/wallet v0.0.0-20250129150034-87b94cdb5488 h1:/9Ol+PfDQFAYtHo0kk6sxqiEsZ6epb6yUEsZJxy14Mk=
|
||||||
git.solsynth.dev/hypernet/wallet v0.0.0-20250129150034-87b94cdb5488/go.mod h1:jd1MTBI5NPHne22nq7nR7kyl4iYb9kV2A+tpXi7HOYY=
|
git.solsynth.dev/hypernet/wallet v0.0.0-20250129150034-87b94cdb5488/go.mod h1:jd1MTBI5NPHne22nq7nR7kyl4iYb9kV2A+tpXi7HOYY=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
"git.solsynth.dev/hypernet/pusher/pkg/pushkit"
|
||||||
"gorm.io/datatypes"
|
"gorm.io/datatypes"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Notification struct {
|
type Notification struct {
|
||||||
|
@ -133,6 +133,9 @@ func PushNotification(notification models.Notification, skipNotifiableCheck ...b
|
|||||||
log.Debug().Str("topic", notification.Topic).Any("uid", notification.AccountID).Msg("Pushing notify to user...")
|
log.Debug().Str("topic", notification.Topic).Any("uid", notification.AccountID).Msg("Pushing notify to user...")
|
||||||
|
|
||||||
err = gap.Px.PushNotifyBatch(pushkit.NotificationPushBatchRequest{
|
err = gap.Px.PushNotifyBatch(pushkit.NotificationPushBatchRequest{
|
||||||
|
Lang: lo.Map(subscribers, func(item models.NotificationSubscriber, index int) string {
|
||||||
|
return notification.Account.Language
|
||||||
|
}),
|
||||||
Providers: providers,
|
Providers: providers,
|
||||||
Tokens: tokens,
|
Tokens: tokens,
|
||||||
Notification: notification.EncodeToPushkit(),
|
Notification: notification.EncodeToPushkit(),
|
||||||
@ -213,6 +216,14 @@ func PushNotificationBatch(notifications []models.Notification, skipNotifiableCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := gap.Px.PushNotifyBatch(pushkit.NotificationPushBatchRequest{
|
if err := gap.Px.PushNotifyBatch(pushkit.NotificationPushBatchRequest{
|
||||||
|
Lang: lo.Map(subscribers, func(item models.NotificationSubscriber, index int) string {
|
||||||
|
for idx := 0; idx < len(notifications); idx++ {
|
||||||
|
if item.AccountID == notifications[idx].AccountID {
|
||||||
|
return notifications[idx].Account.Language
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "en-US"
|
||||||
|
}),
|
||||||
Providers: providers,
|
Providers: providers,
|
||||||
Tokens: tokens,
|
Tokens: tokens,
|
||||||
Notification: notifications[0].EncodeToPushkit(),
|
Notification: notifications[0].EncodeToPushkit(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user