mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-23 14:53:34 +01:00
Remove redundant person implementation
This commit is contained in:
parent
22ba03ae4d
commit
c61be31c72
1 changed files with 0 additions and 56 deletions
|
@ -1,56 +0,0 @@
|
|||
package forgefed
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
ap "github.com/go-ap/activitypub"
|
||||
"github.com/valyala/fastjson"
|
||||
)
|
||||
|
||||
func CreatePersonFromParsedJson(parsed *fastjson.Value) (*ap.Person, error) {
|
||||
|
||||
iriString := ap.JSONGetString(parsed, "id")
|
||||
preferredUsername := ap.JSONGetString(parsed, "preferredUsername")
|
||||
url := ap.JSONGetString(parsed, "url")
|
||||
icon := ap.JSONGetString(parsed.Get("icon"), "url")
|
||||
inbox := ap.JSONGetString(parsed, "inbox")
|
||||
outbox := ap.JSONGetString(parsed, "outbox")
|
||||
publicKeyId := ap.JSONGetString(parsed.Get("publicKey"), "id")
|
||||
publicKeyOwner := ap.JSONGetString(parsed.Get("publicKey"), "owner")
|
||||
publicKeyPem := ap.JSONGetString(parsed.Get("publicKey"), "publicKeyPem")
|
||||
|
||||
person := *ap.PersonNew(ap.IRI(iriString))
|
||||
|
||||
person.Name = ap.NaturalLanguageValuesNew()
|
||||
err := person.Name.Set("en", ap.Content(preferredUsername))
|
||||
if err != nil {
|
||||
return ap.PersonNew(""), fmt.Errorf("set name: %v", err)
|
||||
}
|
||||
|
||||
person.URL = ap.IRI(url)
|
||||
|
||||
person.Icon = ap.Image{
|
||||
Type: ap.ImageType,
|
||||
MediaType: "image/png",
|
||||
URL: ap.IRI(icon),
|
||||
}
|
||||
|
||||
person.Inbox = ap.IRI(inbox)
|
||||
person.Outbox = ap.IRI(outbox)
|
||||
|
||||
person.PublicKey.ID = ap.IRI(publicKeyId)
|
||||
person.PublicKey.Owner = ap.IRI(publicKeyOwner)
|
||||
person.PublicKey.PublicKeyPem = publicKeyPem
|
||||
|
||||
return &person, nil
|
||||
}
|
||||
|
||||
func ParsePersonJson(data []byte) (*ap.Person, error) {
|
||||
parser := fastjson.Parser{}
|
||||
parsed, err := parser.ParseBytes(data)
|
||||
if err != nil {
|
||||
return ap.PersonNew(""), err
|
||||
}
|
||||
|
||||
return CreatePersonFromParsedJson(parsed)
|
||||
}
|
Loading…
Reference in a new issue