Changed the PublicKey.Owner type to be an IRI

This commit is contained in:
Marius Orcsik 2022-01-02 16:20:23 +01:00
parent b32c7ce9db
commit ea1a9658cd
No known key found for this signature in database
GPG key ID: DBF5E47F5DBC4D21
2 changed files with 7 additions and 7 deletions

View file

@ -189,10 +189,12 @@ func (a Actor) IsCollection() bool {
}
// PublicKey holds the ActivityPub compatible public key data
// The document reference can be found at:
// https://web-payments.org/vocabs/security#publicKey
type PublicKey struct {
ID ID `jsonld:"id,omitempty"`
Owner ObjectOrLink `jsonld:"owner,omitempty"`
PublicKeyPem string `jsonld:"publicKeyPem,omitempty"`
ID ID `jsonld:"id,omitempty"`
Owner IRI `jsonld:"owner,omitempty"`
PublicKeyPem string `jsonld:"publicKeyPem,omitempty"`
}
func (p *PublicKey) UnmarshalJSON(data []byte) error {
@ -212,7 +214,7 @@ func (p PublicKey) MarshalJSON() ([]byte, error) {
if v, err := p.ID.MarshalJSON(); err == nil && len(v) > 0 {
notEmpty = !writeJSONProp(&b, "id", v)
}
if p.Owner != nil {
if len(p.Owner) > 0 {
notEmpty = writeIRIJSONProp(&b, "owner", p.Owner) || notEmpty
}
if len(p.PublicKeyPem) > 0 {

View file

@ -378,9 +378,7 @@ func notEmptyActor(a *Actor) bool {
a.PreferredUsername != nil ||
a.Endpoints != nil ||
a.Streams != nil ||
len(a.PublicKey.ID) > 0 ||
(a.PublicKey.Owner != nil &&
len(a.PublicKey.PublicKeyPem) > 0)
len(a.PublicKey.ID)+len(a.PublicKey.Owner)+len(a.PublicKey.PublicKeyPem) > 0
}
// NotEmpty tells us if a Item interface value has a non nil value for various types