kopia lustrzana https://github.com/reiver/greatape
refactor(project): ⚡ improve structure and performance
rodzic
ab7151060e
commit
7e41d3a092
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed _packages.txt
|
//go:embed _packages.txt
|
||||||
var packages string
|
var packages []byte
|
||||||
|
|
||||||
func GetPackages(x IDispatcher) (IGetPackagesResult, error) {
|
func GetPackages(x IDispatcher) (IGetPackagesResult, error) {
|
||||||
return x.NewGetPackagesResult(packages), nil
|
return x.NewGetPackagesResult(packages), nil
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
. "github.com/reiver/greatape/components/contracts"
|
. "github.com/reiver/greatape/components/contracts"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PostToInbox(x IDispatcher, username string, body string) (IPostToInboxResult, error) {
|
func PostToInbox(x IDispatcher, username string, body []byte) (IPostToInboxResult, error) {
|
||||||
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
||||||
return identity.Username() == username
|
return identity.Username() == username
|
||||||
})
|
})
|
||||||
|
|
@ -18,7 +18,7 @@ func PostToInbox(x IDispatcher, username string, body string) (IPostToInboxResul
|
||||||
identity := identities.First()
|
identity := identities.First()
|
||||||
|
|
||||||
object := &activitypub.Object{}
|
object := &activitypub.Object{}
|
||||||
if err := json.Unmarshal([]byte(body), object); err != nil {
|
if err := json.Unmarshal(body, object); err != nil {
|
||||||
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_OBJECT
|
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_OBJECT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ func PostToInbox(x IDispatcher, username string, body string) (IPostToInboxResul
|
||||||
case activitypub.TypeFollow:
|
case activitypub.TypeFollow:
|
||||||
{
|
{
|
||||||
activity := &activitypub.Activity{}
|
activity := &activitypub.Activity{}
|
||||||
if err := json.Unmarshal([]byte(body), activity); err != nil {
|
if err := json.Unmarshal(body, activity); err != nil {
|
||||||
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_ACTIVITY
|
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_ACTIVITY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ func PostToInbox(x IDispatcher, username string, body string) (IPostToInboxResul
|
||||||
case activitypub.TypeCreate:
|
case activitypub.TypeCreate:
|
||||||
{
|
{
|
||||||
activity := &activitypub.Activity{}
|
activity := &activitypub.Activity{}
|
||||||
if err := json.Unmarshal([]byte(body), activity); err != nil {
|
if err := json.Unmarshal(body, activity); err != nil {
|
||||||
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_ACTIVITY
|
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_ACTIVITY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,16 @@ package spi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"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,
|
func PostToOutbox(x IDispatcher, username string, body []byte) (IPostToOutboxResult, error) {
|
||||||
username string,
|
|
||||||
context string,
|
|
||||||
activityType string,
|
|
||||||
to string,
|
|
||||||
attributedTo string,
|
|
||||||
inReplyTo string,
|
|
||||||
content string,
|
|
||||||
) (IPostToOutboxResult, error) {
|
|
||||||
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
identities := x.FilterIdentities(func(identity IIdentity) bool {
|
||||||
return identity.Username() == username
|
return identity.Username() == username
|
||||||
})
|
})
|
||||||
|
|
@ -24,19 +19,37 @@ func PostToOutbox(x IDispatcher,
|
||||||
x.Assert(identities.HasExactlyOneItem()).Or(ERROR_USER_NOT_FOUND)
|
x.Assert(identities.HasExactlyOneItem()).Or(ERROR_USER_NOT_FOUND)
|
||||||
identity := identities.First()
|
identity := identities.First()
|
||||||
|
|
||||||
|
item := x.UnmarshalActivityPubObjectOrLink(body)
|
||||||
|
|
||||||
id := x.Format("%s/u/%s", x.PublicUrl(), identity.Username())
|
id := x.Format("%s/u/%s", x.PublicUrl(), identity.Username())
|
||||||
|
|
||||||
publicKeyId := x.Format("%s#main-key", id)
|
publicKeyId := x.Format("%s#main-key", id)
|
||||||
privateKey := identity.PrivateKey()
|
privateKey := identity.PrivateKey()
|
||||||
|
|
||||||
_ = publicKeyId
|
switch item.GetType() {
|
||||||
|
case ap.NoteType:
|
||||||
switch activityType {
|
|
||||||
case ACTIVITY_PUB_NOTE:
|
|
||||||
{
|
{
|
||||||
|
note := x.UnmarshalActivityPubNote(body)
|
||||||
|
|
||||||
|
content := note.Content.First().Value.String()
|
||||||
|
to := note.To.First().GetID().String()
|
||||||
|
from := note.AttributedTo.GetID().String()
|
||||||
|
|
||||||
|
if from != id {
|
||||||
|
return nil, ERROR_INVALID_PARAMETERS
|
||||||
|
}
|
||||||
|
|
||||||
uniqueIdentifier := x.GenerateUUID()
|
uniqueIdentifier := x.GenerateUUID()
|
||||||
note := activitypub.NewNote(id, to, content)
|
|
||||||
activity := note.Wrap(identity.Username(), x.PublicUrl(), uniqueIdentifier)
|
activity := &activitypub.Activity{
|
||||||
to := activity.To.([]string)[0]
|
Context: activitypub.ActivityStreams,
|
||||||
|
Type: activitypub.TypeCreate,
|
||||||
|
ID: fmt.Sprintf("%s/u/%s/posts/%s", x.PublicUrl(), username, uniqueIdentifier),
|
||||||
|
To: note.To,
|
||||||
|
Actor: fmt.Sprintf("%s/u/%s", x.PublicUrl(), username),
|
||||||
|
Published: time.Now(),
|
||||||
|
Object: note,
|
||||||
|
}
|
||||||
|
|
||||||
if to != activitypub.Public {
|
if to != activitypub.Public {
|
||||||
recipient := &activitypub.Actor{}
|
recipient := &activitypub.Actor{}
|
||||||
|
|
@ -59,15 +72,15 @@ func PostToOutbox(x IDispatcher,
|
||||||
identity.Id(),
|
identity.Id(),
|
||||||
uniqueIdentifier,
|
uniqueIdentifier,
|
||||||
x.UnixNano(),
|
x.UnixNano(),
|
||||||
note.AttributedTo,
|
from,
|
||||||
to,
|
to,
|
||||||
note.Content,
|
content,
|
||||||
string(raw),
|
string(raw),
|
||||||
"PostToOutbox",
|
"PostToOutbox",
|
||||||
EMPTY_JSON,
|
EMPTY_JSON,
|
||||||
)
|
)
|
||||||
|
|
||||||
return x.NewPostToOutboxResult(), nil
|
return x.NewPostToOutboxResult(nil), nil
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil, ERROR_INVALID_PARAMETERS
|
return nil, ERROR_INVALID_PARAMETERS
|
||||||
|
|
|
||||||
|
|
@ -207,13 +207,8 @@ func TestGetFollowingApi(test *testing.T) {
|
||||||
|
|
||||||
func TestPostToOutboxApi(test *testing.T) {
|
func TestPostToOutboxApi(test *testing.T) {
|
||||||
input := &PostToOutboxRequest{
|
input := &PostToOutboxRequest{
|
||||||
Username: "username",
|
Username: "username",
|
||||||
Context: "context",
|
Body: nil,
|
||||||
ActivityType: "activity_type",
|
|
||||||
To: "to",
|
|
||||||
AttributedTo: "attributed_to",
|
|
||||||
InReplyTo: "in_reply_to",
|
|
||||||
Content: "content",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if output, err := api.PostToOutbox(input); err != nil {
|
if output, err := api.PostToOutbox(input); err != nil {
|
||||||
|
|
@ -238,7 +233,7 @@ func TestGetOutboxApi(test *testing.T) {
|
||||||
func TestPostToInboxApi(test *testing.T) {
|
func TestPostToInboxApi(test *testing.T) {
|
||||||
input := &PostToInboxRequest{
|
input := &PostToInboxRequest{
|
||||||
Username: "username",
|
Username: "username",
|
||||||
Body: "body",
|
Body: nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
if output, err := api.PostToInbox(input); err != nil {
|
if output, err := api.PostToInbox(input); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ func (handler *getPackagesHandler) HandlerFunc() HttpHandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
onRequestProcessed := func(output *GetPackagesResult) (string, []byte) {
|
onRequestProcessed := func(output *GetPackagesResult) (string, []byte) {
|
||||||
return "text/plain", []byte(output.Body)
|
return "text/plain", output.Body
|
||||||
}
|
}
|
||||||
|
|
||||||
return pipeline.Handle(x,
|
return pipeline.Handle(x,
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ func (handler *postToInboxHandler) HandlerFunc() HttpHandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
onRequestProcessed := func(output *PostToInboxResult) (string, []byte) {
|
onRequestProcessed := func(output *PostToInboxResult) (string, []byte) {
|
||||||
return "application/activity+json; charset=utf-8", []byte(output.Body)
|
return "application/activity+json; charset=utf-8", output.Body
|
||||||
}
|
}
|
||||||
|
|
||||||
return pipeline.Handle(x,
|
return pipeline.Handle(x,
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,17 @@ func (handler *postToOutboxHandler) HandlerFunc() HttpHandlerFunc {
|
||||||
request.Username = x.Param("username")
|
request.Username = x.Param("username")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onRequestProcessed := func(output *PostToOutboxResult) (string, []byte) {
|
||||||
|
return "application/activity+json; charset=utf-8", output.Body
|
||||||
|
}
|
||||||
|
|
||||||
return pipeline.Handle(x,
|
return pipeline.Handle(x,
|
||||||
"post_to_outbox",
|
"post_to_outbox",
|
||||||
POST_TO_OUTBOX_REQUEST,
|
POST_TO_OUTBOX_REQUEST,
|
||||||
POST_TO_OUTBOX_RESULT,
|
POST_TO_OUTBOX_RESULT,
|
||||||
request, result,
|
request, result,
|
||||||
onRequestUnmarshalled,
|
onRequestUnmarshalled,
|
||||||
nil,
|
onRequestProcessed,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1069,7 +1069,7 @@ type GetPackagesResult struct {
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Body string `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
|
Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GetPackagesResult) Reset() {
|
func (x *GetPackagesResult) Reset() {
|
||||||
|
|
@ -1104,11 +1104,11 @@ func (*GetPackagesResult) Descriptor() ([]byte, []int) {
|
||||||
return file_spis_proto_rawDescGZIP(), []int{19}
|
return file_spis_proto_rawDescGZIP(), []int{19}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GetPackagesResult) GetBody() string {
|
func (x *GetPackagesResult) GetBody() []byte {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Body
|
return x.Body
|
||||||
}
|
}
|
||||||
return ""
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// API: GetActor
|
// API: GetActor
|
||||||
|
|
@ -1806,13 +1806,8 @@ type PostToOutboxRequest struct {
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
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"`
|
||||||
Context string `protobuf:"bytes,2,opt,name=context,json=@context,proto3" json:"context,omitempty"`
|
Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
|
||||||
ActivityType string `protobuf:"bytes,3,opt,name=activityType,json=type,proto3" json:"activityType,omitempty"`
|
|
||||||
To string `protobuf:"bytes,4,opt,name=to,proto3" json:"to,omitempty"`
|
|
||||||
AttributedTo string `protobuf:"bytes,5,opt,name=attributedTo,proto3" json:"attributedTo,omitempty"`
|
|
||||||
InReplyTo string `protobuf:"bytes,6,opt,name=inReplyTo,proto3" json:"inReplyTo,omitempty"`
|
|
||||||
Content string `protobuf:"bytes,7,opt,name=content,proto3" json:"content,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PostToOutboxRequest) Reset() {
|
func (x *PostToOutboxRequest) Reset() {
|
||||||
|
|
@ -1854,52 +1849,19 @@ func (x *PostToOutboxRequest) GetUsername() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PostToOutboxRequest) GetContext() string {
|
func (x *PostToOutboxRequest) GetBody() []byte {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Context
|
return x.Body
|
||||||
}
|
}
|
||||||
return ""
|
return nil
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PostToOutboxRequest) GetActivityType() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.ActivityType
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PostToOutboxRequest) GetTo() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.To
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PostToOutboxRequest) GetAttributedTo() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.AttributedTo
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PostToOutboxRequest) GetInReplyTo() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.InReplyTo
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *PostToOutboxRequest) GetContent() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Content
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostToOutboxResult struct {
|
type PostToOutboxResult struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
|
Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PostToOutboxResult) Reset() {
|
func (x *PostToOutboxResult) Reset() {
|
||||||
|
|
@ -1934,6 +1896,13 @@ func (*PostToOutboxResult) Descriptor() ([]byte, []int) {
|
||||||
return file_spis_proto_rawDescGZIP(), []int{31}
|
return file_spis_proto_rawDescGZIP(), []int{31}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *PostToOutboxResult) GetBody() []byte {
|
||||||
|
if x != nil {
|
||||||
|
return x.Body
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// API: GetOutbox
|
// API: GetOutbox
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
type GetOutboxRequest struct {
|
type GetOutboxRequest struct {
|
||||||
|
|
@ -2078,7 +2047,7 @@ type PostToInboxRequest 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"`
|
||||||
Body string `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
|
Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PostToInboxRequest) Reset() {
|
func (x *PostToInboxRequest) Reset() {
|
||||||
|
|
@ -2120,11 +2089,11 @@ func (x *PostToInboxRequest) GetUsername() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PostToInboxRequest) GetBody() string {
|
func (x *PostToInboxRequest) GetBody() []byte {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Body
|
return x.Body
|
||||||
}
|
}
|
||||||
return ""
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostToInboxResult struct {
|
type PostToInboxResult struct {
|
||||||
|
|
@ -2132,7 +2101,7 @@ type PostToInboxResult struct {
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Body string `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
|
Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PostToInboxResult) Reset() {
|
func (x *PostToInboxResult) Reset() {
|
||||||
|
|
@ -2167,11 +2136,11 @@ func (*PostToInboxResult) Descriptor() ([]byte, []int) {
|
||||||
return file_spis_proto_rawDescGZIP(), []int{35}
|
return file_spis_proto_rawDescGZIP(), []int{35}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *PostToInboxResult) GetBody() string {
|
func (x *PostToInboxResult) GetBody() []byte {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Body
|
return x.Body
|
||||||
}
|
}
|
||||||
return ""
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// API: GetInbox
|
// API: GetInbox
|
||||||
|
|
@ -2402,7 +2371,7 @@ var file_spis_proto_rawDesc = []byte{
|
||||||
0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||||
0x73, 0x74, 0x22, 0x27, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65,
|
0x73, 0x74, 0x22, 0x27, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65,
|
||||||
0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18,
|
0x73, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18,
|
||||||
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x0f, 0x47,
|
0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x0f, 0x47,
|
||||||
0x65, 0x74, 0x41, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a,
|
0x65, 0x74, 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,
|
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, 0xe5, 0x03, 0x0a, 0x0e, 0x47,
|
0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xe5, 0x03, 0x0a, 0x0e, 0x47,
|
||||||
|
|
@ -2479,60 +2448,53 @@ var file_spis_proto_rawDesc = []byte{
|
||||||
0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x6f, 0x72,
|
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,
|
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,
|
0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74,
|
||||||
0x22, 0xd4, 0x01, 0x0a, 0x13, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f,
|
0x22, 0x45, 0x0a, 0x13, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78,
|
||||||
0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72,
|
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e,
|
||||||
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72,
|
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e,
|
||||||
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18,
|
0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12,
|
0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x28, 0x0a, 0x12, 0x50, 0x6f, 0x73, 0x74, 0x54,
|
||||||
0x1a, 0x0a, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x18,
|
0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a,
|
||||||
0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x74,
|
0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64,
|
||||||
0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x74, 0x6f, 0x12, 0x22, 0x0a, 0x0c, 0x61,
|
0x79, 0x22, 0x2e, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65,
|
||||||
0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x54, 0x6f, 0x18, 0x05, 0x20, 0x01, 0x28,
|
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d,
|
||||||
0x09, 0x52, 0x0c, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x54, 0x6f, 0x12,
|
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d,
|
||||||
0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x18, 0x06, 0x20, 0x01,
|
0x65, 0x22, 0xc9, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52,
|
||||||
0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x12, 0x18, 0x0a,
|
0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
||||||
0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74,
|
||||||
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x14, 0x0a, 0x12, 0x50, 0x6f, 0x73, 0x74, 0x54,
|
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64,
|
||||||
0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x2e, 0x0a,
|
0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||||
0x10, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65,
|
||||||
0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
|
0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc9, 0x01,
|
0x74, 0x65, 0x6d, 0x73, 0x12, 0x41, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49,
|
||||||
0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c,
|
0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f,
|
||||||
0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01,
|
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75,
|
||||||
0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02,
|
0x62, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||||
0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04,
|
0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74,
|
||||||
0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65,
|
0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x44, 0x0a,
|
||||||
0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04,
|
0x12, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75,
|
||||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73,
|
0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18,
|
||||||
0x12, 0x41, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73,
|
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12,
|
||||||
0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
|
0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62,
|
||||||
0x66, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75, 0x62, 0x41, 0x63, 0x74,
|
0x6f, 0x64, 0x79, 0x22, 0x27, 0x0a, 0x11, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x49, 0x6e, 0x62,
|
||||||
0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74,
|
0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79,
|
||||||
0x65, 0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01,
|
0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x0f,
|
||||||
0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x22, 0x44, 0x0a, 0x12, 0x50, 0x6f, 0x73,
|
0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
|
||||||
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,
|
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,
|
0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x0e,
|
||||||
0x6f, 0x64, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22,
|
0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19,
|
||||||
0x27, 0x0a, 0x11, 0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65,
|
0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x73, 0x75, 0x6c, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x18, 0x01, 0x20, 0x01,
|
0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18,
|
||||||
0x28, 0x09, 0x52, 0x04, 0x62, 0x6f, 0x64, 0x79, 0x22, 0x2d, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49,
|
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
||||||
0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75,
|
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a,
|
||||||
0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75,
|
0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||||
0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc8, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x49,
|
0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x41, 0x0a,
|
||||||
0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f,
|
0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x05, 0x20,
|
||||||
0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f,
|
0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41,
|
||||||
0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
|
0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75, 0x62, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69,
|
||||||
0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20,
|
0x74, 0x79, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d, 0x73,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74,
|
0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||||
0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74,
|
0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72,
|
||||||
0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x41, 0x0a, 0x0c, 0x6f, 0x72, 0x64,
|
0x6f, 0x74, 0x6f, 0x33,
|
||||||
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, 0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ message GetPackagesRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetPackagesResult {
|
message GetPackagesResult {
|
||||||
string body = 0x00000001;
|
bytes body = 0x00000001;
|
||||||
}
|
}
|
||||||
|
|
||||||
// API: GetActor
|
// API: GetActor
|
||||||
|
|
@ -203,15 +203,11 @@ message GetFollowingResult {
|
||||||
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
||||||
message PostToOutboxRequest {
|
message PostToOutboxRequest {
|
||||||
string username = 0x00000001;
|
string username = 0x00000001;
|
||||||
string context = 0x00000002 [json_name = "@context"];
|
bytes body = 0x00000002;
|
||||||
string activityType = 0x00000003 [json_name = "type"];
|
|
||||||
string to = 0x00000004;
|
|
||||||
string attributedTo = 0x00000005;
|
|
||||||
string inReplyTo = 0x00000006;
|
|
||||||
string content = 0x00000007;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message PostToOutboxResult {
|
message PostToOutboxResult {
|
||||||
|
bytes body = 0x00000001;
|
||||||
}
|
}
|
||||||
|
|
||||||
// API: GetOutbox
|
// API: GetOutbox
|
||||||
|
|
@ -233,11 +229,11 @@ message GetOutboxResult {
|
||||||
//-----------------------------------------------------------
|
//-----------------------------------------------------------
|
||||||
message PostToInboxRequest {
|
message PostToInboxRequest {
|
||||||
string username = 0x00000001;
|
string username = 0x00000001;
|
||||||
string body = 0x00000002;
|
bytes body = 0x00000002;
|
||||||
}
|
}
|
||||||
|
|
||||||
message PostToInboxResult {
|
message PostToInboxResult {
|
||||||
string body = 0x00000001;
|
bytes body = 0x00000001;
|
||||||
}
|
}
|
||||||
|
|
||||||
// API: GetInbox
|
// API: GetInbox
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ func PostToOutboxService(context IContext, input *PostToOutboxRequest) (result *
|
||||||
conductor.LogRemoteCall(context, INITIALIZE, "post_to_outbox", input, result, err)
|
conductor.LogRemoteCall(context, INITIALIZE, "post_to_outbox", input, result, err)
|
||||||
defer func() { conductor.LogRemoteCall(context, FINALIZE, "post_to_outbox", input, result, err) }()
|
defer func() { conductor.LogRemoteCall(context, FINALIZE, "post_to_outbox", input, result, err) }()
|
||||||
|
|
||||||
_result, _err := conductor.PostToOutbox(input.Username, input.Context, input.ActivityType, input.To, input.AttributedTo, input.InReplyTo, input.Content, context.Identity())
|
_result, _err := conductor.PostToOutbox(input.Username, input.Body, context.Identity())
|
||||||
if _err != nil {
|
if _err != nil {
|
||||||
err = _err
|
err = _err
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -24,5 +24,6 @@ func PostToOutboxService(context IContext, input *PostToOutboxRequest) (result *
|
||||||
_ = _result
|
_ = _result
|
||||||
|
|
||||||
result = context.ResultContainer().(*PostToOutboxResult)
|
result = context.ResultContainer().(*PostToOutboxResult)
|
||||||
|
result.Body = _result.Body()
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,9 @@ type (
|
||||||
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)
|
||||||
PostToOutbox(username string, context string, activityType string, to string, attributedTo string, inReplyTo string, content string, editor Identity) (IPostToOutboxResult, error)
|
PostToOutbox(username string, body []byte, editor Identity) (IPostToOutboxResult, error)
|
||||||
GetOutbox(username string, editor Identity) (IGetOutboxResult, error)
|
GetOutbox(username string, editor Identity) (IGetOutboxResult, error)
|
||||||
PostToInbox(username string, body string, editor Identity) (IPostToInboxResult, error)
|
PostToInbox(username string, body []byte, editor Identity) (IPostToInboxResult, error)
|
||||||
GetInbox(username string, editor Identity) (IGetInboxResult, error)
|
GetInbox(username string, editor Identity) (IGetInboxResult, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
IGetPackagesResult interface {
|
IGetPackagesResult interface {
|
||||||
Body() string
|
Body() []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
IGetActorResult interface {
|
IGetActorResult interface {
|
||||||
|
|
@ -168,6 +168,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
IPostToOutboxResult interface {
|
IPostToOutboxResult interface {
|
||||||
|
Body() []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
IGetOutboxResult interface {
|
IGetOutboxResult interface {
|
||||||
|
|
@ -180,7 +181,7 @@ type (
|
||||||
}
|
}
|
||||||
|
|
||||||
IPostToInboxResult interface {
|
IPostToInboxResult interface {
|
||||||
Body() string
|
Body() []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
IGetInboxResult interface {
|
IGetInboxResult interface {
|
||||||
|
|
|
||||||
|
|
@ -271,9 +271,9 @@ type (
|
||||||
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)
|
||||||
PostToOutbox(username string, context string, activityType string, to string, attributedTo string, inReplyTo string, content string, editor Identity) (IPostToOutboxResult, error)
|
PostToOutbox(username string, body []byte, editor Identity) (IPostToOutboxResult, error)
|
||||||
GetOutbox(username string, editor Identity) (IGetOutboxResult, error)
|
GetOutbox(username string, editor Identity) (IGetOutboxResult, error)
|
||||||
PostToInbox(username string, body string, editor Identity) (IPostToInboxResult, error)
|
PostToInbox(username string, body []byte, editor Identity) (IPostToInboxResult, error)
|
||||||
GetInbox(username string, editor Identity) (IGetInboxResult, error)
|
GetInbox(username string, editor Identity) (IGetInboxResult, error)
|
||||||
|
|
||||||
NewDocument(id int64, content string) (IDocument, error)
|
NewDocument(id int64, content string) (IDocument, error)
|
||||||
|
|
@ -301,15 +301,15 @@ type (
|
||||||
NewUpdateProfileByUserResult(displayName string, avatar string, banner string, summary string, github string, ignored interface{}) IUpdateProfileByUserResult
|
NewUpdateProfileByUserResult(displayName string, avatar string, banner string, summary string, github string, ignored interface{}) IUpdateProfileByUserResult
|
||||||
NewLogoutResult(ignored interface{}) ILogoutResult
|
NewLogoutResult(ignored interface{}) ILogoutResult
|
||||||
NewWebfingerResult(aliases []string, links []IActivityPubLink, subject string, ignored interface{}) IWebfingerResult
|
NewWebfingerResult(aliases []string, links []IActivityPubLink, subject string, ignored interface{}) IWebfingerResult
|
||||||
NewGetPackagesResult(body string, 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(url string, 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
|
||||||
NewPostToOutboxResult(ignored interface{}) IPostToOutboxResult
|
NewPostToOutboxResult(body []byte, ignored interface{}) IPostToOutboxResult
|
||||||
NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, ignored interface{}) IGetOutboxResult
|
NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, ignored interface{}) IGetOutboxResult
|
||||||
NewPostToInboxResult(body string, ignored interface{}) IPostToInboxResult
|
NewPostToInboxResult(body []byte, ignored interface{}) IPostToInboxResult
|
||||||
NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, ignored interface{}) IGetInboxResult
|
NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, ignored interface{}) IGetInboxResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package contracts
|
package contracts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/go-ap/activitypub"
|
||||||
. "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"
|
||||||
|
|
@ -1045,9 +1046,9 @@ type IDispatcher interface {
|
||||||
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)
|
||||||
PostToOutbox(username string, context string, activityType string, to string, attributedTo string, inReplyTo string, content string) (IPostToOutboxResult, error)
|
PostToOutbox(username string, body []byte) (IPostToOutboxResult, error)
|
||||||
GetOutbox(username string) (IGetOutboxResult, error)
|
GetOutbox(username string) (IGetOutboxResult, error)
|
||||||
PostToInbox(username string, body string) (IPostToInboxResult, error)
|
PostToInbox(username string, body []byte) (IPostToInboxResult, error)
|
||||||
GetInbox(username string) (IGetInboxResult, error)
|
GetInbox(username string) (IGetInboxResult, error)
|
||||||
|
|
||||||
// NewDocument creates a new 'Document' instance using the provided property values.
|
// NewDocument creates a new 'Document' instance using the provided property values.
|
||||||
|
|
@ -1135,7 +1136,7 @@ type IDispatcher interface {
|
||||||
// NewWebfingerResult creates a new result container for 'Webfinger' system action.
|
// NewWebfingerResult creates a new result container for 'Webfinger' system action.
|
||||||
NewWebfingerResult(aliases []string, links []IActivityPubLink, subject string) IWebfingerResult
|
NewWebfingerResult(aliases []string, links []IActivityPubLink, subject string) IWebfingerResult
|
||||||
// NewGetPackagesResult creates a new result container for 'Get Packages' system action.
|
// NewGetPackagesResult creates a new result container for 'Get Packages' system action.
|
||||||
NewGetPackagesResult(body string) IGetPackagesResult
|
NewGetPackagesResult(body []byte) IGetPackagesResult
|
||||||
// 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.
|
||||||
|
|
@ -1147,11 +1148,11 @@ type IDispatcher interface {
|
||||||
// NewGetFollowingResult creates a new result container for 'Get Following' system action.
|
// NewGetFollowingResult creates a new result container for 'Get Following' system action.
|
||||||
NewGetFollowingResult(context string, id string, type_ string, totalItems int32, orderedItems []string, first string) IGetFollowingResult
|
NewGetFollowingResult(context string, id string, type_ string, totalItems int32, orderedItems []string, first string) IGetFollowingResult
|
||||||
// NewPostToOutboxResult creates a new result container for 'Post To Outbox' system action.
|
// NewPostToOutboxResult creates a new result container for 'Post To Outbox' system action.
|
||||||
NewPostToOutboxResult() IPostToOutboxResult
|
NewPostToOutboxResult(body []byte) IPostToOutboxResult
|
||||||
// NewGetOutboxResult creates a new result container for 'Get Outbox' system action.
|
// NewGetOutboxResult creates a new result container for 'Get Outbox' system action.
|
||||||
NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetOutboxResult
|
NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetOutboxResult
|
||||||
// NewPostToInboxResult creates a new result container for 'Post To Inbox' system action.
|
// NewPostToInboxResult creates a new result container for 'Post To Inbox' system action.
|
||||||
NewPostToInboxResult(body string) IPostToInboxResult
|
NewPostToInboxResult(body []byte) IPostToInboxResult
|
||||||
// NewGetInboxResult creates a new result container for 'Get Inbox' system action.
|
// NewGetInboxResult creates a new result container for 'Get Inbox' system action.
|
||||||
NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetInboxResult
|
NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetInboxResult
|
||||||
// Assert asserts the provided condition and panics if the assertion is not valid.
|
// Assert asserts the provided condition and panics if the assertion is not valid.
|
||||||
|
|
@ -1222,4 +1223,6 @@ type IDispatcher interface {
|
||||||
PostActivityStream(url string, data []byte, output interface{}) error
|
PostActivityStream(url string, data []byte, output interface{}) error
|
||||||
GetActivityStreamSigned(url, keyId, privateKey string, data []byte, output interface{}) error
|
GetActivityStreamSigned(url, keyId, privateKey string, data []byte, output interface{}) error
|
||||||
PostActivityStreamSigned(url, keyId, privateKey string, data []byte, output interface{}) error
|
PostActivityStreamSigned(url, keyId, privateKey string, data []byte, output interface{}) error
|
||||||
|
UnmarshalActivityPubObjectOrLink([]byte) activitypub.ObjectOrLink
|
||||||
|
UnmarshalActivityPubNote([]byte) *activitypub.Note
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1151,15 +1151,15 @@ func (conductor *conductor) GetFollowing(username string, editor Identity) (IGet
|
||||||
return conductor.spiManager.GetFollowing(username, editor)
|
return conductor.spiManager.GetFollowing(username, editor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) PostToOutbox(username string, context string, activityType string, to string, attributedTo string, inReplyTo string, content string, editor Identity) (IPostToOutboxResult, error) {
|
func (conductor *conductor) PostToOutbox(username string, body []byte, editor Identity) (IPostToOutboxResult, error) {
|
||||||
return conductor.spiManager.PostToOutbox(username, context, activityType, to, attributedTo, inReplyTo, content, editor)
|
return conductor.spiManager.PostToOutbox(username, body, editor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) GetOutbox(username string, editor Identity) (IGetOutboxResult, error) {
|
func (conductor *conductor) GetOutbox(username string, editor Identity) (IGetOutboxResult, error) {
|
||||||
return conductor.spiManager.GetOutbox(username, editor)
|
return conductor.spiManager.GetOutbox(username, editor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) PostToInbox(username string, body string, editor Identity) (IPostToInboxResult, error) {
|
func (conductor *conductor) PostToInbox(username string, body []byte, editor Identity) (IPostToInboxResult, error) {
|
||||||
return conductor.spiManager.PostToInbox(username, body, editor)
|
return conductor.spiManager.PostToInbox(username, body, editor)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1267,7 +1267,7 @@ func (conductor *conductor) NewWebfingerResult(aliases []string, links []IActivi
|
||||||
return NewWebfingerResult(aliases, links, subject, nil)
|
return NewWebfingerResult(aliases, links, subject, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) NewGetPackagesResult(body string, _ interface{}) IGetPackagesResult {
|
func (conductor *conductor) NewGetPackagesResult(body []byte, _ interface{}) IGetPackagesResult {
|
||||||
return NewGetPackagesResult(body, nil)
|
return NewGetPackagesResult(body, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1291,15 +1291,15 @@ func (conductor *conductor) NewGetFollowingResult(context string, id string, typ
|
||||||
return NewGetFollowingResult(context, id, type_, totalItems, orderedItems, first, nil)
|
return NewGetFollowingResult(context, id, type_, totalItems, orderedItems, first, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) NewPostToOutboxResult(_ interface{}) IPostToOutboxResult {
|
func (conductor *conductor) NewPostToOutboxResult(body []byte, _ interface{}) IPostToOutboxResult {
|
||||||
return NewPostToOutboxResult(nil)
|
return NewPostToOutboxResult(body, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, _ interface{}) IGetOutboxResult {
|
func (conductor *conductor) NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, _ interface{}) IGetOutboxResult {
|
||||||
return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil)
|
return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conductor *conductor) NewPostToInboxResult(body string, _ interface{}) IPostToInboxResult {
|
func (conductor *conductor) NewPostToInboxResult(body []byte, _ interface{}) IPostToInboxResult {
|
||||||
return NewPostToInboxResult(body, nil)
|
return NewPostToInboxResult(body, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -291,15 +291,15 @@ func (dispatcher *dispatcher) GetFollowing(username string) (IGetFollowingResult
|
||||||
return dispatcher.conductor.SpiManager().GetFollowing(username, dispatcher.identity)
|
return dispatcher.conductor.SpiManager().GetFollowing(username, dispatcher.identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) PostToOutbox(username string, context string, activityType string, to string, attributedTo string, inReplyTo string, content string) (IPostToOutboxResult, error) {
|
func (dispatcher *dispatcher) PostToOutbox(username string, body []byte) (IPostToOutboxResult, error) {
|
||||||
return dispatcher.conductor.SpiManager().PostToOutbox(username, context, activityType, to, attributedTo, inReplyTo, content, dispatcher.identity)
|
return dispatcher.conductor.SpiManager().PostToOutbox(username, body, dispatcher.identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) GetOutbox(username string) (IGetOutboxResult, error) {
|
func (dispatcher *dispatcher) GetOutbox(username string) (IGetOutboxResult, error) {
|
||||||
return dispatcher.conductor.SpiManager().GetOutbox(username, dispatcher.identity)
|
return dispatcher.conductor.SpiManager().GetOutbox(username, dispatcher.identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) PostToInbox(username string, body string) (IPostToInboxResult, error) {
|
func (dispatcher *dispatcher) PostToInbox(username string, body []byte) (IPostToInboxResult, error) {
|
||||||
return dispatcher.conductor.SpiManager().PostToInbox(username, body, dispatcher.identity)
|
return dispatcher.conductor.SpiManager().PostToInbox(username, body, dispatcher.identity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -588,16 +588,16 @@ func (manager *spiManager) Webfinger(resource string, editor Identity) (result I
|
||||||
//region IGetPackagesResult Implementation
|
//region IGetPackagesResult Implementation
|
||||||
|
|
||||||
type getPackagesResult struct {
|
type getPackagesResult struct {
|
||||||
body string
|
body []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGetPackagesResult(body string, _ interface{}) IGetPackagesResult {
|
func NewGetPackagesResult(body []byte, _ interface{}) IGetPackagesResult {
|
||||||
return &getPackagesResult{
|
return &getPackagesResult{
|
||||||
body: body,
|
body: body,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (result getPackagesResult) Body() string {
|
func (result getPackagesResult) Body() []byte {
|
||||||
return result.body
|
return result.body
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -948,15 +948,22 @@ func (manager *spiManager) GetFollowing(username string, editor Identity) (resul
|
||||||
//region IPostToOutboxResult Implementation
|
//region IPostToOutboxResult Implementation
|
||||||
|
|
||||||
type postToOutboxResult struct {
|
type postToOutboxResult struct {
|
||||||
|
body []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPostToOutboxResult(_ interface{}) IPostToOutboxResult {
|
func NewPostToOutboxResult(body []byte, _ interface{}) IPostToOutboxResult {
|
||||||
return &postToOutboxResult{}
|
return &postToOutboxResult{
|
||||||
|
body: body,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (result postToOutboxResult) Body() []byte {
|
||||||
|
return result.body
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
func (manager *spiManager) PostToOutbox(username string, context string, activityType string, to string, attributedTo string, inReplyTo string, content string, editor Identity) (result IPostToOutboxResult, err error) {
|
func (manager *spiManager) PostToOutbox(username string, body []byte, editor Identity) (result IPostToOutboxResult, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if reason := recover(); reason != nil {
|
if reason := recover(); reason != nil {
|
||||||
err = manager.Error(reason)
|
err = manager.Error(reason)
|
||||||
|
|
@ -966,7 +973,7 @@ func (manager *spiManager) PostToOutbox(username string, context string, activit
|
||||||
editor.Lock(POST_TO_OUTBOX_REQUEST)
|
editor.Lock(POST_TO_OUTBOX_REQUEST)
|
||||||
defer editor.Unlock(POST_TO_OUTBOX_REQUEST)
|
defer editor.Unlock(POST_TO_OUTBOX_REQUEST)
|
||||||
|
|
||||||
if result, err = commands.PostToOutbox(NewDispatcher(Conductor, editor), username, context, activityType, to, attributedTo, inReplyTo, content); err != nil {
|
if result, err = commands.PostToOutbox(NewDispatcher(Conductor, editor), username, body); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|
@ -1041,22 +1048,22 @@ func (manager *spiManager) GetOutbox(username string, editor Identity) (result I
|
||||||
//region IPostToInboxResult Implementation
|
//region IPostToInboxResult Implementation
|
||||||
|
|
||||||
type postToInboxResult struct {
|
type postToInboxResult struct {
|
||||||
body string
|
body []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPostToInboxResult(body string, _ interface{}) IPostToInboxResult {
|
func NewPostToInboxResult(body []byte, _ interface{}) IPostToInboxResult {
|
||||||
return &postToInboxResult{
|
return &postToInboxResult{
|
||||||
body: body,
|
body: body,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (result postToInboxResult) Body() string {
|
func (result postToInboxResult) Body() []byte {
|
||||||
return result.body
|
return result.body
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
func (manager *spiManager) PostToInbox(username string, body string, editor Identity) (result IPostToInboxResult, err error) {
|
func (manager *spiManager) PostToInbox(username string, body []byte, editor Identity) (result IPostToInboxResult, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if reason := recover(); reason != nil {
|
if reason := recover(); reason != nil {
|
||||||
err = manager.Error(reason)
|
err = manager.Error(reason)
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ func TestSpiManager_GetFollowing(test *testing.T) {
|
||||||
func TestSpiManager_PostToOutbox(test *testing.T) {
|
func TestSpiManager_PostToOutbox(test *testing.T) {
|
||||||
manager := Conductor.SpiManager()
|
manager := Conductor.SpiManager()
|
||||||
|
|
||||||
result, err := manager.PostToOutbox("username", "context", "activity_type", "to", "attributed_to", "in_reply_to", "content", nil)
|
result, err := manager.PostToOutbox("username", nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
test.Fatal(err)
|
test.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -328,7 +328,7 @@ func TestSpiManager_GetOutbox(test *testing.T) {
|
||||||
func TestSpiManager_PostToInbox(test *testing.T) {
|
func TestSpiManager_PostToInbox(test *testing.T) {
|
||||||
manager := Conductor.SpiManager()
|
manager := Conductor.SpiManager()
|
||||||
|
|
||||||
result, err := manager.PostToInbox("username", "body", nil)
|
result, err := manager.PostToInbox("username", nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
test.Fatal(err)
|
test.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -8,7 +9,9 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-ap/activitypub"
|
||||||
. "github.com/reiver/greatape/components/contracts"
|
. "github.com/reiver/greatape/components/contracts"
|
||||||
|
"github.com/valyala/fastjson"
|
||||||
. "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"
|
||||||
|
|
@ -333,4 +336,23 @@ func (dispatcher *dispatcher) PostActivityStreamSigned(url, keyId, privateKey st
|
||||||
return dispatcher.conductor.RequestActivityStream(http.MethodPost, url, keyId, privateKey, data, output)
|
return dispatcher.conductor.RequestActivityStream(http.MethodPost, url, keyId, privateKey, data, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dispatcher *dispatcher) UnmarshalActivityPubObjectOrLink(data []byte) activitypub.ObjectOrLink {
|
||||||
|
var parser fastjson.Parser
|
||||||
|
value, err := parser.ParseBytes(data)
|
||||||
|
if err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return activitypub.JSONUnmarshalToItem(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dispatcher *dispatcher) UnmarshalActivityPubNote(data []byte) *activitypub.Note {
|
||||||
|
note := &activitypub.Note{}
|
||||||
|
if err := json.Unmarshal(data, note); err != nil {
|
||||||
|
panic(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return note
|
||||||
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ func (dispatcher *dispatcher) NewWebfingerResult(aliases []string, links []IActi
|
||||||
return NewWebfingerResult(aliases, links, subject, nil)
|
return NewWebfingerResult(aliases, links, subject, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) NewGetPackagesResult(body string) IGetPackagesResult {
|
func (dispatcher *dispatcher) NewGetPackagesResult(body []byte) IGetPackagesResult {
|
||||||
return NewGetPackagesResult(body, nil)
|
return NewGetPackagesResult(body, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,15 +60,15 @@ func (dispatcher *dispatcher) NewGetFollowingResult(context string, id string, t
|
||||||
return NewGetFollowingResult(context, id, type_, totalItems, orderedItems, first, nil)
|
return NewGetFollowingResult(context, id, type_, totalItems, orderedItems, first, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) NewPostToOutboxResult() IPostToOutboxResult {
|
func (dispatcher *dispatcher) NewPostToOutboxResult(body []byte) IPostToOutboxResult {
|
||||||
return NewPostToOutboxResult(nil)
|
return NewPostToOutboxResult(body, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetOutboxResult {
|
func (dispatcher *dispatcher) NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetOutboxResult {
|
||||||
return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil)
|
return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dispatcher *dispatcher) NewPostToInboxResult(body string) IPostToInboxResult {
|
func (dispatcher *dispatcher) NewPostToInboxResult(body []byte) IPostToInboxResult {
|
||||||
return NewPostToInboxResult(body, nil)
|
return NewPostToInboxResult(body, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
7
go.mod
7
go.mod
|
|
@ -3,15 +3,20 @@ module github.com/reiver/greatape
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/go-ap/activitypub v0.0.0-20230331173947-f5b96d9450d4
|
||||||
github.com/mitchellh/mapstructure v1.5.0
|
github.com/mitchellh/mapstructure v1.5.0
|
||||||
github.com/robfig/cron v1.2.0
|
github.com/robfig/cron v1.2.0
|
||||||
github.com/sendgrid/sendgrid-go v3.12.0+incompatible
|
github.com/sendgrid/sendgrid-go v3.12.0+incompatible
|
||||||
github.com/xeronith/diamante v1.8.1
|
github.com/valyala/fastjson v1.6.4
|
||||||
|
github.com/xeronith/diamante v1.8.2
|
||||||
google.golang.org/protobuf v1.28.1
|
google.golang.org/protobuf v1.28.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 // indirect
|
||||||
github.com/BurntSushi/toml v0.3.1 // indirect
|
github.com/BurntSushi/toml v0.3.1 // indirect
|
||||||
|
github.com/go-ap/errors v0.0.0-20221205040414-01c1adfc98ea // indirect
|
||||||
|
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73 // indirect
|
||||||
github.com/gofrs/uuid v3.3.0+incompatible // indirect
|
github.com/gofrs/uuid v3.3.0+incompatible // indirect
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
|
||||||
github.com/gorilla/securecookie v1.1.1 // indirect
|
github.com/gorilla/securecookie v1.1.1 // indirect
|
||||||
|
|
|
||||||
15
go.sum
15
go.sum
|
|
@ -1,8 +1,16 @@
|
||||||
|
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 h1:cliQ4HHsCo6xi2oWZYKWW4bly/Ory9FuTpFPRxj/mAg=
|
||||||
|
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078/go.mod h1:g/V2Hjas6Z1UHUp4yIx6bATpNzJ7DYtD0FG3+xARWxs=
|
||||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/go-ap/activitypub v0.0.0-20230331173947-f5b96d9450d4 h1:SGAGW21M92426IL1wW42rDHEkA2kqheNYrkFYVDNLvk=
|
||||||
|
github.com/go-ap/activitypub v0.0.0-20230331173947-f5b96d9450d4/go.mod h1:qw0WNf+PTG69Xu6mVqUluDuKl1VwVYdgntOZQFBZQ48=
|
||||||
|
github.com/go-ap/errors v0.0.0-20221205040414-01c1adfc98ea h1:ywGtLGVjJjMrq4mu35Qmu+NtlhlTk/gTayE6Bb4tQZk=
|
||||||
|
github.com/go-ap/errors v0.0.0-20221205040414-01c1adfc98ea/go.mod h1:SaTNjEEkp0q+w3pUS1ccyEL/lUrHteORlDq/e21mCc8=
|
||||||
|
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73 h1:GMKIYXyXPGIp+hYiWOhfqK4A023HdgisDT4YGgf99mw=
|
||||||
|
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73/go.mod h1:jyveZeGw5LaADntW+UEsMjl3IlIwk+DxlYNsbofQkGA=
|
||||||
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
|
github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6rR7UHz84=
|
||||||
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||||
|
|
@ -44,11 +52,14 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
|
github.com/valyala/fastjson v1.6.3/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
|
||||||
|
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
|
||||||
|
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
|
||||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
github.com/xeronith/diamante v1.8.1 h1:rAEFVfj+3nOrBCGdfOk2F9FuijG+r/Vws5YLEuup/0Y=
|
github.com/xeronith/diamante v1.8.2 h1:XGEKM6sKWNTbuBt8DmFWkRR5XMn7RW02o2QvGi2QZJo=
|
||||||
github.com/xeronith/diamante v1.8.1/go.mod h1:9Tm1tILSKRFRLqvGkG6fTNdLpQbsTZohTLD6xRoWkx8=
|
github.com/xeronith/diamante v1.8.2/go.mod h1:9Tm1tILSKRFRLqvGkG6fTNdLpQbsTZohTLD6xRoWkx8=
|
||||||
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
|
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
|
||||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||||
|
|
|
||||||
Ładowanie…
Reference in New Issue