👽 Support new version dealer devkit

This commit is contained in:
LittleSheep 2024-09-11 23:04:14 +08:00
parent 313f6b8d4f
commit ea3d6c20d3
5 changed files with 41 additions and 14 deletions

View File

@ -4,12 +4,7 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix daily sign random panic"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Realm avatar, banner and access policy" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/models/realms.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/realms.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/realms_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/realms_api.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@ -155,7 +150,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":alien: Change avatar and banner id to string" />
<MESSAGE value=":card_file_box: Update modeling" /> <MESSAGE value=":card_file_box: Update modeling" />
<MESSAGE value=":sparkles: Bot token aka. API token" /> <MESSAGE value=":sparkles: Bot token aka. API token" />
<MESSAGE value=":sparkles: Bots aka. automated accounts" /> <MESSAGE value=":sparkles: Bots aka. automated accounts" />
@ -180,7 +174,8 @@
<MESSAGE value=":bug: Fix date formatting issue on daily signing" /> <MESSAGE value=":bug: Fix date formatting issue on daily signing" />
<MESSAGE value=":bug: Fix daily sign batch list query issue" /> <MESSAGE value=":bug: Fix daily sign batch list query issue" />
<MESSAGE value=":bug: Fix daily sign random panic" /> <MESSAGE value=":bug: Fix daily sign random panic" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix daily sign random panic" /> <MESSAGE value=":sparkles: Realm avatar, banner and access policy" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Realm avatar, banner and access policy" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.21.6
toolchain go1.22.1 toolchain go1.22.1
require ( require (
git.solsynth.dev/hydrogen/dealer v0.0.0-20240824155914-68c6a5565468 git.solsynth.dev/hydrogen/dealer v0.0.0-20240911145828-d734d617bfc8
github.com/go-playground/validator/v10 v10.17.0 github.com/go-playground/validator/v10 v10.17.0
github.com/gofiber/fiber/v2 v2.52.4 github.com/gofiber/fiber/v2 v2.52.4
github.com/golang-jwt/jwt/v5 v5.2.0 github.com/golang-jwt/jwt/v5 v5.2.0

2
go.sum
View File

@ -2,6 +2,8 @@ git.solsynth.dev/hydrogen/dealer v0.0.0-20240823113302-208da7e90fdb h1:dv4uVDMe5
git.solsynth.dev/hydrogen/dealer v0.0.0-20240823113302-208da7e90fdb/go.mod h1:Q51JPkKnV0UoOT/IRmdBh5CyfSlp7s8BRGzgooYHqkI= git.solsynth.dev/hydrogen/dealer v0.0.0-20240823113302-208da7e90fdb/go.mod h1:Q51JPkKnV0UoOT/IRmdBh5CyfSlp7s8BRGzgooYHqkI=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240824155914-68c6a5565468 h1:DZ1b5WA1FoUE71zyl6OzQ+QbCo4tPJv077ekM1VQ524= git.solsynth.dev/hydrogen/dealer v0.0.0-20240824155914-68c6a5565468 h1:DZ1b5WA1FoUE71zyl6OzQ+QbCo4tPJv077ekM1VQ524=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240824155914-68c6a5565468/go.mod h1:Q51JPkKnV0UoOT/IRmdBh5CyfSlp7s8BRGzgooYHqkI= git.solsynth.dev/hydrogen/dealer v0.0.0-20240824155914-68c6a5565468/go.mod h1:Q51JPkKnV0UoOT/IRmdBh5CyfSlp7s8BRGzgooYHqkI=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240911145828-d734d617bfc8 h1:kWheneSdSySG5tz9TAXrtr546JdMpQZTyWDFk4jeGwg=
git.solsynth.dev/hydrogen/dealer v0.0.0-20240911145828-d734d617bfc8/go.mod h1:Q51JPkKnV0UoOT/IRmdBh5CyfSlp7s8BRGzgooYHqkI=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= 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= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=

View File

@ -2,6 +2,7 @@ package grpc
import ( import (
"context" "context"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database" "git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models" "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
"github.com/samber/lo" "github.com/samber/lo"

View File

@ -3,6 +3,7 @@ package grpc
import ( import (
"context" "context"
"fmt" "fmt"
"git.solsynth.dev/hydrogen/dealer/pkg/proto" "git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hydrogen/passport/pkg/internal/database" "git.solsynth.dev/hydrogen/passport/pkg/internal/database"
"git.solsynth.dev/hydrogen/passport/pkg/internal/models" "git.solsynth.dev/hydrogen/passport/pkg/internal/models"
@ -18,7 +19,7 @@ func (v *Server) ListCommunityRealm(ctx context.Context, empty *proto.ListRealmR
return &proto.ListRealmResponse{ return &proto.ListRealmResponse{
Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo { Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo {
return &proto.RealmInfo{ info := &proto.RealmInfo{
Id: uint64(item.ID), Id: uint64(item.ID),
Alias: item.Alias, Alias: item.Alias,
Name: item.Name, Name: item.Name,
@ -26,6 +27,13 @@ func (v *Server) ListCommunityRealm(ctx context.Context, empty *proto.ListRealmR
IsPublic: item.IsPublic, IsPublic: item.IsPublic,
IsCommunity: item.IsCommunity, IsCommunity: item.IsCommunity,
} }
if item.Avatar != nil {
info.Avatar = *item.Avatar
}
if item.Banner != nil {
info.Banner = *item.Banner
}
return info
}), }),
}, nil }, nil
} }
@ -42,7 +50,7 @@ func (v *Server) ListAvailableRealm(ctx context.Context, request *proto.LookupUs
return &proto.ListRealmResponse{ return &proto.ListRealmResponse{
Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo { Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo {
return &proto.RealmInfo{ info := &proto.RealmInfo{
Id: uint64(item.ID), Id: uint64(item.ID),
Alias: item.Alias, Alias: item.Alias,
Name: item.Name, Name: item.Name,
@ -50,6 +58,13 @@ func (v *Server) ListAvailableRealm(ctx context.Context, request *proto.LookupUs
IsPublic: item.IsPublic, IsPublic: item.IsPublic,
IsCommunity: item.IsCommunity, IsCommunity: item.IsCommunity,
} }
if item.Avatar != nil {
info.Avatar = *item.Avatar
}
if item.Banner != nil {
info.Banner = *item.Banner
}
return info
}), }),
}, nil }, nil
} }
@ -66,7 +81,7 @@ func (v *Server) ListOwnedRealm(ctx context.Context, request *proto.LookupUserRe
return &proto.ListRealmResponse{ return &proto.ListRealmResponse{
Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo { Data: lo.Map(realms, func(item models.Realm, index int) *proto.RealmInfo {
return &proto.RealmInfo{ info := &proto.RealmInfo{
Id: uint64(item.ID), Id: uint64(item.ID),
Alias: item.Alias, Alias: item.Alias,
Name: item.Name, Name: item.Name,
@ -74,6 +89,13 @@ func (v *Server) ListOwnedRealm(ctx context.Context, request *proto.LookupUserRe
IsPublic: item.IsPublic, IsPublic: item.IsPublic,
IsCommunity: item.IsCommunity, IsCommunity: item.IsCommunity,
} }
if item.Avatar != nil {
info.Avatar = *item.Avatar
}
if item.Banner != nil {
info.Banner = *item.Banner
}
return info
}), }),
}, nil }, nil
} }
@ -99,14 +121,21 @@ func (v *Server) GetRealm(ctx context.Context, request *proto.LookupRealmRequest
return nil, err return nil, err
} }
return &proto.RealmInfo{ info := &proto.RealmInfo{
Id: uint64(realm.ID), Id: uint64(realm.ID),
Alias: realm.Alias, Alias: realm.Alias,
Name: realm.Name, Name: realm.Name,
Description: realm.Description, Description: realm.Description,
IsPublic: realm.IsPublic, IsPublic: realm.IsPublic,
IsCommunity: realm.IsCommunity, IsCommunity: realm.IsCommunity,
}, nil }
if realm.Avatar != nil {
info.Avatar = *realm.Avatar
}
if realm.Banner != nil {
info.Banner = *realm.Banner
}
return info, nil
} }
func (v *Server) ListRealmMember(ctx context.Context, request *proto.RealmMemberLookupRequest) (*proto.ListRealmMemberResponse, error) { func (v *Server) ListRealmMember(ctx context.Context, request *proto.RealmMemberLookupRequest) (*proto.ListRealmMemberResponse, error) {