kopia lustrzana https://github.com/reiver/greatape
refactor(project): 🧱 improve federation
rodzic
c733122af1
commit
c9addad9ad
|
@ -1,85 +1,61 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/reiver/greatape/app/activitypub"
|
"github.com/reiver/greatape/app/activitypub"
|
||||||
. "github.com/reiver/greatape/components/constants"
|
|
||||||
. "github.com/reiver/greatape/components/contracts"
|
. "github.com/reiver/greatape/components/contracts"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FollowActor(x IDispatcher, username string, acct string) (IFollowActorResult, error) {
|
func FollowActor(x IDispatcher, username string, account string) (IFollowActorResult, error) {
|
||||||
parts := strings.Split(acct, "@")
|
webfinger, err := x.ResolveWebfinger(account)
|
||||||
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)
|
|
||||||
x.AssertNoError(err)
|
x.AssertNoError(err)
|
||||||
|
|
||||||
data, err := io.ReadAll(resp.Body)
|
identity := x.GetIdentityByUsername(username)
|
||||||
x.AssertNoError(err)
|
follower := x.GetActorId(identity)
|
||||||
|
|
||||||
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()
|
|
||||||
|
|
||||||
followee := &activitypub.Actor{}
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
uniqueIdentifier := x.GenerateUUID()
|
followers := x.FilterActivityPubFollowers(func(follow IActivityPubFollower) bool {
|
||||||
follow := activitypub.NewFollow(follower, followee.ID, uniqueIdentifier)
|
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 {
|
x.Atomic(func() error {
|
||||||
activity := x.MarshalJson(follow)
|
if followers.IsEmpty() {
|
||||||
|
activity := x.MarshalJson(follow)
|
||||||
|
|
||||||
x.AddActivityPubOutgoingActivity(
|
x.AddActivityPubOutgoingActivity(
|
||||||
identity.Id(),
|
identity.Id(),
|
||||||
uniqueIdentifier,
|
follow.UniqueIdentifier,
|
||||||
x.UnixNano(),
|
x.UnixNano(),
|
||||||
follower,
|
follower,
|
||||||
followee.ID,
|
followee.Id,
|
||||||
activitypub.TypeFollow,
|
activitypub.TypeFollow,
|
||||||
activity,
|
activity,
|
||||||
)
|
)
|
||||||
|
|
||||||
x.AddActivityPubFollower(
|
x.AddActivityPubFollower(
|
||||||
follower,
|
follower,
|
||||||
followee.Inbox,
|
followee.Inbox,
|
||||||
followee.ID,
|
followee.Id,
|
||||||
activity,
|
activity,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if err := x.PostActivityStreamSigned(followee.Inbox, follow, nil); err != nil {
|
if err := x.PostSignedActivityStream(followee.Inbox, follow, identity); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
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) {
|
func PostToInbox(x IDispatcher, username string, body []byte) (IPostToInboxResult, error) {
|
||||||
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
identity := x.GetIdentityByUsername(username)
|
||||||
return identity.Username() == username
|
object := x.UnmarshalActivityPubObjectOrLink(body)
|
||||||
})
|
|
||||||
|
|
||||||
x.Assert(identities.HasExactlyOneItem()).Or(ERROR_USER_NOT_FOUND)
|
switch object.GetType() {
|
||||||
identity := identities.First()
|
|
||||||
|
|
||||||
object := &activitypub.Object{}
|
|
||||||
x.UnmarshalJson(body, object)
|
|
||||||
|
|
||||||
switch object.Type {
|
|
||||||
case activitypub.TypeAccept:
|
case activitypub.TypeAccept:
|
||||||
{
|
{
|
||||||
activity := &activitypub.Activity{}
|
activity := &activitypub.Activity{}
|
||||||
|
@ -57,17 +50,17 @@ func PostToInbox(x IDispatcher, username string, body []byte) (IPostToInboxResul
|
||||||
follow := &activitypub.Follow{}
|
follow := &activitypub.Follow{}
|
||||||
x.UnmarshalJson(body, follow)
|
x.UnmarshalJson(body, follow)
|
||||||
|
|
||||||
url := follow.Actor
|
actorId := x.GetActorId(identity)
|
||||||
|
|
||||||
actor := &activitypub.Actor{}
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
follower := x.AddActivityPubFollower(
|
follower := x.AddActivityPubFollower(
|
||||||
follow.Actor,
|
follow.Actor,
|
||||||
actor.Inbox,
|
actor.Inbox,
|
||||||
x.Format("%s/u/%s", x.PublicUrl(), username),
|
actorId,
|
||||||
x.MarshalJson(follow),
|
x.MarshalJson(follow),
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
@ -76,11 +69,11 @@ func PostToInbox(x IDispatcher, username string, body []byte) (IPostToInboxResul
|
||||||
Context: activitypub.ActivityStreams,
|
Context: activitypub.ActivityStreams,
|
||||||
ID: x.Format("%s/%s", x.PublicUrl(), x.GenerateUUID()),
|
ID: x.Format("%s/%s", x.PublicUrl(), x.GenerateUUID()),
|
||||||
Type: activitypub.TypeAccept,
|
Type: activitypub.TypeAccept,
|
||||||
Actor: x.Format("%s/u/%s", x.PublicUrl(), username),
|
Actor: actorId,
|
||||||
Object: follow,
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,37 +1,27 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
ap "github.com/go-ap/activitypub"
|
||||||
"github.com/reiver/greatape/app/activitypub"
|
"github.com/reiver/greatape/app/activitypub"
|
||||||
. "github.com/reiver/greatape/components/constants"
|
. "github.com/reiver/greatape/components/constants"
|
||||||
. "github.com/reiver/greatape/components/contracts"
|
. "github.com/reiver/greatape/components/contracts"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PostToOutbox(x IDispatcher, username string, body []byte) (IPostToOutboxResult, error) {
|
func PostToOutbox(x IDispatcher, username string, body []byte) (IPostToOutboxResult, error) {
|
||||||
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
identity := x.GetIdentityByUsername(username)
|
||||||
return identity.Username() == username
|
object := x.UnmarshalActivityPubObjectOrLink(body)
|
||||||
})
|
|
||||||
|
|
||||||
x.Assert(identities.HasExactlyOneItem()).Or(ERROR_USER_NOT_FOUND)
|
switch object.GetType() {
|
||||||
identity := identities.First()
|
|
||||||
|
|
||||||
item := x.UnmarshalActivityPubObjectOrLink(body)
|
|
||||||
|
|
||||||
actorId := x.GetActorId()
|
|
||||||
|
|
||||||
switch item.GetType() {
|
|
||||||
case activitypub.TypeNote:
|
case activitypub.TypeNote:
|
||||||
{
|
{
|
||||||
note, err := activitypub.UnmarshalNote(body)
|
note := object.(*ap.Note)
|
||||||
if err != nil {
|
|
||||||
return nil, ERROR_INVALID_PARAMETERS
|
|
||||||
}
|
|
||||||
|
|
||||||
content := note.Content
|
actorId := x.GetActorId(identity)
|
||||||
to := note.To[0]
|
content := note.Content.First().String()
|
||||||
from := note.AttributedTo
|
to := note.To[0].GetID().String()
|
||||||
|
from := note.AttributedTo.GetID().String()
|
||||||
|
|
||||||
if from != actorId {
|
if from != actorId {
|
||||||
return nil, ERROR_INVALID_PARAMETERS
|
return nil, ERROR_INVALID_PARAMETERS
|
||||||
|
@ -42,22 +32,22 @@ func PostToOutbox(x IDispatcher, username string, body []byte) (IPostToOutboxRes
|
||||||
activity := &activitypub.Activity{
|
activity := &activitypub.Activity{
|
||||||
Context: activitypub.ActivityStreams,
|
Context: activitypub.ActivityStreams,
|
||||||
Type: activitypub.TypeCreate,
|
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,
|
To: note.To,
|
||||||
Actor: fmt.Sprintf("%s/u/%s", x.PublicUrl(), username),
|
Actor: actorId,
|
||||||
Published: time.Now(),
|
Published: time.Now(),
|
||||||
Object: note,
|
Object: note,
|
||||||
}
|
}
|
||||||
|
|
||||||
if to != ACTIVITY_PUB_PUBLIC {
|
if to != ACTIVITY_PUB_PUBLIC {
|
||||||
recipient := &activitypub.Actor{}
|
recipient := &activitypub.Actor{}
|
||||||
if err := x.GetActivityStreamSigned(to, nil, recipient); err != nil {
|
if err := x.GetSignedActivityStream(to, recipient, identity); err != nil {
|
||||||
return nil, err
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ func TestGetActorApi(test *testing.T) {
|
||||||
func TestFollowActorApi(test *testing.T) {
|
func TestFollowActorApi(test *testing.T) {
|
||||||
input := &FollowActorRequest{
|
input := &FollowActorRequest{
|
||||||
Username: "username",
|
Username: "username",
|
||||||
Acct: "acct",
|
Account: "account",
|
||||||
}
|
}
|
||||||
|
|
||||||
if output, err := api.FollowActor(input); err != nil {
|
if output, err := api.FollowActor(input); err != nil {
|
||||||
|
|
|
@ -1804,7 +1804,7 @@ type FollowActorRequest struct {
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
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() {
|
func (x *FollowActorRequest) Reset() {
|
||||||
|
@ -1846,9 +1846,9 @@ func (x *FollowActorRequest) GetUsername() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FollowActorRequest) GetAcct() string {
|
func (x *FollowActorRequest) GetAccount() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Acct
|
return x.Account
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -1857,8 +1857,6 @@ type FollowActorResult struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FollowActorResult) Reset() {
|
func (x *FollowActorResult) Reset() {
|
||||||
|
@ -1893,13 +1891,6 @@ func (*FollowActorResult) Descriptor() ([]byte, []int) {
|
||||||
return file_spis_proto_rawDescGZIP(), []int{33}
|
return file_spis_proto_rawDescGZIP(), []int{33}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *FollowActorResult) GetUrl() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Url
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
// API: AuthorizeInteraction
|
// API: AuthorizeInteraction
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
type AuthorizeInteractionRequest struct {
|
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,
|
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,
|
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,
|
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,
|
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,
|
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,
|
0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61,
|
||||||
0x63, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x63, 0x63, 0x74, 0x22,
|
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63,
|
||||||
0x25, 0x0a, 0x11, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x41, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x65,
|
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13, 0x0a, 0x11, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x41,
|
||||||
0x73, 0x75, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28,
|
0x63, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x2f, 0x0a, 0x1b, 0x41, 0x75,
|
||||||
0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x2f, 0x0a, 0x1b, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72,
|
0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x61, 0x63, 0x74, 0x69,
|
||||||
0x69, 0x7a, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
|
0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69,
|
||||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x01, 0x20, 0x01,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x22, 0x48, 0x0a, 0x1a, 0x41,
|
||||||
0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x22, 0x48, 0x0a, 0x1a, 0x41, 0x75, 0x74, 0x68, 0x6f,
|
0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x61, 0x63, 0x74,
|
||||||
0x72, 0x69, 0x7a, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52,
|
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69,
|
||||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x69, 0x18, 0x01, 0x20, 0x01,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x18, 0x0a, 0x07, 0x73,
|
||||||
0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65,
|
0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75,
|
||||||
0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73,
|
0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x31, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c,
|
||||||
0x73, 0x22, 0x31, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72,
|
0x6f, 0x77, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08,
|
||||||
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72,
|
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
|
||||||
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72,
|
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74,
|
||||||
0x6e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c,
|
0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12,
|
||||||
0x6f, 0x77, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63,
|
0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63,
|
0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
|
||||||
0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
|
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79,
|
||||||
0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03,
|
0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f,
|
0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01,
|
||||||
0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
|
0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x22,
|
||||||
0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72,
|
0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05,
|
||||||
0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09,
|
0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65,
|
||||||
0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x14,
|
0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28,
|
||||||
0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66,
|
0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x31, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46,
|
||||||
0x69, 0x72, 0x73, 0x74, 0x22, 0x31, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c, 0x6f,
|
0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
||||||
0x77, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75,
|
0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75,
|
0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x12,
|
||||||
0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xad, 0x01, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x46,
|
0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x75,
|
||||||
0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19,
|
0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20,
|
||||||
0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a,
|
||||||
0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
|
0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a,
|
||||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70,
|
||||||
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a,
|
0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18,
|
||||||
0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28,
|
0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d,
|
||||||
0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x22, 0x0a,
|
0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d,
|
||||||
0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20,
|
0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64,
|
||||||
0x03, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d,
|
0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06,
|
||||||
0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09,
|
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x45, 0x0a, 0x13, 0x50,
|
||||||
0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x45, 0x0a, 0x13, 0x50, 0x6f, 0x73, 0x74, 0x54,
|
0x6f, 0x73, 0x74, 0x54, 0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||||
0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a,
|
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,
|
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,
|
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,
|
0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x27,
|
||||||
0x0a, 0x12, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65,
|
0x0a, 0x11, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73,
|
||||||
0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01,
|
0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||||
0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2e, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x4f,
|
0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e,
|
||||||
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,
|
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, 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,
|
0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x49, 0x6e,
|
||||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x27, 0x0a, 0x11, 0x50, 0x6f,
|
0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e,
|
||||||
0x73, 0x74, 0x54, 0x6f, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12,
|
0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e,
|
||||||
0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62,
|
0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52,
|
0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01,
|
||||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61,
|
0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61,
|
||||||
0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61,
|
0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f,
|
||||||
0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52,
|
0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x41, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65,
|
||||||
0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d,
|
||||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69,
|
||||||
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64,
|
0x74, 0x79, 0x50, 0x75, 0x62, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x6f,
|
||||||
0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66,
|
||||||
0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65,
|
0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73,
|
||||||
0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49,
|
0x74, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
|
||||||
0x74, 0x65, 0x6d, 0x73, 0x12, 0x41, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49,
|
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
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 (
|
var (
|
||||||
|
|
|
@ -201,11 +201,10 @@ message GetActorResult {
|
||||||
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
||||||
message FollowActorRequest {
|
message FollowActorRequest {
|
||||||
string username = 0x00000001;
|
string username = 0x00000001;
|
||||||
string acct = 0x00000002;
|
string account = 0x00000002;
|
||||||
}
|
}
|
||||||
|
|
||||||
message FollowActorResult {
|
message FollowActorResult {
|
||||||
string url = 0x00000001;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// API: AuthorizeInteraction
|
// API: AuthorizeInteraction
|
||||||
|
|
|
@ -12,12 +12,10 @@ func FollowActorService(context IContext, input *FollowActorRequest) (result *Fo
|
||||||
/* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err)
|
/* //////// */ Conductor.LogRemoteCall(context, INIT, source, input, result, err)
|
||||||
defer func() { Conductor.LogRemoteCall(context, DONE, 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 = Conductor.FollowActor(input.Username, input.Account, context.Identity()); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result = context.ResultContainer().(*FollowActorResult)
|
result = context.ResultContainer().(*FollowActorResult)
|
||||||
result.Url = commandResult.Url()
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,7 @@ type (
|
||||||
ExistsWhich(condition IdentityCondition) bool
|
ExistsWhich(condition IdentityCondition) bool
|
||||||
ListIdentities(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IIdentityCollection
|
ListIdentities(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IIdentityCollection
|
||||||
GetIdentity(id int64, editor Identity) (IIdentity, error)
|
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)
|
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)
|
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)
|
AddIdentityObject(identity IIdentity, editor Identity) (IIdentity, error)
|
||||||
|
|
|
@ -70,7 +70,7 @@ type (
|
||||||
Webfinger(resource string, editor Identity) (IWebfingerResult, error)
|
Webfinger(resource string, editor Identity) (IWebfingerResult, error)
|
||||||
GetPackages(editor Identity) (IGetPackagesResult, error)
|
GetPackages(editor Identity) (IGetPackagesResult, error)
|
||||||
GetActor(username string, editor Identity) (IGetActorResult, 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)
|
AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error)
|
||||||
GetFollowers(username string, editor Identity) (IGetFollowersResult, error)
|
GetFollowers(username string, editor Identity) (IGetFollowersResult, error)
|
||||||
GetFollowing(username string, editor Identity) (IGetFollowingResult, error)
|
GetFollowing(username string, editor Identity) (IGetFollowingResult, error)
|
||||||
|
@ -167,7 +167,6 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
IFollowActorResult interface {
|
IFollowActorResult interface {
|
||||||
Url() string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IAuthorizeInteractionResult interface {
|
IAuthorizeInteractionResult interface {
|
||||||
|
|
|
@ -60,6 +60,7 @@ type (
|
||||||
IdentityExists(id int64) bool
|
IdentityExists(id int64) bool
|
||||||
ListIdentities(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IIdentityCollection
|
ListIdentities(pageIndex uint32, pageSize uint32, criteria string, editor Identity) IIdentityCollection
|
||||||
GetIdentity(id int64, editor Identity) (IIdentity, error)
|
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)
|
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)
|
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)
|
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)
|
Webfinger(resource string, editor Identity) (IWebfingerResult, error)
|
||||||
GetPackages(editor Identity) (IGetPackagesResult, error)
|
GetPackages(editor Identity) (IGetPackagesResult, error)
|
||||||
GetActor(username string, editor Identity) (IGetActorResult, 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)
|
AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error)
|
||||||
GetFollowers(username string, editor Identity) (IGetFollowersResult, error)
|
GetFollowers(username string, editor Identity) (IGetFollowersResult, error)
|
||||||
GetFollowing(username string, editor Identity) (IGetFollowingResult, error)
|
GetFollowing(username string, editor Identity) (IGetFollowingResult, error)
|
||||||
|
@ -313,7 +314,7 @@ type (
|
||||||
NewWebfingerResult(aliases []string, links []IActivityPubLink, subject string, ignored interface{}) IWebfingerResult
|
NewWebfingerResult(aliases []string, links []IActivityPubLink, subject string, ignored interface{}) IWebfingerResult
|
||||||
NewGetPackagesResult(body []byte, ignored interface{}) IGetPackagesResult
|
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
|
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
|
NewAuthorizeInteractionResult(uri string, success bool, ignored interface{}) IAuthorizeInteractionResult
|
||||||
NewGetFollowersResult(context string, id string, type_ string, totalItems int32, orderedItems []string, first string, ignored interface{}) IGetFollowersResult
|
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
|
NewGetFollowingResult(context string, id string, type_ string, totalItems int32, orderedItems []string, first string, ignored interface{}) IGetFollowingResult
|
||||||
|
|
|
@ -2,6 +2,7 @@ package contracts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-ap/activitypub"
|
"github.com/go-ap/activitypub"
|
||||||
|
. "github.com/xeronith/diamante/contracts/federation"
|
||||||
. "github.com/xeronith/diamante/contracts/logging"
|
. "github.com/xeronith/diamante/contracts/logging"
|
||||||
. "github.com/xeronith/diamante/contracts/security"
|
. "github.com/xeronith/diamante/contracts/security"
|
||||||
. "github.com/xeronith/diamante/contracts/settings"
|
. "github.com/xeronith/diamante/contracts/settings"
|
||||||
|
@ -164,6 +165,8 @@ type IDispatcher interface {
|
||||||
// GetIdentity finds a specific 'Identity' instance using
|
// GetIdentity finds a specific 'Identity' instance using
|
||||||
// the provided unique identifier or 'Id'.
|
// the provided unique identifier or 'Id'.
|
||||||
GetIdentity(id int64) IIdentity
|
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
|
// 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.
|
// 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
|
// 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)
|
Webfinger(resource string) (IWebfingerResult, error)
|
||||||
GetPackages() (IGetPackagesResult, error)
|
GetPackages() (IGetPackagesResult, error)
|
||||||
GetActor(username string) (IGetActorResult, 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)
|
AuthorizeInteraction(uri string) (IAuthorizeInteractionResult, error)
|
||||||
GetFollowers(username string) (IGetFollowersResult, error)
|
GetFollowers(username string) (IGetFollowersResult, error)
|
||||||
GetFollowing(username string) (IGetFollowingResult, 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 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
|
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 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 creates a new result container for 'Authorize Interaction' system action.
|
||||||
NewAuthorizeInteractionResult(uri string, success bool) IAuthorizeInteractionResult
|
NewAuthorizeInteractionResult(uri string, success bool) IAuthorizeInteractionResult
|
||||||
// NewGetFollowersResult creates a new result container for 'Get Followers' system action.
|
// NewGetFollowersResult creates a new result container for 'Get Followers' system action.
|
||||||
|
@ -1186,6 +1189,12 @@ type IDispatcher interface {
|
||||||
AssertNotEmpty(input string) IAssertionResult
|
AssertNotEmpty(input string) IAssertionResult
|
||||||
// Format provides a wrapper around fmt.Sprintf
|
// Format provides a wrapper around fmt.Sprintf
|
||||||
Format(format string, args ...interface{}) string
|
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 sorts the provided slice using the provided comparator function.
|
||||||
Sort(slice interface{}, less func(x, y int) bool)
|
Sort(slice interface{}, less func(x, y int) bool)
|
||||||
// Search searches the input for any or all of the words in criteria.
|
// Search searches the input for any or all of the words in criteria.
|
||||||
|
@ -1249,11 +1258,14 @@ type IDispatcher interface {
|
||||||
IsStagingEnvironment() bool
|
IsStagingEnvironment() bool
|
||||||
IsProductionEnvironment() bool
|
IsProductionEnvironment() bool
|
||||||
|
|
||||||
GetActorId() string
|
GetActorId(Identity) string
|
||||||
GetActivityStream(url string, input, output interface{}) error
|
GetPublicKeyId(Identity) string
|
||||||
PostActivityStream(url string, input, output interface{}) error
|
GetActivityStream(url string, output interface{}) error
|
||||||
GetActivityStreamSigned(url string, input, output interface{}) error
|
PostActivityStream(url string, input interface{}) error
|
||||||
PostActivityStreamSigned(url string, input, output interface{}) error
|
GetSignedActivityStream(url string, output interface{}, identity Identity) error
|
||||||
|
PostSignedActivityStream(url string, input interface{}, identity Identity) error
|
||||||
UnmarshalActivityPubObjectOrLink([]byte) activitypub.ObjectOrLink
|
UnmarshalActivityPubObjectOrLink([]byte) activitypub.ObjectOrLink
|
||||||
UnmarshalActivityPubNote([]byte) *activitypub.Note
|
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 {
|
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
|
transaction := dispatcher.transaction
|
||||||
if transaction != nil {
|
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) {
|
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)
|
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)
|
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)
|
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) {
|
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)
|
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)
|
return conductor.spiManager.GetActor(username, editor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) FollowActor(username string, acct string, editor Identity) (IFollowActorResult, error) {
|
func (conductor *conductor) FollowActor(username string, account string, editor Identity) (IFollowActorResult, error) {
|
||||||
return conductor.spiManager.FollowActor(username, acct, editor)
|
return conductor.spiManager.FollowActor(username, account, editor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error) {
|
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)
|
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 {
|
func (conductor *conductor) NewFollowActorResult(_ interface{}) IFollowActorResult {
|
||||||
return NewFollowActorResult(url, nil)
|
return NewFollowActorResult(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) NewAuthorizeInteractionResult(uri string, success bool, _ interface{}) IAuthorizeInteractionResult {
|
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)
|
return dispatcher.conductor.SpiManager().GetActor(username, dispatcher.identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) FollowActor(username string, acct string) (IFollowActorResult, error) {
|
func (dispatcher *dispatcher) FollowActor(username string, account string) (IFollowActorResult, error) {
|
||||||
return dispatcher.conductor.SpiManager().FollowActor(username, acct, dispatcher.identity)
|
return dispatcher.conductor.SpiManager().FollowActor(username, account, dispatcher.identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) AuthorizeInteraction(uri string) (IAuthorizeInteractionResult, error) {
|
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
|
//region IFollowActorResult Implementation
|
||||||
|
|
||||||
type followActorResult struct {
|
type followActorResult struct {
|
||||||
url string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFollowActorResult(url string, _ interface{}) IFollowActorResult {
|
func NewFollowActorResult(_ interface{}) IFollowActorResult {
|
||||||
return &followActorResult{
|
return &followActorResult{}
|
||||||
url: url,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (result followActorResult) Url() string {
|
|
||||||
return result.url
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//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() {
|
defer func() {
|
||||||
if reason := recover(); reason != nil {
|
if reason := recover(); reason != nil {
|
||||||
err = manager.Error(reason)
|
err = manager.Error(reason)
|
||||||
|
@ -959,7 +952,7 @@ func (manager *spiManager) FollowActor(username string, acct string, editor Iden
|
||||||
defer editor.Unlock(FOLLOW_ACTOR_REQUEST)
|
defer editor.Unlock(FOLLOW_ACTOR_REQUEST)
|
||||||
|
|
||||||
dispatcher := NewDispatcher(Conductor, editor)
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,7 +317,7 @@ func TestSpiManager_GetActor(test *testing.T) {
|
||||||
func TestSpiManager_FollowActor(test *testing.T) {
|
func TestSpiManager_FollowActor(test *testing.T) {
|
||||||
manager := Conductor.SpiManager()
|
manager := Conductor.SpiManager()
|
||||||
|
|
||||||
result, err := manager.FollowActor("username", "acct", nil)
|
result, err := manager.FollowActor("username", "account", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
test.Fatal(err)
|
test.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package core
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -14,9 +15,11 @@ import (
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
. "github.com/reiver/greatape/components/contracts"
|
. "github.com/reiver/greatape/components/contracts"
|
||||||
"github.com/valyala/fastjson"
|
"github.com/valyala/fastjson"
|
||||||
|
. "github.com/xeronith/diamante/contracts/federation"
|
||||||
. "github.com/xeronith/diamante/contracts/logging"
|
. "github.com/xeronith/diamante/contracts/logging"
|
||||||
. "github.com/xeronith/diamante/contracts/security"
|
. "github.com/xeronith/diamante/contracts/security"
|
||||||
. "github.com/xeronith/diamante/contracts/settings"
|
. "github.com/xeronith/diamante/contracts/settings"
|
||||||
|
"github.com/xeronith/diamante/federation"
|
||||||
"github.com/xeronith/diamante/utility/search"
|
"github.com/xeronith/diamante/utility/search"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -229,6 +232,10 @@ func (dispatcher *dispatcher) Format(format string, args ...interface{}) string
|
||||||
return fmt.Sprintf(format, args...)
|
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) {
|
func (dispatcher *dispatcher) Sort(slice interface{}, less func(x, y int) bool) {
|
||||||
sort.Slice(slice, less)
|
sort.Slice(slice, less)
|
||||||
}
|
}
|
||||||
|
@ -356,34 +363,32 @@ func (dispatcher *dispatcher) IsProductionEnvironment() bool {
|
||||||
return dispatcher.conductor.IdentityManager().IsProductionEnvironment()
|
return dispatcher.conductor.IdentityManager().IsProductionEnvironment()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) GetActorId() string {
|
func (dispatcher *dispatcher) GetActorId(identity Identity) string {
|
||||||
config := dispatcher.conductor.Configuration().GetServerConfiguration()
|
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 {
|
func (dispatcher *dispatcher) GetPublicKeyId(identity Identity) string {
|
||||||
config := dispatcher.conductor.Configuration().GetServerConfiguration()
|
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 {
|
func (dispatcher *dispatcher) GetActivityStream(url string, output interface{}) error {
|
||||||
return dispatcher.conductor.RequestActivityStream(http.MethodGet, url, "", "", input, output)
|
return dispatcher.conductor.RequestActivityStream(http.MethodGet, url, "", "", nil, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) PostActivityStream(url string, input, output interface{}) error {
|
func (dispatcher *dispatcher) PostActivityStream(url string, input interface{}) error {
|
||||||
return dispatcher.conductor.RequestActivityStream(http.MethodPost, url, "", "", input, output)
|
return dispatcher.conductor.RequestActivityStream(http.MethodPost, url, "", "", input, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) GetActivityStreamSigned(url string, input, output interface{}) error {
|
func (dispatcher *dispatcher) GetSignedActivityStream(url string, output interface{}, identity Identity) error {
|
||||||
identity := dispatcher.identity
|
|
||||||
keyId := dispatcher.GetPublicKeyId(identity)
|
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 {
|
func (dispatcher *dispatcher) PostSignedActivityStream(url string, input interface{}, identity Identity) error {
|
||||||
identity := dispatcher.identity
|
|
||||||
keyId := dispatcher.GetPublicKeyId(identity)
|
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 {
|
func (dispatcher *dispatcher) UnmarshalActivityPubObjectOrLink(data []byte) activitypub.ObjectOrLink {
|
||||||
|
@ -405,4 +410,31 @@ func (dispatcher *dispatcher) UnmarshalActivityPubNote(data []byte) *activitypub
|
||||||
return note
|
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
|
//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)
|
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 {
|
func (dispatcher *dispatcher) NewFollowActorResult() IFollowActorResult {
|
||||||
return NewFollowActorResult(url, nil)
|
return NewFollowActorResult(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) NewAuthorizeInteractionResult(uri string, success bool) IAuthorizeInteractionResult {
|
func (dispatcher *dispatcher) NewAuthorizeInteractionResult(uri string, success bool) IAuthorizeInteractionResult {
|
||||||
|
|
Ładowanie…
Reference in New Issue