perf: sync protocol and core hardening updates
This commit is contained in:
parent
152fed3b87
commit
4390ebf5a9
283 changed files with 29231 additions and 2295 deletions
39
internal/rpc/album_group.go
Normal file
39
internal/rpc/album_group.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"telesrv/internal/domain"
|
||||
)
|
||||
|
||||
func (r *Router) reserveAlbumGroup(ctx context.Context, userID int64, peer domain.Peer, items []domain.AlbumGroupReservationItem) (int64, error) {
|
||||
reservations, ok := r.deps.Messages.(AlbumGroupService)
|
||||
if !ok {
|
||||
r.log.Error("messages.sendMultiMedia album reservation capability missing",
|
||||
append(r.contextLogFields(ctx), zap.Int64("user_id", userID), zap.String("peer_type", string(peer.Type)), zap.Int64("peer_id", peer.ID))...)
|
||||
return 0, internalErr()
|
||||
}
|
||||
groupedID, err := reservations.ReserveAlbumGroup(ctx, userID, domain.AlbumGroupReservationRequest{
|
||||
SenderUserID: userID,
|
||||
Peer: peer,
|
||||
Items: items,
|
||||
ProposedGroupedID: randomNonZeroInt64(),
|
||||
})
|
||||
if errors.Is(err, domain.ErrMessageRandomIDDuplicate) {
|
||||
return 0, randomIDDuplicateErr()
|
||||
}
|
||||
if err != nil {
|
||||
r.log.Error("messages.sendMultiMedia album reservation failed",
|
||||
append(r.contextLogFields(ctx), zap.Error(err), zap.Int64("user_id", userID), zap.String("peer_type", string(peer.Type)), zap.Int64("peer_id", peer.ID), zap.Int("items", len(items)))...)
|
||||
return 0, internalErr()
|
||||
}
|
||||
if groupedID == 0 {
|
||||
r.log.Error("messages.sendMultiMedia album reservation returned zero grouped_id",
|
||||
append(r.contextLogFields(ctx), zap.Int64("user_id", userID), zap.String("peer_type", string(peer.Type)), zap.Int64("peer_id", peer.ID))...)
|
||||
return 0, internalErr()
|
||||
}
|
||||
return groupedID, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue