refactor(server): rename stuff from Lysand to Versia

Big diff energy
This commit is contained in:
DevMiner 2024-08-27 19:59:12 +02:00
parent 03e01548dc
commit cb135706e2
29 changed files with 103 additions and 96 deletions

View file

@ -9,35 +9,32 @@ import (
type Follow struct {
*ent.Follow
URI *versiautils.URL
FollowerURI *versiautils.URL
FolloweeURI *versiautils.URL
URI *versiautils.URL
Follower *User
Followee *User
}
func NewFollow(dbFollow *ent.Follow) (*Follow, error) {
f := &Follow{Follow: dbFollow}
func NewFollow(dbData *ent.Follow) (*Follow, error) {
f := &Follow{Follow: dbData}
var err error
f.URI, err = versiautils.ParseURL(dbFollow.URI)
if err != nil {
if f.URI, err = versiautils.ParseURL(dbData.URI); err != nil {
return nil, err
}
f.FollowerURI, err = versiautils.ParseURL(dbFollow.Edges.Follower.URI)
if err != nil {
if f.Follower, err = NewUser(dbData.Edges.Follower); err != nil {
return nil, err
}
f.FolloweeURI, err = versiautils.ParseURL(dbFollow.Edges.Followee.URI)
if err != nil {
if f.Followee, err = NewUser(dbData.Edges.Followee); err != nil {
return nil, err
}
return f, nil
}
func (f Follow) ToLysand() *versia.Follow {
func (f Follow) ToVersia() *versia.Follow {
return &versia.Follow{
Entity: versia.Entity{
ID: f.ID,
@ -45,12 +42,12 @@ func (f Follow) ToLysand() *versia.Follow {
CreatedAt: versiautils.Time(f.CreatedAt),
Extensions: f.Extensions,
},
Author: f.FollowerURI,
Followee: f.FolloweeURI,
Author: f.Follower.URI,
Followee: f.Followee.URI,
}
}
func (f Follow) ToLysandAccept() *versia.FollowAccept {
func (f Follow) ToVersiaAccept() *versia.FollowAccept {
return &versia.FollowAccept{
Entity: versia.Entity{
ID: f.ID,
@ -58,12 +55,12 @@ func (f Follow) ToLysandAccept() *versia.FollowAccept {
CreatedAt: versiautils.Time(f.CreatedAt),
Extensions: f.Extensions,
},
Author: f.FolloweeURI,
Follower: f.FollowerURI,
Author: f.Followee.URI,
Follower: f.Follower.URI,
}
}
func (f Follow) ToLysandReject() *versia.FollowReject {
func (f Follow) ToVersiaReject() *versia.FollowReject {
return &versia.FollowReject{
Entity: versia.Entity{
ID: f.ID,
@ -71,7 +68,7 @@ func (f Follow) ToLysandReject() *versia.FollowReject {
CreatedAt: versiautils.Time(f.CreatedAt),
Extensions: f.Extensions,
},
Author: f.FolloweeURI,
Follower: f.FollowerURI,
Author: f.Followee.URI,
Follower: f.Follower.URI,
}
}

View file

@ -46,7 +46,7 @@ func NewNote(dbNote *ent.Note) (*Note, error) {
return n, nil
}
func (n Note) ToLysand() versia.Note {
func (n Note) ToVersia() versia.Note {
return versia.Note{
Entity: versia.Entity{
ID: n.ID,

View file

@ -70,7 +70,7 @@ func NewInstanceMetadata(dbData *ent.InstanceMetadata) (*InstanceMetadata, error
return n, nil
}
func (m InstanceMetadata) ToLysand() versia.InstanceMetadata {
func (m InstanceMetadata) ToVersia() versia.InstanceMetadata {
return versia.InstanceMetadata{
CreatedAt: versiautils.TimeFromStd(m.CreatedAt),
Extensions: m.Extensions,

View file

@ -23,10 +23,10 @@ type User struct {
Followers *versiautils.URL
Following *versiautils.URL
DisplayName string
LysandAvatar versiautils.ImageContentTypeMap
LysandBiography versiautils.TextContentTypeMap
Signer versiacrypto.Signer
DisplayName string
Avatar versiautils.ImageContentTypeMap
Biography versiautils.TextContentTypeMap
Signer versiacrypto.Signer
}
func NewUser(dbData *ent.User) (*User, error) {
@ -38,8 +38,8 @@ func NewUser(dbData *ent.User) (*User, error) {
},
DisplayName: dbData.Username,
LysandAvatar: lysandAvatar(dbData),
LysandBiography: lysandBiography(dbData),
Avatar: userAvatar(dbData),
Biography: userBiography(dbData),
}
if dbData.DisplayName != nil {
@ -81,7 +81,7 @@ func NewUser(dbData *ent.User) (*User, error) {
return u, nil
}
func (u User) ToLysand() *versia.User {
func (u User) ToVersia() *versia.User {
return &versia.User{
Entity: versia.Entity{
ID: u.ID,
@ -91,7 +91,7 @@ func (u User) ToLysand() *versia.User {
},
DisplayName: helpers.StringPtr(u.DisplayName),
Username: u.Username,
Avatar: u.LysandAvatar,
Avatar: u.Avatar,
Header: imageMap(u.Edges.HeaderImage),
Indexable: u.Indexable,
PublicKey: versia.UserPublicKey{
@ -99,7 +99,7 @@ func (u User) ToLysand() *versia.User {
Algorithm: u.PublicKeyAlgorithm,
Key: u.PublicKey,
},
Bio: u.LysandBiography,
Bio: u.Biography,
Fields: u.Fields,
Inbox: u.Inbox,
@ -110,7 +110,7 @@ func (u User) ToLysand() *versia.User {
}
}
func lysandAvatar(u *ent.User) versiautils.ImageContentTypeMap {
func userAvatar(u *ent.User) versiautils.ImageContentTypeMap {
if avatar := imageMap(u.Edges.AvatarImage); avatar != nil {
return avatar
}
@ -122,7 +122,7 @@ func lysandAvatar(u *ent.User) versiautils.ImageContentTypeMap {
}
}
func lysandBiography(u *ent.User) versiautils.TextContentTypeMap {
func userBiography(u *ent.User) versiautils.TextContentTypeMap {
if u.Biography == nil {
return nil
}