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"
|
2024-07-17 06:10:04 +00:00
|
|
|
"time"
|
|
|
|
|
2024-11-02 05:24:37 +00:00
|
|
|
"git.solsynth.dev/hypernet/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 {
|
2024-07-17 06:10:04 +00:00
|
|
|
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)
|
2024-07-17 06:10:04 +00:00
|
|
|
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 {
|
2024-09-11 15:54:18 +00:00
|
|
|
return uint64(item.ID)
|
2024-07-20 08:02:16 +00:00
|
|
|
}),
|
|
|
|
Notify: notification,
|
2024-03-26 15:05:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|