♻️ Replace nil context with context.Background in authkit
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package authkit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex/sec"
|
||||
@ -13,7 +14,7 @@ func AddEvent(nx *nex.Conn, userId uint, action, target, ip, ua string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get auth service client: %v", err)
|
||||
}
|
||||
_, err = proto.NewAuditServiceClient(conn).RecordEvent(nil, &proto.RecordEventRequest{
|
||||
_, err = proto.NewAuditServiceClient(conn).RecordEvent(context.Background(), &proto.RecordEventRequest{
|
||||
UserId: uint64(userId),
|
||||
Action: action,
|
||||
Target: target,
|
||||
@ -33,7 +34,7 @@ func AddEventExt(nx *nex.Conn, action, target string, c *fiber.Ctx) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get auth service client: %v", err)
|
||||
}
|
||||
_, err = proto.NewAuditServiceClient(conn).RecordEvent(nil, &proto.RecordEventRequest{
|
||||
_, err = proto.NewAuditServiceClient(conn).RecordEvent(context.Background(), &proto.RecordEventRequest{
|
||||
UserId: uint64(user.ID),
|
||||
Action: action,
|
||||
Target: target,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package authkit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
||||
"git.solsynth.dev/hypernet/passport/pkg/proto"
|
||||
@ -17,7 +18,7 @@ func NotifyUser(nx *nex.Conn, userId uint64, notify pushkit.Notification, unsave
|
||||
if len(unsaved) == 0 {
|
||||
unsaved = append(unsaved, false)
|
||||
}
|
||||
_, err = proto.NewNotifyServiceClient(conn).NotifyUser(nil, &proto.NotifyUserRequest{
|
||||
_, err = proto.NewNotifyServiceClient(conn).NotifyUser(context.Background(), &proto.NotifyUserRequest{
|
||||
UserId: userId,
|
||||
Notify: &proto.NotifyInfoPayload{
|
||||
Unsaved: unsaved[0],
|
||||
@ -36,7 +37,7 @@ func NotifyUserBatch(nx *nex.Conn, userId []uint64, notify pushkit.Notification,
|
||||
if len(unsaved) == 0 {
|
||||
unsaved = append(unsaved, false)
|
||||
}
|
||||
_, err = proto.NewNotifyServiceClient(conn).NotifyUserBatch(nil, &proto.NotifyUserBatchRequest{
|
||||
_, err = proto.NewNotifyServiceClient(conn).NotifyUserBatch(context.Background(), &proto.NotifyUserBatchRequest{
|
||||
UserId: userId,
|
||||
Notify: &proto.NotifyInfoPayload{
|
||||
Unsaved: unsaved[0],
|
||||
|
@ -1,6 +1,7 @@
|
||||
package authkit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
||||
"git.solsynth.dev/hypernet/passport/pkg/authkit/models"
|
||||
"git.solsynth.dev/hypernet/passport/pkg/proto"
|
||||
@ -13,7 +14,7 @@ func GetRealm(nx *nex.Conn, id uint) (models.Realm, error) {
|
||||
if err != nil {
|
||||
return realm, err
|
||||
}
|
||||
resp, err := proto.NewRealmServiceClient(conn).GetRealm(nil, &proto.LookupRealmRequest{
|
||||
resp, err := proto.NewRealmServiceClient(conn).GetRealm(context.Background(), &proto.LookupRealmRequest{
|
||||
Id: lo.ToPtr(uint64(id)),
|
||||
})
|
||||
if err != nil {
|
||||
@ -28,7 +29,7 @@ func GetRealmByAlias(nx *nex.Conn, alias string) (models.Realm, error) {
|
||||
if err != nil {
|
||||
return realm, err
|
||||
}
|
||||
resp, err := proto.NewRealmServiceClient(conn).GetRealm(nil, &proto.LookupRealmRequest{
|
||||
resp, err := proto.NewRealmServiceClient(conn).GetRealm(context.Background(), &proto.LookupRealmRequest{
|
||||
Alias: &alias,
|
||||
})
|
||||
if err != nil {
|
||||
@ -43,7 +44,7 @@ func ListRealm(nx *nex.Conn, id []uint) ([]models.Realm, error) {
|
||||
if err != nil {
|
||||
return realms, err
|
||||
}
|
||||
resp, err := proto.NewRealmServiceClient(conn).ListRealm(nil, &proto.ListRealmRequest{
|
||||
resp, err := proto.NewRealmServiceClient(conn).ListRealm(context.Background(), &proto.ListRealmRequest{
|
||||
Id: lo.Map(id, func(item uint, _ int) uint64 {
|
||||
return uint64(item)
|
||||
}),
|
||||
@ -63,7 +64,7 @@ func GetRealmMember(nx *nex.Conn, realmID, userID uint) (models.RealmMember, err
|
||||
if err != nil {
|
||||
return member, err
|
||||
}
|
||||
resp, err := proto.NewRealmServiceClient(conn).GetRealmMember(nil, &proto.RealmMemberLookupRequest{
|
||||
resp, err := proto.NewRealmServiceClient(conn).GetRealmMember(context.Background(), &proto.RealmMemberLookupRequest{
|
||||
RealmId: lo.ToPtr(uint64(realmID)),
|
||||
UserId: lo.ToPtr(uint64(userID)),
|
||||
})
|
||||
@ -79,7 +80,7 @@ func ListRealmMember(nx *nex.Conn, realmID uint) ([]models.RealmMember, error) {
|
||||
if err != nil {
|
||||
return members, err
|
||||
}
|
||||
resp, err := proto.NewRealmServiceClient(conn).ListRealmMember(nil, &proto.RealmMemberLookupRequest{
|
||||
resp, err := proto.NewRealmServiceClient(conn).ListRealmMember(context.Background(), &proto.RealmMemberLookupRequest{
|
||||
RealmId: lo.ToPtr(uint64(realmID)),
|
||||
})
|
||||
if err != nil {
|
||||
@ -96,7 +97,7 @@ func CheckRealmMemberPerm(nx *nex.Conn, realmID uint, userID, power int) bool {
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
resp, err := proto.NewRealmServiceClient(conn).CheckRealmMemberPerm(nil, &proto.CheckRealmPermRequest{
|
||||
resp, err := proto.NewRealmServiceClient(conn).CheckRealmMemberPerm(context.Background(), &proto.CheckRealmPermRequest{
|
||||
RealmId: uint64(realmID),
|
||||
UserId: uint64(userID),
|
||||
PowerLevel: int32(power),
|
||||
|
@ -1,6 +1,7 @@
|
||||
package authkit
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/proto"
|
||||
)
|
||||
@ -10,10 +11,13 @@ func ListRelative(nx *nex.Conn, userId uint, status int32, isRelated bool) ([]*p
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp, err := proto.NewUserServiceClient(conn).ListUserRelative(nil, &proto.ListUserRelativeRequest{
|
||||
resp, err := proto.NewUserServiceClient(conn).ListUserRelative(context.Background(), &proto.ListUserRelativeRequest{
|
||||
UserId: uint64(userId),
|
||||
Status: status,
|
||||
IsRelated: isRelated,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp.GetData(), err
|
||||
}
|
||||
|
Reference in New Issue
Block a user