kopia lustrzana https://github.com/reiver/greatape
refactor(project): 🧱 improve federation
rodzic
c733122af1
commit
c9addad9ad
|
@ -1,85 +1,61 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/reiver/greatape/app/activitypub"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
)
|
||||
|
||||
func FollowActor(x IDispatcher, username string, acct string) (IFollowActorResult, error) {
|
||||
parts := strings.Split(acct, "@")
|
||||
x.Assert(len(parts) == 2).Or(ERROR_INVALID_PARAMETERS)
|
||||
|
||||
webfingerUrl := x.Format("https://%s/.well-known/webfinger?resource=acct:%s", parts[1], acct)
|
||||
resp, err := http.Get(webfingerUrl)
|
||||
func FollowActor(x IDispatcher, username string, account string) (IFollowActorResult, error) {
|
||||
webfinger, err := x.ResolveWebfinger(account)
|
||||
x.AssertNoError(err)
|
||||
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
x.AssertNoError(err)
|
||||
|
||||
webfinger, err := activitypub.UnmarshalWebfinger(data)
|
||||
x.AssertNoError(err)
|
||||
|
||||
subject := ""
|
||||
for _, link := range webfinger.Links {
|
||||
if link.Rel == "self" {
|
||||
subject = *link.Href
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if x.IsEmpty(subject) {
|
||||
return nil, ERROR_INVALID_PARAMETERS
|
||||
}
|
||||
|
||||
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
||||
return identity.Username() == username
|
||||
})
|
||||
|
||||
x.Assert(identities.HasExactlyOneItem()).Or(ERROR_USER_NOT_FOUND)
|
||||
identity := identities.First()
|
||||
|
||||
follower := x.GetActorId()
|
||||
|
||||
identity := x.GetIdentityByUsername(username)
|
||||
follower := x.GetActorId(identity)
|
||||
followee := &activitypub.Actor{}
|
||||
if err := x.GetActivityStreamSigned(subject, nil, followee); err != nil {
|
||||
|
||||
if err := x.GetSignedActivityStream(webfinger.Self(), followee, identity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
uniqueIdentifier := x.GenerateUUID()
|
||||
follow := activitypub.NewFollow(follower, followee.ID, uniqueIdentifier)
|
||||
followers := x.FilterActivityPubFollowers(func(follow IActivityPubFollower) bool {
|
||||
return follow.Handle() == follower && follow.Subject() == followee.Id
|
||||
})
|
||||
|
||||
if followers.HasAtLeastOneItem() && followers.First().Accepted() {
|
||||
return x.NewFollowActorResult(), nil
|
||||
}
|
||||
|
||||
follow := activitypub.NewFollow(follower, followee.Id)
|
||||
|
||||
x.Atomic(func() error {
|
||||
activity := x.MarshalJson(follow)
|
||||
if followers.IsEmpty() {
|
||||
activity := x.MarshalJson(follow)
|
||||
|
||||
x.AddActivityPubOutgoingActivity(
|
||||
identity.Id(),
|
||||
uniqueIdentifier,
|
||||
x.UnixNano(),
|
||||
follower,
|
||||
followee.ID,
|
||||
activitypub.TypeFollow,
|
||||
activity,
|
||||
)
|
||||
x.AddActivityPubOutgoingActivity(
|
||||
identity.Id(),
|
||||
follow.UniqueIdentifier,
|
||||
x.UnixNano(),
|
||||
follower,
|
||||
followee.Id,
|
||||
activitypub.TypeFollow,
|
||||
activity,
|
||||
)
|
||||
|
||||
x.AddActivityPubFollower(
|
||||
follower,
|
||||
followee.Inbox,
|
||||
followee.ID,
|
||||
activity,
|
||||
false,
|
||||
)
|
||||
x.AddActivityPubFollower(
|
||||
follower,
|
||||
followee.Inbox,
|
||||
followee.Id,
|
||||
activity,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
||||
if err := x.PostActivityStreamSigned(followee.Inbox, follow, nil); err != nil {
|
||||
if err := x.PostSignedActivityStream(followee.Inbox, follow, identity); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return x.NewFollowActorResult(follow.Id), nil
|
||||
return x.NewFollowActorResult(), nil
|
||||
}
|
||||
|
|
|
@ -7,17 +7,10 @@ import (
|
|||
)
|
||||
|
||||
func PostToInbox(x IDispatcher, username string, body []byte) (IPostToInboxResult, error) {
|
||||
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
||||
return identity.Username() == username
|
||||
})
|
||||
identity := x.GetIdentityByUsername(username)
|
||||
object := x.UnmarshalActivityPubObjectOrLink(body)
|
||||
|
||||
x.Assert(identities.HasExactlyOneItem()).Or(ERROR_USER_NOT_FOUND)
|
||||
identity := identities.First()
|
||||
|
||||
object := &activitypub.Object{}
|
||||
x.UnmarshalJson(body, object)
|
||||
|
||||
switch object.Type {
|
||||
switch object.GetType() {
|
||||
case activitypub.TypeAccept:
|
||||
{
|
||||
activity := &activitypub.Activity{}
|
||||
|
@ -57,17 +50,17 @@ func PostToInbox(x IDispatcher, username string, body []byte) (IPostToInboxResul
|
|||
follow := &activitypub.Follow{}
|
||||
x.UnmarshalJson(body, follow)
|
||||
|
||||
url := follow.Actor
|
||||
actorId := x.GetActorId(identity)
|
||||
|
||||
actor := &activitypub.Actor{}
|
||||
if err := x.GetActivityStreamSigned(url, nil, actor); err != nil {
|
||||
if err := x.GetSignedActivityStream(follow.Actor, actor, identity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
follower := x.AddActivityPubFollower(
|
||||
follow.Actor,
|
||||
actor.Inbox,
|
||||
x.Format("%s/u/%s", x.PublicUrl(), username),
|
||||
actorId,
|
||||
x.MarshalJson(follow),
|
||||
false,
|
||||
)
|
||||
|
@ -76,11 +69,11 @@ func PostToInbox(x IDispatcher, username string, body []byte) (IPostToInboxResul
|
|||
Context: activitypub.ActivityStreams,
|
||||
ID: x.Format("%s/%s", x.PublicUrl(), x.GenerateUUID()),
|
||||
Type: activitypub.TypeAccept,
|
||||
Actor: x.Format("%s/u/%s", x.PublicUrl(), username),
|
||||
Actor: actorId,
|
||||
Object: follow,
|
||||
}
|
||||
|
||||
if err := x.PostActivityStreamSigned(actor.Inbox, activity, nil); err != nil {
|
||||
if err := x.PostSignedActivityStream(actor.Inbox, activity, identity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -1,37 +1,27 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
ap "github.com/go-ap/activitypub"
|
||||
"github.com/reiver/greatape/app/activitypub"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
)
|
||||
|
||||
func PostToOutbox(x IDispatcher, username string, body []byte) (IPostToOutboxResult, error) {
|
||||
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
||||
return identity.Username() == username
|
||||
})
|
||||
identity := x.GetIdentityByUsername(username)
|
||||
object := x.UnmarshalActivityPubObjectOrLink(body)
|
||||
|
||||
x.Assert(identities.HasExactlyOneItem()).Or(ERROR_USER_NOT_FOUND)
|
||||
identity := identities.First()
|
||||
|
||||
item := x.UnmarshalActivityPubObjectOrLink(body)
|
||||
|
||||
actorId := x.GetActorId()
|
||||
|
||||
switch item.GetType() {
|
||||
switch object.GetType() {
|
||||
case activitypub.TypeNote:
|
||||
{
|
||||
note, err := activitypub.UnmarshalNote(body)
|
||||
if err != nil {
|
||||
return nil, ERROR_INVALID_PARAMETERS
|
||||
}
|
||||
note := object.(*ap.Note)
|
||||
|
||||
content := note.Content
|
||||
to := note.To[0]
|
||||
from := note.AttributedTo
|
||||
actorId := x.GetActorId(identity)
|
||||
content := note.Content.First().String()
|
||||
to := note.To[0].GetID().String()
|
||||
from := note.AttributedTo.GetID().String()
|
||||
|
||||
if from != actorId {
|
||||
return nil, ERROR_INVALID_PARAMETERS
|
||||
|
@ -42,22 +32,22 @@ func PostToOutbox(x IDispatcher, username string, body []byte) (IPostToOutboxRes
|
|||
activity := &activitypub.Activity{
|
||||
Context: activitypub.ActivityStreams,
|
||||
Type: activitypub.TypeCreate,
|
||||
ID: fmt.Sprintf("%s/u/%s/posts/%s", x.PublicUrl(), username, uniqueIdentifier),
|
||||
ID: x.Format("%s/posts/%s", actorId, uniqueIdentifier),
|
||||
To: note.To,
|
||||
Actor: fmt.Sprintf("%s/u/%s", x.PublicUrl(), username),
|
||||
Actor: actorId,
|
||||
Published: time.Now(),
|
||||
Object: note,
|
||||
}
|
||||
|
||||
if to != ACTIVITY_PUB_PUBLIC {
|
||||
recipient := &activitypub.Actor{}
|
||||
if err := x.GetActivityStreamSigned(to, nil, recipient); err != nil {
|
||||
if err := x.GetSignedActivityStream(to, recipient, identity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
to = recipient.ID
|
||||
to = recipient.Id
|
||||
|
||||
if err := x.PostActivityStreamSigned(recipient.Inbox, activity, nil); err != nil {
|
||||
if err := x.PostSignedActivityStream(recipient.Inbox, activity, identity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ func TestGetActorApi(test *testing.T) {
|
|||
func TestFollowActorApi(test *testing.T) {
|
||||
input := &FollowActorRequest{
|
||||
Username: "username",
|
||||
Acct: "acct",
|
||||
Account: "account",
|
||||
}
|
||||
|
||||
if output, err := api.FollowActor(input); err != nil {
|
||||
|
|
|
@ -1804,7 +1804,7 @@ type FollowActorRequest struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
||||
Acct string `protobuf:"bytes,2,opt,name=acct,proto3" json:"acct,omitempty"`
|
||||
Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"`
|
||||
}
|
||||
|
||||
func (x *FollowActorRequest) Reset() {
|
||||
|
@ -1846,9 +1846,9 @@ func (x *FollowActorRequest) GetUsername() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (x *FollowActorRequest) GetAcct() string {
|
||||
func (x *FollowActorRequest) GetAccount() string {
|
||||
if x != nil {
|
||||
return x.Acct
|
||||
return x.Account
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -1857,8 +1857,6 @@ type FollowActorResult struct {
|
|||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
|
||||
}
|
||||
|
||||
func (x *FollowActorResult) Reset() {
|
||||
|
@ -1893,13 +1891,6 @@ func (*FollowActorResult) Descriptor() ([]byte, []int) {
|
|||
return file_spis_proto_rawDescGZIP(), []int{33}
|
||||
}
|
||||
|
||||
func (x *FollowActorResult) GetUrl() string {
|
||||
if x != nil {
|
||||
return x.Url
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// API: AuthorizeInteraction
|
||||
// -----------------------------------------------------------
|
||||
type AuthorizeInteractionRequest struct {
|
||||
|
@ -2919,97 +2910,96 @@ var file_spis_proto_rawDesc = []byte{
|
|||
0x79, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x0e, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x07, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x70,
|
||||
0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
|
||||
0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x22, 0x44, 0x0a, 0x12, 0x46, 0x6f, 0x6c,
|
||||
0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x65, 0x64, 0x22, 0x4a, 0x0a, 0x12, 0x46, 0x6f, 0x6c,
|
||||
0x6c, 0x6f, 0x77, 0x41, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
||||
0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x61,
|
||||
0x63, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x63, 0x63, 0x74, 0x22,
|
||||
0x25, 0x0a, 0x11, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x41, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x65,
|
||||
0x73, 0x75, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x2f, 0x0a, 0x1b, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72,
|
||||
0x69, 0x7a, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x22, 0x48, 0x0a, 0x1a, 0x41, 0x75, 0x74, 0x68, 0x6f,
|
||||
0x72, 0x69, 0x7a, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52,
|
||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65,
|
||||
0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73,
|
||||
0x73, 0x22, 0x31, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72,
|
||||
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c,
|
||||
0x6f, 0x77, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63,
|
||||
0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63,
|
||||
0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f,
|
||||
0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
|
||||
0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72,
|
||||
0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09,
|
||||
0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66,
|
||||
0x69, 0x72, 0x73, 0x74, 0x22, 0x31, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c, 0x6f,
|
||||
0x77, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75,
|
||||
0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75,
|
||||
0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x46,
|
||||
0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19,
|
||||
0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
||||
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a,
|
||||
0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x22, 0x0a,
|
||||
0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20,
|
||||
0x03, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x45, 0x0a, 0x13, 0x50, 0x6f, 0x73, 0x74, 0x54,
|
||||
0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a,
|
||||
0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13, 0x0a, 0x11, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x41,
|
||||
0x63, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x2f, 0x0a, 0x1b, 0x41, 0x75,
|
||||
0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x61, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x22, 0x48, 0x0a, 0x1a, 0x41,
|
||||
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x61, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x18, 0x0a, 0x07, 0x73,
|
||||
0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75,
|
||||
0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x31, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c,
|
||||
0x6f, 0x77, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74,
|
||||
0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12,
|
||||
0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79,
|
||||
0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e,
|
||||
0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01,
|
||||
0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x22,
|
||||
0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05,
|
||||
0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65,
|
||||
0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x31, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46,
|
||||
0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
||||
0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x12,
|
||||
0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x75,
|
||||
0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a,
|
||||
0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70,
|
||||
0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18,
|
||||
0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64,
|
||||
0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x45, 0x0a, 0x13, 0x50,
|
||||
0x6f, 0x73, 0x74, 0x54, 0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f,
|
||||
0x64, 0x79, 0x22, 0x28, 0x0a, 0x12, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x4f, 0x75, 0x74, 0x62,
|
||||
0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2e, 0x0a, 0x10,
|
||||
0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc9, 0x01, 0x0a,
|
||||
0x0f, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74,
|
||||
0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69,
|
||||
0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74,
|
||||
0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12,
|
||||
0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12,
|
||||
0x41, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18,
|
||||
0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75, 0x62, 0x41, 0x63, 0x74, 0x69,
|
||||
0x76, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65,
|
||||
0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x44, 0x0a, 0x12, 0x50, 0x6f, 0x73, 0x74,
|
||||
0x54, 0x6f, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a,
|
||||
0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f,
|
||||
0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x28,
|
||||
0x0a, 0x12, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65,
|
||||
0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2e, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x4f,
|
||||
0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08,
|
||||
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc9, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74,
|
||||
0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18,
|
||||
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74,
|
||||
0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x41, 0x0a, 0x0c, 0x6f,
|
||||
0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x63, 0x74,
|
||||
0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75, 0x62, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
|
||||
0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66,
|
||||
0x69, 0x72, 0x73, 0x74, 0x22, 0x44, 0x0a, 0x12, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x49, 0x6e,
|
||||
0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x27,
|
||||
0x0a, 0x11, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73,
|
||||
0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e,
|
||||
0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73,
|
||||
0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73,
|
||||
0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x27, 0x0a, 0x11, 0x50, 0x6f,
|
||||
0x73, 0x74, 0x54, 0x6f, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12,
|
||||
0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62,
|
||||
0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61,
|
||||
0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52,
|
||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
||||
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65,
|
||||
0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x73, 0x12, 0x41, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75,
|
||||
0x62, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||
0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74,
|
||||
0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x42, 0x0d, 0x5a,
|
||||
0x0b, 0x2e, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x33,
|
||||
0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x49, 0x6e,
|
||||
0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e,
|
||||
0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e,
|
||||
0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61,
|
||||
0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f,
|
||||
0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x41, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65,
|
||||
0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69,
|
||||
0x74, 0x79, 0x50, 0x75, 0x62, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x6f,
|
||||
0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66,
|
||||
0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73,
|
||||
0x74, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -201,11 +201,10 @@ message GetActorResult {
|
|||
//-----------------------------------------------------------
|
||||
message FollowActorRequest {
|
||||
string username = 0x00000001;
|
||||
string acct = 0x00000002;
|
||||
string account = 0x00000002;
|
||||
}
|
||||
|
||||
message FollowActorResult {
|
||||
string url = 0x00000001;
|
||||
}
|
||||
|
||||
// API: AuthorizeInteraction
|
||||
|
|
|
@ -12,12 +12,10 @@ func FollowActorService(context IContext, input *FollowActorRequest) (result *Fo
|
|||
/* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err)
|
||||
defer func() { Conductor.LogRemoteCall(context, DONE, source, input, result, err) }()
|
||||
|
||||
commandResult, err := Conductor.FollowActor(input.Username, input.Acct, context.Identity())
|
||||
if err != nil {
|
||||
if _, err = Conductor.FollowActor(input.Username, input.Account, context.Identity()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result = context.ResultContainer().(*FollowActorResult)
|
||||
result.Url = commandResult.Url()
|
||||
return result, nil
|
||||
}
|
||||
|
|
|
@ -227,6 +227,7 @@ type (
|
|||
ExistsWhich(condition IdentityCondition) bool
|
||||
ListIdentities(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IIdentityCollection
|
||||
GetIdentity(id int64, editor Identity) (IIdentity, error)
|
||||
GetIdentityByUsername(username string, editor Identity) (IIdentity, error)
|
||||
AddIdentity(username string, phoneNumber string, phoneNumberConfirmed bool, firstName string, lastName string, displayName string, email string, emailConfirmed bool, avatar string, banner string, summary string, token string, multiFactor bool, hash string, salt string, publicKey string, privateKey string, permission uint64, restriction uint32, lastLogin int64, loginCount uint32, editor Identity) (IIdentity, error)
|
||||
AddIdentityWithCustomId(id int64, username string, phoneNumber string, phoneNumberConfirmed bool, firstName string, lastName string, displayName string, email string, emailConfirmed bool, avatar string, banner string, summary string, token string, multiFactor bool, hash string, salt string, publicKey string, privateKey string, permission uint64, restriction uint32, lastLogin int64, loginCount uint32, editor Identity) (IIdentity, error)
|
||||
AddIdentityObject(identity IIdentity, editor Identity) (IIdentity, error)
|
||||
|
|
|
@ -70,7 +70,7 @@ type (
|
|||
Webfinger(resource string, editor Identity) (IWebfingerResult, error)
|
||||
GetPackages(editor Identity) (IGetPackagesResult, error)
|
||||
GetActor(username string, editor Identity) (IGetActorResult, error)
|
||||
FollowActor(username string, acct string, editor Identity) (IFollowActorResult, error)
|
||||
FollowActor(username string, account string, editor Identity) (IFollowActorResult, error)
|
||||
AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error)
|
||||
GetFollowers(username string, editor Identity) (IGetFollowersResult, error)
|
||||
GetFollowing(username string, editor Identity) (IGetFollowingResult, error)
|
||||
|
@ -167,7 +167,6 @@ type (
|
|||
}
|
||||
|
||||
IFollowActorResult interface {
|
||||
Url() string
|
||||
}
|
||||
|
||||
IAuthorizeInteractionResult interface {
|
||||
|
|
|
@ -60,6 +60,7 @@ type (
|
|||
IdentityExists(id int64) bool
|
||||
ListIdentities(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IIdentityCollection
|
||||
GetIdentity(id int64, editor Identity) (IIdentity, error)
|
||||
GetIdentityByUsername(username string, editor Identity) (IIdentity, error)
|
||||
AddIdentity(username string, phoneNumber string, phoneNumberConfirmed bool, firstName string, lastName string, displayName string, email string, emailConfirmed bool, avatar string, banner string, summary string, token string, multiFactor bool, hash string, salt string, publicKey string, privateKey string, permission uint64, restriction uint32, lastLogin int64, loginCount uint32, editor Identity) (IIdentity, error)
|
||||
AddIdentityAtomic(transaction ITransaction, username string, phoneNumber string, phoneNumberConfirmed bool, firstName string, lastName string, displayName string, email string, emailConfirmed bool, avatar string, banner string, summary string, token string, multiFactor bool, hash string, salt string, publicKey string, privateKey string, permission uint64, restriction uint32, lastLogin int64, loginCount uint32, editor Identity) (IIdentity, error)
|
||||
LogIdentity(username string, phoneNumber string, phoneNumberConfirmed bool, firstName string, lastName string, displayName string, email string, emailConfirmed bool, avatar string, banner string, summary string, token string, multiFactor bool, hash string, salt string, publicKey string, privateKey string, permission uint64, restriction uint32, lastLogin int64, loginCount uint32, source string, editor Identity, payload string)
|
||||
|
@ -272,7 +273,7 @@ type (
|
|||
Webfinger(resource string, editor Identity) (IWebfingerResult, error)
|
||||
GetPackages(editor Identity) (IGetPackagesResult, error)
|
||||
GetActor(username string, editor Identity) (IGetActorResult, error)
|
||||
FollowActor(username string, acct string, editor Identity) (IFollowActorResult, error)
|
||||
FollowActor(username string, account string, editor Identity) (IFollowActorResult, error)
|
||||
AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error)
|
||||
GetFollowers(username string, editor Identity) (IGetFollowersResult, error)
|
||||
GetFollowing(username string, editor Identity) (IGetFollowingResult, error)
|
||||
|
@ -313,7 +314,7 @@ type (
|
|||
NewWebfingerResult(aliases []string, links []IActivityPubLink, subject string, ignored interface{}) IWebfingerResult
|
||||
NewGetPackagesResult(body []byte, ignored interface{}) IGetPackagesResult
|
||||
NewGetActorResult(context []string, id string, followers string, following string, inbox string, outbox string, name string, preferredUsername string, type_ string, url string, icon IActivityPubMedia, image IActivityPubMedia, publicKey IActivityPubPublicKey, summary string, published string, ignored interface{}) IGetActorResult
|
||||
NewFollowActorResult(url string, ignored interface{}) IFollowActorResult
|
||||
NewFollowActorResult(ignored interface{}) IFollowActorResult
|
||||
NewAuthorizeInteractionResult(uri string, success bool, ignored interface{}) IAuthorizeInteractionResult
|
||||
NewGetFollowersResult(context string, id string, type_ string, totalItems int32, orderedItems []string, first string, ignored interface{}) IGetFollowersResult
|
||||
NewGetFollowingResult(context string, id string, type_ string, totalItems int32, orderedItems []string, first string, ignored interface{}) IGetFollowingResult
|
||||
|
|
|
@ -2,6 +2,7 @@ package contracts
|
|||
|
||||
import (
|
||||
"github.com/go-ap/activitypub"
|
||||
. "github.com/xeronith/diamante/contracts/federation"
|
||||
. "github.com/xeronith/diamante/contracts/logging"
|
||||
. "github.com/xeronith/diamante/contracts/security"
|
||||
. "github.com/xeronith/diamante/contracts/settings"
|
||||
|
@ -164,6 +165,8 @@ type IDispatcher interface {
|
|||
// GetIdentity finds a specific 'Identity' instance using
|
||||
// the provided unique identifier or 'Id'.
|
||||
GetIdentity(id int64) IIdentity
|
||||
// GetIdentityByUsername finds a specific 'Identity' instance using the provided username.
|
||||
GetIdentityByUsername(username string) IIdentity
|
||||
// AddIdentity creates a new 'Identity' instance with an auto-generated unique identifier using the
|
||||
// provided property values and adds it to persistent data store and system cache.
|
||||
// The method is smart enough to respect the transaction if used in an
|
||||
|
@ -1047,7 +1050,7 @@ type IDispatcher interface {
|
|||
Webfinger(resource string) (IWebfingerResult, error)
|
||||
GetPackages() (IGetPackagesResult, error)
|
||||
GetActor(username string) (IGetActorResult, error)
|
||||
FollowActor(username string, acct string) (IFollowActorResult, error)
|
||||
FollowActor(username string, account string) (IFollowActorResult, error)
|
||||
AuthorizeInteraction(uri string) (IAuthorizeInteractionResult, error)
|
||||
GetFollowers(username string) (IGetFollowersResult, error)
|
||||
GetFollowing(username string) (IGetFollowingResult, error)
|
||||
|
@ -1155,7 +1158,7 @@ type IDispatcher interface {
|
|||
// NewGetActorResult creates a new result container for 'Get Actor' system action.
|
||||
NewGetActorResult(context []string, id string, followers string, following string, inbox string, outbox string, name string, preferredUsername string, type_ string, url string, icon IActivityPubMedia, image IActivityPubMedia, publicKey IActivityPubPublicKey, summary string, published string) IGetActorResult
|
||||
// NewFollowActorResult creates a new result container for 'Follow Actor' system action.
|
||||
NewFollowActorResult(url string) IFollowActorResult
|
||||
NewFollowActorResult() IFollowActorResult
|
||||
// NewAuthorizeInteractionResult creates a new result container for 'Authorize Interaction' system action.
|
||||
NewAuthorizeInteractionResult(uri string, success bool) IAuthorizeInteractionResult
|
||||
// NewGetFollowersResult creates a new result container for 'Get Followers' system action.
|
||||
|
@ -1186,6 +1189,12 @@ type IDispatcher interface {
|
|||
AssertNotEmpty(input string) IAssertionResult
|
||||
// Format provides a wrapper around fmt.Sprintf
|
||||
Format(format string, args ...interface{}) string
|
||||
// ReplaceAll returns a copy of the input string with all
|
||||
// non-overlapping instances of old replaced by new.
|
||||
// If old is empty, it matches at the beginning of the string
|
||||
// and after each UTF-8 sequence, yielding up to k+1 replacements
|
||||
// for a k-rune string.
|
||||
ReplaceAll(input, old, new string) string
|
||||
// Sort sorts the provided slice using the provided comparator function.
|
||||
Sort(slice interface{}, less func(x, y int) bool)
|
||||
// Search searches the input for any or all of the words in criteria.
|
||||
|
@ -1249,11 +1258,14 @@ type IDispatcher interface {
|
|||
IsStagingEnvironment() bool
|
||||
IsProductionEnvironment() bool
|
||||
|
||||
GetActorId() string
|
||||
GetActivityStream(url string, input, output interface{}) error
|
||||
PostActivityStream(url string, input, output interface{}) error
|
||||
GetActivityStreamSigned(url string, input, output interface{}) error
|
||||
PostActivityStreamSigned(url string, input, output interface{}) error
|
||||
GetActorId(Identity) string
|
||||
GetPublicKeyId(Identity) string
|
||||
GetActivityStream(url string, output interface{}) error
|
||||
PostActivityStream(url string, input interface{}) error
|
||||
GetSignedActivityStream(url string, output interface{}, identity Identity) error
|
||||
PostSignedActivityStream(url string, input interface{}, identity Identity) error
|
||||
UnmarshalActivityPubObjectOrLink([]byte) activitypub.ObjectOrLink
|
||||
UnmarshalActivityPubNote([]byte) *activitypub.Note
|
||||
|
||||
ResolveWebfinger(account string) (IWebfinger, error)
|
||||
}
|
||||
|
|
|
@ -760,6 +760,13 @@ func (dispatcher *dispatcher) GetIdentity(id int64) IIdentity {
|
|||
}
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) GetIdentityByUsername(username string) IIdentity {
|
||||
if identity, err := dispatcher.conductor.IdentityManager().GetIdentityByUsername(username, dispatcher.identity); err != nil {
|
||||
panic(err.Error())
|
||||
} else {
|
||||
return identity
|
||||
}
|
||||
}
|
||||
func (dispatcher *dispatcher) AddIdentity(username string, phoneNumber string, phoneNumberConfirmed bool, firstName string, lastName string, displayName string, email string, emailConfirmed bool, avatar string, banner string, summary string, token string, multiFactor bool, hash string, salt string, publicKey string, privateKey string, permission uint64, restriction uint32, lastLogin int64, loginCount uint32) IIdentity {
|
||||
transaction := dispatcher.transaction
|
||||
if transaction != nil {
|
||||
|
|
|
@ -101,6 +101,14 @@ func (manager *identityManager) GetIdentity(id int64, _ Identity) (IIdentity, er
|
|||
}
|
||||
}
|
||||
|
||||
func (manager *identityManager) GetIdentityByUsername(username string, _ Identity) (IIdentity, error) {
|
||||
if object, exists := manager.cache.GetByUsername(username); !exists {
|
||||
return nil, ERROR_IDENTITY_NOT_FOUND
|
||||
} else {
|
||||
return object.(IIdentity), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (manager *identityManager) AddIdentity(username string, phoneNumber string, phoneNumberConfirmed bool, firstName string, lastName string, displayName string, email string, emailConfirmed bool, avatar string, banner string, summary string, token string, multiFactor bool, hash string, salt string, publicKey string, privateKey string, permission uint64, restriction uint32, lastLogin int64, loginCount uint32, editor Identity) (IIdentity, error) {
|
||||
identityEntity := NewIdentityEntity(manager.UniqueId(), username, phoneNumber, phoneNumberConfirmed, firstName, lastName, displayName, email, emailConfirmed, avatar, banner, summary, token, multiFactor, hash, salt, publicKey, privateKey, permission, restriction, lastLogin, loginCount)
|
||||
return manager.Apply(identityEntity, repository.Identities.Add, manager.cache.Put, editor)
|
||||
|
|
|
@ -402,6 +402,10 @@ func (conductor *conductor) GetIdentity(id int64, editor Identity) (IIdentity, e
|
|||
return conductor.identityManager.GetIdentity(id, editor)
|
||||
}
|
||||
|
||||
func (conductor *conductor) GetIdentityByUsername(username string, editor Identity) (IIdentity, error) {
|
||||
return conductor.identityManager.GetIdentityByUsername(username, editor)
|
||||
}
|
||||
|
||||
func (conductor *conductor) AddIdentity(username string, phoneNumber string, phoneNumberConfirmed bool, firstName string, lastName string, displayName string, email string, emailConfirmed bool, avatar string, banner string, summary string, token string, multiFactor bool, hash string, salt string, publicKey string, privateKey string, permission uint64, restriction uint32, lastLogin int64, loginCount uint32, editor Identity) (IIdentity, error) {
|
||||
return conductor.identityManager.AddIdentity(username, phoneNumber, phoneNumberConfirmed, firstName, lastName, displayName, email, emailConfirmed, avatar, banner, summary, token, multiFactor, hash, salt, publicKey, privateKey, permission, restriction, lastLogin, loginCount, editor)
|
||||
}
|
||||
|
@ -1166,8 +1170,8 @@ func (conductor *conductor) GetActor(username string, editor Identity) (IGetActo
|
|||
return conductor.spiManager.GetActor(username, editor)
|
||||
}
|
||||
|
||||
func (conductor *conductor) FollowActor(username string, acct string, editor Identity) (IFollowActorResult, error) {
|
||||
return conductor.spiManager.FollowActor(username, acct, editor)
|
||||
func (conductor *conductor) FollowActor(username string, account string, editor Identity) (IFollowActorResult, error) {
|
||||
return conductor.spiManager.FollowActor(username, account, editor)
|
||||
}
|
||||
|
||||
func (conductor *conductor) AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error) {
|
||||
|
@ -1326,8 +1330,8 @@ func (conductor *conductor) NewGetActorResult(context []string, id string, follo
|
|||
return NewGetActorResult(context, id, followers, following, inbox, outbox, name, preferredUsername, type_, url, icon, image, publicKey, summary, published, nil)
|
||||
}
|
||||
|
||||
func (conductor *conductor) NewFollowActorResult(url string, _ interface{}) IFollowActorResult {
|
||||
return NewFollowActorResult(url, nil)
|
||||
func (conductor *conductor) NewFollowActorResult(_ interface{}) IFollowActorResult {
|
||||
return NewFollowActorResult(nil)
|
||||
}
|
||||
|
||||
func (conductor *conductor) NewAuthorizeInteractionResult(uri string, success bool, _ interface{}) IAuthorizeInteractionResult {
|
||||
|
|
|
@ -300,8 +300,8 @@ func (dispatcher *dispatcher) GetActor(username string) (IGetActorResult, error)
|
|||
return dispatcher.conductor.SpiManager().GetActor(username, dispatcher.identity)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) FollowActor(username string, acct string) (IFollowActorResult, error) {
|
||||
return dispatcher.conductor.SpiManager().FollowActor(username, acct, dispatcher.identity)
|
||||
func (dispatcher *dispatcher) FollowActor(username string, account string) (IFollowActorResult, error) {
|
||||
return dispatcher.conductor.SpiManager().FollowActor(username, account, dispatcher.identity)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) AuthorizeInteraction(uri string) (IAuthorizeInteractionResult, error) {
|
||||
|
|
|
@ -933,22 +933,15 @@ func (manager *spiManager) GetActor(username string, editor Identity) (result IG
|
|||
//region IFollowActorResult Implementation
|
||||
|
||||
type followActorResult struct {
|
||||
url string
|
||||
}
|
||||
|
||||
func NewFollowActorResult(url string, _ interface{}) IFollowActorResult {
|
||||
return &followActorResult{
|
||||
url: url,
|
||||
}
|
||||
}
|
||||
|
||||
func (result followActorResult) Url() string {
|
||||
return result.url
|
||||
func NewFollowActorResult(_ interface{}) IFollowActorResult {
|
||||
return &followActorResult{}
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
func (manager *spiManager) FollowActor(username string, acct string, editor Identity) (result IFollowActorResult, err error) {
|
||||
func (manager *spiManager) FollowActor(username string, account string, editor Identity) (result IFollowActorResult, err error) {
|
||||
defer func() {
|
||||
if reason := recover(); reason != nil {
|
||||
err = manager.Error(reason)
|
||||
|
@ -959,7 +952,7 @@ func (manager *spiManager) FollowActor(username string, acct string, editor Iden
|
|||
defer editor.Unlock(FOLLOW_ACTOR_REQUEST)
|
||||
|
||||
dispatcher := NewDispatcher(Conductor, editor)
|
||||
if result, err = commands.FollowActor(dispatcher, username, acct); err != nil {
|
||||
if result, err = commands.FollowActor(dispatcher, username, account); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ func TestSpiManager_GetActor(test *testing.T) {
|
|||
func TestSpiManager_FollowActor(test *testing.T) {
|
||||
manager := Conductor.SpiManager()
|
||||
|
||||
result, err := manager.FollowActor("username", "acct", nil)
|
||||
result, err := manager.FollowActor("username", "account", nil)
|
||||
if err != nil {
|
||||
test.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package core
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
@ -14,9 +15,11 @@ import (
|
|||
"github.com/mitchellh/mapstructure"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
"github.com/valyala/fastjson"
|
||||
. "github.com/xeronith/diamante/contracts/federation"
|
||||
. "github.com/xeronith/diamante/contracts/logging"
|
||||
. "github.com/xeronith/diamante/contracts/security"
|
||||
. "github.com/xeronith/diamante/contracts/settings"
|
||||
"github.com/xeronith/diamante/federation"
|
||||
"github.com/xeronith/diamante/utility/search"
|
||||
)
|
||||
|
||||
|
@ -229,6 +232,10 @@ func (dispatcher *dispatcher) Format(format string, args ...interface{}) string
|
|||
return fmt.Sprintf(format, args...)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) ReplaceAll(input, old, new string) string {
|
||||
return strings.ReplaceAll(input, old, new)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) Sort(slice interface{}, less func(x, y int) bool) {
|
||||
sort.Slice(slice, less)
|
||||
}
|
||||
|
@ -356,34 +363,32 @@ func (dispatcher *dispatcher) IsProductionEnvironment() bool {
|
|||
return dispatcher.conductor.IdentityManager().IsProductionEnvironment()
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) GetActorId() string {
|
||||
func (dispatcher *dispatcher) GetActorId(identity Identity) string {
|
||||
config := dispatcher.conductor.Configuration().GetServerConfiguration()
|
||||
return fmt.Sprintf("%s://%s/u/%s", config.GetProtocol(), config.GetFQDN(), dispatcher.identity.Username())
|
||||
return fmt.Sprintf("%s://%s/users/%s", config.GetProtocol(), config.GetFQDN(), identity.Username())
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) GetPublicKeyId(identity Identity) string {
|
||||
config := dispatcher.conductor.Configuration().GetServerConfiguration()
|
||||
return fmt.Sprintf("%s://%s/u/%s#main-key", config.GetProtocol(), config.GetFQDN(), identity.Username())
|
||||
return fmt.Sprintf("%s://%s/users/%s#main-key", config.GetProtocol(), config.GetFQDN(), identity.Username())
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) GetActivityStream(url string, input, output interface{}) error {
|
||||
return dispatcher.conductor.RequestActivityStream(http.MethodGet, url, "", "", input, output)
|
||||
func (dispatcher *dispatcher) GetActivityStream(url string, output interface{}) error {
|
||||
return dispatcher.conductor.RequestActivityStream(http.MethodGet, url, "", "", nil, output)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) PostActivityStream(url string, input, output interface{}) error {
|
||||
return dispatcher.conductor.RequestActivityStream(http.MethodPost, url, "", "", input, output)
|
||||
func (dispatcher *dispatcher) PostActivityStream(url string, input interface{}) error {
|
||||
return dispatcher.conductor.RequestActivityStream(http.MethodPost, url, "", "", input, nil)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) GetActivityStreamSigned(url string, input, output interface{}) error {
|
||||
identity := dispatcher.identity
|
||||
func (dispatcher *dispatcher) GetSignedActivityStream(url string, output interface{}, identity Identity) error {
|
||||
keyId := dispatcher.GetPublicKeyId(identity)
|
||||
return dispatcher.conductor.RequestActivityStream(http.MethodGet, url, keyId, identity.PrivateKey(), input, output)
|
||||
return dispatcher.conductor.RequestActivityStream(http.MethodGet, url, keyId, identity.PrivateKey(), nil, output)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) PostActivityStreamSigned(url string, input, output interface{}) error {
|
||||
identity := dispatcher.identity
|
||||
func (dispatcher *dispatcher) PostSignedActivityStream(url string, input interface{}, identity Identity) error {
|
||||
keyId := dispatcher.GetPublicKeyId(identity)
|
||||
return dispatcher.conductor.RequestActivityStream(http.MethodPost, url, keyId, identity.PrivateKey(), input, output)
|
||||
return dispatcher.conductor.RequestActivityStream(http.MethodPost, url, keyId, identity.PrivateKey(), input, nil)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) UnmarshalActivityPubObjectOrLink(data []byte) activitypub.ObjectOrLink {
|
||||
|
@ -405,4 +410,31 @@ func (dispatcher *dispatcher) UnmarshalActivityPubNote(data []byte) *activitypub
|
|||
return note
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) ResolveWebfinger(account string) (IWebfinger, error) {
|
||||
parts := strings.Split(account, "@")
|
||||
if len(parts) != 2 {
|
||||
return nil, fmt.Errorf("invalid_account")
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("https://%s/.well-known/webfinger?resource=acct:%s", parts[1], account)
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
data, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
webfinger := federation.NewWebfinger()
|
||||
if err := webfinger.Unmarshal(data); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return webfinger, nil
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
|
|
@ -64,8 +64,8 @@ func (dispatcher *dispatcher) NewGetActorResult(context []string, id string, fol
|
|||
return NewGetActorResult(context, id, followers, following, inbox, outbox, name, preferredUsername, type_, url, icon, image, publicKey, summary, published, nil)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) NewFollowActorResult(url string) IFollowActorResult {
|
||||
return NewFollowActorResult(url, nil)
|
||||
func (dispatcher *dispatcher) NewFollowActorResult() IFollowActorResult {
|
||||
return NewFollowActorResult(nil)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) NewAuthorizeInteractionResult(uri string, success bool) IAuthorizeInteractionResult {
|
||||
|
|
Ładowanie…
Reference in New Issue