diff --git a/client.go b/client.go index 10eda22..f67e8ae 100644 --- a/client.go +++ b/client.go @@ -120,7 +120,7 @@ func WithToken(ctx context.Context, token string) context.Context { func (c *LibrarianClient) RunBackgroundRefresh() { for { c.muToken.RLock() - resp, err := c.RefreshToken( + resp, err := c.RefreshToken( // nolint:typecheck // false positive WithToken(context.Background(), c.refreshToken), new(pb.RefreshTokenRequest), ) diff --git a/go.mod b/go.mod index d7cfad0..9ae3d80 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,8 @@ require ( github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20240627104009-3198e0b83bf2 github.com/go-kratos/kratos/v2 v2.7.3 github.com/hashicorp/consul/api v1.29.1 - github.com/tuihub/protos v0.4.14 - google.golang.org/grpc v1.64.0 + github.com/tuihub/protos v0.4.16 + google.golang.org/grpc v1.64.1 google.golang.org/protobuf v1.34.2 ) diff --git a/go.sum b/go.sum index 1d87f61..9eb508b 100644 --- a/go.sum +++ b/go.sum @@ -227,6 +227,8 @@ github.com/tuihub/protos v0.4.4 h1:C+iZHYVjyXVZvqVF9DqUNudsheLAEyhHRdA5gt43hJw= github.com/tuihub/protos v0.4.4/go.mod h1:FvaMeevw4RUzHy5kNgbCHWk3fH25ApXEaNmPvDhXozc= github.com/tuihub/protos v0.4.14 h1:QQDr/lw4r88iSzAVh9TwdKm4uFpMmCSsRYIPXtg13gg= github.com/tuihub/protos v0.4.14/go.mod h1:DuhbgkLYDaZxitUjLYHrc5ArgM25V1Vcl68mpTgC/co= +github.com/tuihub/protos v0.4.16 h1:zNawX1TpkCMTDKzYikGgeSJmwdJk0PLW75N3RBEiToc= +github.com/tuihub/protos v0.4.16/go.mod h1:h0nKrfphmLMsiDHrG07DHKFNSmqi2JoePTx60ER7wQI= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -316,6 +318,7 @@ google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY= google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg= +google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= diff --git a/porter.go b/porter.go index e1c6085..e5cd3c4 100644 --- a/porter.go +++ b/porter.go @@ -197,9 +197,9 @@ func (p *Porter) AsUser(ctx context.Context, userID int64) (*LibrarianClient, er if err != nil { return nil, err } - resp, err := client.GainUserPrivilege( + resp, err := client.AcquireUserToken( WithToken(ctx, p.wrapper.Token.AccessToken), - &sephirah.GainUserPrivilegeRequest{ + &sephirah.AcquireUserTokenRequest{ UserId: &librarian.InternalID{Id: userID}, }, ) diff --git a/wrapper.go b/wrapper.go index 06ffa2a..32882f4 100644 --- a/wrapper.go +++ b/wrapper.go @@ -181,12 +181,8 @@ func (s *service) PullFeed(ctx context.Context, req *pb.PullFeedRequest) (*pb.Pu if !s.p.Enabled() { return nil, errors.Forbidden("Unauthorized caller", "") } - if req.GetSource() == "" || - req.GetChannelId() == "" { - return nil, errors.BadRequest("Invalid feed id", "") - } for _, source := range s.p.Config.FeatureSummary.GetFeedSources() { - if source.GetId() == req.GetSource() { + if source.GetId() == req.GetSource().GetId() { return s.p.Handler.PullFeed(ctx, req) } } @@ -197,11 +193,8 @@ func (s *service) PushFeedItems(ctx context.Context, req *pb.PushFeedItemsReques if !s.p.Enabled() { return nil, errors.Forbidden("Unauthorized caller", "") } - if req.GetDestination() == "" || req.GetChannelId() == "" || len(req.GetItems()) == 0 { - return nil, errors.BadRequest("Invalid feed id", "") - } for _, destination := range s.p.Config.FeatureSummary.GetNotifyDestinations() { - if destination.GetId() == req.GetDestination() { + if destination.GetId() == req.GetDestination().GetId() { return s.p.Handler.PushFeedItems(ctx, req) } }