Messaging/pkg/internal/services/accounts.go

32 lines
794 B
Go
Raw Normal View History

2024-03-26 15:05:13 +00:00
package services
import (
"context"
2024-11-02 05:23:27 +00:00
"git.solsynth.dev/hypernet/nexus/pkg/nex"
authm "git.solsynth.dev/hypernet/passport/pkg/authkit/models"
"time"
"git.solsynth.dev/hydrogen/messaging/pkg/internal/gap"
2024-07-20 08:02:16 +00:00
"github.com/samber/lo"
2024-03-26 15:05:13 +00:00
2024-07-16 06:44:00 +00:00
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
2024-03-26 15:05:13 +00:00
)
2024-11-02 05:23:27 +00:00
func NotifyAccountMessagerBatch(users []authm.Account, notification *proto.NotifyRequest) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
2024-11-02 05:23:27 +00:00
pc, err := gap.Nx.GetClientGrpcConn(nex.ServiceTypeAuth)
if err != nil {
return err
}
_, err = proto.NewNotifierClient(pc).NotifyUserBatch(ctx, &proto.NotifyUserBatchRequest{
2024-11-02 05:23:27 +00:00
UserId: lo.Map(users, func(item authm.Account, idx int) uint64 {
return uint64(item.ID)
2024-07-20 08:02:16 +00:00
}),
Notify: notification,
2024-03-26 15:05:13 +00:00
})
return err
}