✨ Realm operations now available in authkit
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
package models
|
||||
|
||||
import "gorm.io/datatypes"
|
||||
import (
|
||||
"git.solsynth.dev/hypernet/nexus/pkg/nex"
|
||||
"git.solsynth.dev/hypernet/passport/pkg/proto"
|
||||
"gorm.io/datatypes"
|
||||
)
|
||||
|
||||
type Realm struct {
|
||||
BaseModel
|
||||
@ -17,6 +21,22 @@ type Realm struct {
|
||||
AccountID uint `json:"account_id"`
|
||||
}
|
||||
|
||||
func NewRealmFromProto(proto *proto.RealmInfo) Realm {
|
||||
return Realm{
|
||||
BaseModel: BaseModel{
|
||||
ID: uint(proto.GetId()),
|
||||
},
|
||||
Alias: proto.GetAlias(),
|
||||
Name: proto.GetName(),
|
||||
Description: proto.GetDescription(),
|
||||
Avatar: &proto.Avatar,
|
||||
Banner: &proto.Banner,
|
||||
IsPublic: proto.GetIsPublic(),
|
||||
IsCommunity: proto.GetIsCommunity(),
|
||||
AccessPolicy: nex.DecodeMap(proto.GetAccessPolicy()),
|
||||
}
|
||||
}
|
||||
|
||||
type RealmMember struct {
|
||||
BaseModel
|
||||
|
||||
@ -26,3 +46,14 @@ type RealmMember struct {
|
||||
Account Account `json:"account"`
|
||||
PowerLevel int `json:"power_level"`
|
||||
}
|
||||
|
||||
func NewRealmMemberFromProto(proto *proto.RealmMemberInfo) RealmMember {
|
||||
return RealmMember{
|
||||
BaseModel: BaseModel{
|
||||
ID: uint(proto.GetId()),
|
||||
},
|
||||
RealmID: uint(proto.GetRealmId()),
|
||||
AccountID: uint(proto.GetUserId()),
|
||||
PowerLevel: int(proto.GetPowerLevel()),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user