linstrom/storage/person.go
mStar aka a person 935fc33094 Uuuh, lots of stuff
More config, moved files, some endpoints (wip), some storage
2024-01-19 10:21:31 +00:00

59 lines
1.5 KiB
Go

// Copyright (c) 2024 mStar
//
// Licensed under the EUPL, Version 1.2
//
// You may not use this work except in compliance with the Licence.
// You should have received a copy of the Licence along with this work. If not, see:
// <https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12>.
// See the Licence for the specific language governing permissions and limitations under the Licence.
//
package storage
import (
"errors"
"github.com/MatejLach/astreams"
"gorm.io/gorm"
)
type Person struct {
gorm.Model // Includes primary key (uid) as well as various time info
// Public data
Uid string
ApID string
Name string
Instance string // url
Local bool
PublicKey string
Url string
ManuallyApprovesFollowers bool
// Private data, set if local == true
Mail *string // mail
PwHash *string
Inbox string // url
Outbox string // url
PrivateKey *string // private key
}
func (pdb *Person) IntoAPPerson() (*astreams.Person, error) {
var actor astreams.Actor
actor.PublicKey = &astreams.PublicKey{
ID: pdb.ApID,
Owner: pdb.Url,
PublicKeyPem: pdb.PublicKey,
}
actor.Inbox = &astreams.StringWithOrderedCollection{
URL: pdb.Inbox,
}
actor.Outbox = &astreams.StringWithOrderedCollection{
URL: pdb.Outbox,
}
actor.ManuallyApprovesFollowers = pdb.ManuallyApprovesFollowers
actor.PreferredUsername = pdb.Name
return nil, errors.New("unimplemented")
}