⬆️ Implement list user relative grpc function
This commit is contained in:
parent
bdcc8de59b
commit
dd3586b241
11
.idea/workspace.xml
generated
11
.idea/workspace.xml
generated
@ -4,9 +4,12 @@
|
||||
<option name="autoReloadType" value="ALL" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Use capital to deal with links">
|
||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix internal token audience update isn't fully applied">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/oauth_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/oauth_api.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/auth.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/settings.toml" beforeDir="false" afterPath="$PROJECT_DIR$/settings.toml" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -153,7 +156,6 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value=":recycle: Optimized the initial permission system" />
|
||||
<MESSAGE value=":zap: Optimized audit, event logging system :sparkles: Audit logs :sparkles: Admin edit user permissions" />
|
||||
<MESSAGE value=":sparkles: Admin force confirm account" />
|
||||
<MESSAGE value=":sparkles: Admin notify one user" />
|
||||
@ -178,7 +180,8 @@
|
||||
<MESSAGE value=":bug: Fix permissions in groups" />
|
||||
<MESSAGE value=":wastebasket: Clean up code" />
|
||||
<MESSAGE value=":sparkles: Use capital to deal with links" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Use capital to deal with links" />
|
||||
<MESSAGE value=":bug: Fix internal token audience update isn't fully applied" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix internal token audience update isn't fully applied" />
|
||||
</component>
|
||||
<component name="VgoProject">
|
||||
<settings-migrated>true</settings-migrated>
|
||||
|
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.21.6
|
||||
toolchain go1.22.1
|
||||
|
||||
require (
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240801060523-8cf0feb09a27
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240802073919-63ea5e848f6e
|
||||
github.com/go-playground/validator/v10 v10.17.0
|
||||
github.com/gofiber/fiber/v2 v2.52.4
|
||||
github.com/golang-jwt/jwt/v5 v5.2.0
|
||||
|
2
go.sum
2
go.sum
@ -2,6 +2,8 @@ git.solsynth.dev/hydrogen/dealer v0.0.0-20240721055146-d74cdddbaf49 h1:DMmCBcnCO
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240721055146-d74cdddbaf49/go.mod h1:IZd94qZZIj+MO9EqjGDqnAD9nWurlNPyhVPKemAY5lw=
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240801060523-8cf0feb09a27 h1:KQzeOI2ou240SXiL1hxMYDvZpYKtCFblCGDusFyGyBY=
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240801060523-8cf0feb09a27/go.mod h1:IZd94qZZIj+MO9EqjGDqnAD9nWurlNPyhVPKemAY5lw=
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240802073919-63ea5e848f6e h1:xsyulF3EVhyQ+/+mbg1xso7PeVt1cX+d92LsTwF59JQ=
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240802073919-63ea5e848f6e/go.mod h1:IZd94qZZIj+MO9EqjGDqnAD9nWurlNPyhVPKemAY5lw=
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
|
||||
|
@ -2,7 +2,9 @@ package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
|
||||
"github.com/samber/lo"
|
||||
|
||||
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
||||
@ -89,3 +91,53 @@ func (v *Server) EnsureUserPermGranted(_ context.Context, in *proto.CheckUserPer
|
||||
IsValid: valid,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (v *Server) ListUserFriends(_ context.Context, in *proto.ListUserRelativeRequest) (*proto.ListUserRelativeResponse, error) {
|
||||
tx := database.C.Preload("Account").Where("status = ?", models.RelationshipFriend)
|
||||
|
||||
if in.GetIsRelated() {
|
||||
tx = tx.Where("related_id = ?", in.GetUserId())
|
||||
} else {
|
||||
tx = tx.Where("account_id = ?", in.GetUserId())
|
||||
}
|
||||
|
||||
var data []models.AccountRelationship
|
||||
if err := tx.Find(&data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &proto.ListUserRelativeResponse{
|
||||
Data: lo.Map(data, func(item models.AccountRelationship, index int) *proto.SimpleUserInfo {
|
||||
return &proto.SimpleUserInfo{
|
||||
Id: uint64(item.AccountID),
|
||||
Name: item.Account.Name,
|
||||
Nick: item.Account.Nick,
|
||||
}
|
||||
}),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (v *Server) ListUserBlocklist(_ context.Context, in *proto.ListUserRelativeRequest) (*proto.ListUserRelativeResponse, error) {
|
||||
tx := database.C.Preload("Account").Where("status = ?", models.RelationshipBlocked)
|
||||
|
||||
if in.GetIsRelated() {
|
||||
tx = tx.Where("related_id = ?", in.GetUserId())
|
||||
} else {
|
||||
tx = tx.Where("account_id = ?", in.GetUserId())
|
||||
}
|
||||
|
||||
var data []models.AccountRelationship
|
||||
if err := tx.Find(&data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &proto.ListUserRelativeResponse{
|
||||
Data: lo.Map(data, func(item models.AccountRelationship, index int) *proto.SimpleUserInfo {
|
||||
return &proto.SimpleUserInfo{
|
||||
Id: uint64(item.AccountID),
|
||||
Name: item.Account.Name,
|
||||
Nick: item.Account.Nick,
|
||||
}
|
||||
}),
|
||||
}, nil
|
||||
}
|
||||
|
@ -3,12 +3,10 @@ name = "Solarpass"
|
||||
|
||||
bind = "0.0.0.0:8444"
|
||||
grpc_bind = "0.0.0.0:7444"
|
||||
domain = "localhost"
|
||||
domain = "id.solsynth.dev"
|
||||
|
||||
frontend_app = "https://solsynth.dev"
|
||||
|
||||
domain = "id.solsynth.dev"
|
||||
|
||||
content_endpoint = "https://usercontent.solsynth.dev"
|
||||
|
||||
default_user_group = 1
|
||||
|
Loading…
Reference in New Issue
Block a user