Porównaj commity

...

5 Commity

Autor SHA1 Wiadomość Data
Xeronith ab7151060e refactor(project): 🎨 improve structure and format of the code 2023-05-03 18:11:06 +03:30
Xeronith d21cfef455 test(components): 🧪 get packages 2023-05-02 21:20:08 +03:30
Xeronith 30ff977c2c feat(app): get packages command 2023-05-02 21:19:51 +03:30
Xeronith 7e5bef51fa feat(components): get packages 2023-05-02 21:17:43 +03:30
Xeronith 53f9bf25cd feat(components): upgrade server pipeline 2023-05-02 21:13:35 +03:30
50 zmienionych plików z 870 dodań i 288 usunięć

Wyświetl plik

@ -20,11 +20,11 @@ type Actor struct {
Url string `json:"url"` Url string `json:"url"`
Summary string `json:"summary"` Summary string `json:"summary"`
Published time.Time `json:"published"` Published time.Time `json:"published"`
Icon Icon `json:"icon,omitempty"` Icon Media `json:"icon,omitempty"`
Image Icon `json:"image,omitempty"` Image Media `json:"image,omitempty"`
} }
type Icon struct { type Media struct {
Height int64 `json:"height,omitempty"` Height int64 `json:"height,omitempty"`
MediaType string `json:"mediaType,omitempty"` MediaType string `json:"mediaType,omitempty"`
Type string `json:"type,omitempty"` Type string `json:"type,omitempty"`
@ -39,11 +39,11 @@ type PublicKey struct {
} }
func UnmarshalActor(data []byte) (Actor, error) { func UnmarshalActor(data []byte) (Actor, error) {
var r Actor var actor Actor
err := json.Unmarshal(data, &r) err := json.Unmarshal(data, &actor)
return r, err return actor, err
} }
func (r *Actor) Marshal() ([]byte, error) { func (actor *Actor) Marshal() ([]byte, error) {
return json.Marshal(r) return json.Marshal(actor)
} }

Wyświetl plik

@ -22,11 +22,11 @@ func NewOrderedCollection(id string, items interface{}, length int) *OrderedColl
} }
func UnmarshalOrderedCollection(data []byte) (OrderedCollection, error) { func UnmarshalOrderedCollection(data []byte) (OrderedCollection, error) {
var o OrderedCollection var orderedCollection OrderedCollection
err := json.Unmarshal(data, &o) err := json.Unmarshal(data, &orderedCollection)
return o, err return orderedCollection, err
} }
func (o *OrderedCollection) Marshal() ([]byte, error) { func (orderedCollection *OrderedCollection) Marshal() ([]byte, error) {
return json.Marshal(o) return json.Marshal(orderedCollection)
} }

Wyświetl plik

@ -11,11 +11,11 @@ type Followers struct {
} }
func UnmarshalFollowers(data []byte) (Followers, error) { func UnmarshalFollowers(data []byte) (Followers, error) {
var o Followers var followers Followers
err := json.Unmarshal(data, &o) err := json.Unmarshal(data, &followers)
return o, err return followers, err
} }
func (o *Followers) Marshal() ([]byte, error) { func (followers *Followers) Marshal() ([]byte, error) {
return json.Marshal(o) return json.Marshal(followers)
} }

Wyświetl plik

@ -0,0 +1,21 @@
package activitypub
import "encoding/json"
type Inbox struct {
Context string `json:"@context"`
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
TotalItems int `json:"totalItems"`
OrderedItems interface{} `json:"orderedItems,omitempty"`
}
func UnmarshalInbox(data []byte) (Inbox, error) {
var inbox Inbox
err := json.Unmarshal(data, &inbox)
return inbox, err
}
func (inbox *Inbox) Marshal() ([]byte, error) {
return json.Marshal(inbox)
}

Wyświetl plik

@ -11,11 +11,11 @@ type Outbox struct {
} }
func UnmarshalOutbox(data []byte) (Outbox, error) { func UnmarshalOutbox(data []byte) (Outbox, error) {
var o Outbox var outbox Outbox
err := json.Unmarshal(data, &o) err := json.Unmarshal(data, &outbox)
return o, err return outbox, err
} }
func (o *Outbox) Marshal() ([]byte, error) { func (outbox *Outbox) Marshal() ([]byte, error) {
return json.Marshal(o) return json.Marshal(outbox)
} }

Wyświetl plik

@ -7,6 +7,7 @@ const (
TypeFollow = "Follow" TypeFollow = "Follow"
TypeAccept = "Accept" TypeAccept = "Accept"
TypeNote = "Note" TypeNote = "Note"
TypeLike = "Like"
TypeOrderedCollection = "OrderedCollection" TypeOrderedCollection = "OrderedCollection"
Public = ActivityStreams + "#Public" Public = ActivityStreams + "#Public"

Wyświetl plik

@ -2,16 +2,6 @@ package activitypub
import "encoding/json" import "encoding/json"
func UnmarshalWebfinger(data []byte) (Webfinger, error) {
var r Webfinger
err := json.Unmarshal(data, &r)
return r, err
}
func (r *Webfinger) Marshal() ([]byte, error) {
return json.Marshal(r)
}
type Webfinger struct { type Webfinger struct {
Aliases []string `json:"aliases"` Aliases []string `json:"aliases"`
Links []Link `json:"links"` Links []Link `json:"links"`
@ -36,3 +26,13 @@ func (webfinger *Webfinger) Self() string {
return self return self
} }
func UnmarshalWebfinger(data []byte) (Webfinger, error) {
var webfinger Webfinger
err := json.Unmarshal(data, &webfinger)
return webfinger, err
}
func (webfinger *Webfinger) Marshal() ([]byte, error) {
return json.Marshal(webfinger)
}

Wyświetl plik

@ -0,0 +1,3 @@
google.golang.org/protobuf version=1.28.1 url=https://github.com/protocolbuffers/protobuf-go
github.com/gorilla/securecookie version=1.1.1 url=https://github.com/gorilla/securecookie
gopkg.in/yaml.v2 version=2.4.0 url=https://github.com/go-yaml/yaml

Wyświetl plik

@ -1,6 +1,9 @@
package spi package spi
import ( import (
"time"
"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"
) )
@ -15,12 +18,40 @@ func GetInbox(x IDispatcher, username string) (IGetInboxResult, error) {
actor := x.Format("%s/u/%s", x.PublicUrl(), identity.Username()) actor := x.Format("%s/u/%s", x.PublicUrl(), identity.Username())
activities := x.FilterActivityPubIncomingActivities(func(activity IActivityPubIncomingActivity) bool {
return activity.From() == actor && activity.To() == ACTIVITY_PUB_PUBLIC
})
var orderedItems ActivityPubActivities var orderedItems ActivityPubActivities
activities.ForEach(func(incomingActivity IActivityPubIncomingActivity) {
published := time.Unix(0, incomingActivity.Timestamp()).Format("2006-01-02T15:04:05Z")
note := activitypub.NewPublicNote(actor, incomingActivity.Content())
noteActivity := note.Wrap(username, x.PublicUrl(), incomingActivity.UniqueIdentifier())
object, _ := x.NewActivityPubObject()
object.SetContext(ACTIVITY_STREAMS)
object.SetType(ACTIVITY_PUB_NOTE)
object.SetId(note.Id)
object.SetContent(note.Content)
activity, _ := x.NewActivityPubActivity()
activity.SetContext(ACTIVITY_STREAMS)
activity.SetType(ACTIVITY_PUB_CREATE)
activity.SetId(x.Format("%s/posts/%s", actor, incomingActivity.UniqueIdentifier()))
activity.SetActor(actor)
activity.SetTo(noteActivity.To.([]string))
activity.SetPublished(published)
activity.SetObject(object)
orderedItems = append(orderedItems, activity)
})
return x.NewGetInboxResult( return x.NewGetInboxResult(
ACTIVITY_STREAMS, // context ACTIVITY_STREAMS, // context
x.Format("%s/inbox", actor), // id x.Format("%s/inbox", actor), // id
ACTIVITY_PUB_ORDERED_COLLECTION, // type ACTIVITY_PUB_ORDERED_COLLECTION, // type
0, // totalItems int32(len(orderedItems)), // totalItems
orderedItems, // orderedItems orderedItems, // orderedItems
"", // first "", // first
), nil ), nil

Wyświetl plik

@ -0,0 +1,14 @@
package spi
import (
_ "embed"
. "github.com/reiver/greatape/components/contracts"
)
//go:embed _packages.txt
var packages string
func GetPackages(x IDispatcher) (IGetPackagesResult, error) {
return x.NewGetPackagesResult(packages), nil
}

Wyświetl plik

@ -1,10 +1,110 @@
package spi package spi
import ( import (
"encoding/json"
"github.com/mitchellh/mapstructure"
"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 PostToInbox(x IDispatcher, username string) (IPostToInboxResult, error) { func PostToInbox(x IDispatcher, username string, body string) (IPostToInboxResult, error) {
return nil, ERROR_NOT_IMPLEMENTED identities := x.FilterIdentities(func(identity IIdentity) bool {
return identity.Username() == username
})
x.Assert(identities.HasExactlyOneItem()).Or(ERROR_USER_NOT_FOUND)
identity := identities.First()
object := &activitypub.Object{}
if err := json.Unmarshal([]byte(body), object); err != nil {
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_OBJECT
}
keyId := x.Format("%s/u/%s#main-key", x.PublicUrl(), username)
switch object.Type {
case activitypub.TypeFollow:
{
activity := &activitypub.Activity{}
if err := json.Unmarshal([]byte(body), activity); err != nil {
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_ACTIVITY
}
url := activity.Actor
var inbox string
{
actor := &activitypub.Actor{}
if err := x.GetActivityStreamSigned(url, keyId, identity.PrivateKey(), nil, actor); err != nil {
return nil, err
}
inbox = actor.Inbox
}
data, err := json.Marshal(activity)
if err != nil {
return nil, err
}
follower := x.AddActivityPubFollower(
activity.Actor,
inbox,
x.Format("%s/u/%s", x.PublicUrl(), username),
string(data),
false,
)
data, _ = json.Marshal(&activitypub.Activity{
Context: activitypub.ActivityStreams,
ID: x.Format("%s/%s", x.PublicUrl(), x.GenerateUUID()),
Type: activitypub.TypeAccept,
Actor: x.Format("%s/u/%s", x.PublicUrl(), username),
Object: activity,
})
if err := x.PostActivityStreamSigned(inbox, keyId, identity.PrivateKey(), data, nil); err != nil {
return nil, err
}
follower.UpdateAccepted(true, x.Identity())
}
case activitypub.TypeCreate:
{
activity := &activitypub.Activity{}
if err := json.Unmarshal([]byte(body), activity); err != nil {
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_ACTIVITY
}
switch activity.Object.(map[string]interface{})["type"] {
case activitypub.TypeNote:
note := &activitypub.Note{}
if err := mapstructure.Decode(activity.Object, note); err != nil {
return nil, ERROR_UNKNOWN_ACTIVITY_PUB_ACTIVITY
}
raw, _ := json.Marshal(note)
x.AddActivityPubIncomingActivity(
identity.Id(),
x.GenerateUUID(),
x.UnixNano(),
note.AttributedTo,
note.To[0],
note.Content,
string(raw),
)
default:
return nil, ERROR_INVALID_PARAMETERS
}
}
default:
{
return nil, ERROR_INVALID_PARAMETERS
}
}
return x.NewPostToInboxResult(body), nil
} }

Wyświetl plik

@ -134,6 +134,16 @@ func TestWebfingerApi(test *testing.T) {
} }
} }
func TestGetPackagesApi(test *testing.T) {
input := &GetPackagesRequest{}
if output, err := api.GetPackages(input); err != nil {
test.Fatal(err)
} else if output == nil {
test.Fail()
}
}
func TestGetActorApi(test *testing.T) { func TestGetActorApi(test *testing.T) {
input := &GetActorRequest{ input := &GetActorRequest{
Username: "username", Username: "username",
@ -228,6 +238,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",
} }
if output, err := api.PostToInbox(input); err != nil { if output, err := api.PostToInbox(input); err != nil {

Wyświetl plik

@ -39,6 +39,7 @@ func (handler *authorizeInteractionHandler) HandlerFunc() HttpHandlerFunc {
AUTHORIZE_INTERACTION_RESULT, AUTHORIZE_INTERACTION_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -38,6 +38,7 @@ func (handler *echoHandler) HandlerFunc() HttpHandlerFunc {
ECHO_RESULT, ECHO_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -14,6 +14,7 @@ func (factory *httpHandlerFactory) Handlers() []IHttpHandler {
UpdateProfileByUserHandler(), // │ P . /api/v1/profile UpdateProfileByUserHandler(), // │ P . /api/v1/profile
LogoutHandler(), // │ P . /api/v1/logout LogoutHandler(), // │ P . /api/v1/logout
WebfingerHandler(), // │ G . /.well-known/webfinger WebfingerHandler(), // │ G . /.well-known/webfinger
GetPackagesHandler(), // │ G . /.well-known/packages.txt
GetActorHandler(), // │ G . /u/:username GetActorHandler(), // │ G . /u/:username
FollowActorHandler(), // │ G . /u/:username/follow FollowActorHandler(), // │ G . /u/:username/follow
AuthorizeInteractionHandler(), // │ G . /authorize_interaction AuthorizeInteractionHandler(), // │ G . /authorize_interaction

Wyświetl plik

@ -40,6 +40,7 @@ func (handler *followActorHandler) HandlerFunc() HttpHandlerFunc {
FOLLOW_ACTOR_RESULT, FOLLOW_ACTOR_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
true, true,
); err != nil { ); err != nil {
return err return err

Wyświetl plik

@ -39,6 +39,7 @@ func (handler *getActorHandler) HandlerFunc() HttpHandlerFunc {
GET_ACTOR_RESULT, GET_ACTOR_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -39,6 +39,7 @@ func (handler *getFollowersHandler) HandlerFunc() HttpHandlerFunc {
GET_FOLLOWERS_RESULT, GET_FOLLOWERS_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -39,6 +39,7 @@ func (handler *getFollowingHandler) HandlerFunc() HttpHandlerFunc {
GET_FOLLOWING_RESULT, GET_FOLLOWING_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -39,6 +39,7 @@ func (handler *getInboxHandler) HandlerFunc() HttpHandlerFunc {
GET_INBOX_RESULT, GET_INBOX_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -39,6 +39,7 @@ func (handler *getOutboxHandler) HandlerFunc() HttpHandlerFunc {
GET_OUTBOX_RESULT, GET_OUTBOX_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -0,0 +1,49 @@
package handlers
import (
"net/http"
. "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/network/http"
pipeline "github.com/xeronith/diamante/network/http"
)
type getPackagesHandler struct {
}
func GetPackagesHandler() IHttpHandler {
return &getPackagesHandler{}
}
func (handler *getPackagesHandler) Method() string {
return http.MethodGet
}
func (handler *getPackagesHandler) Path() string {
return "/.well-known/packages.txt"
}
func (handler *getPackagesHandler) HandlerFunc() HttpHandlerFunc {
return func(x IServerDispatcher) error {
request := &GetPackagesRequest{}
result := &GetPackagesResult{}
onRequestUnmarshalled := func(request *GetPackagesRequest) {
}
onRequestProcessed := func(output *GetPackagesResult) (string, []byte) {
return "text/plain", []byte(output.Body)
}
return pipeline.Handle(x,
"get_packages",
GET_PACKAGES_REQUEST,
GET_PACKAGES_RESULT,
request, result,
onRequestUnmarshalled,
onRequestProcessed,
false,
)
}
}

Wyświetl plik

@ -38,6 +38,7 @@ func (handler *getProfileByUserHandler) HandlerFunc() HttpHandlerFunc {
GET_PROFILE_BY_USER_RESULT, GET_PROFILE_BY_USER_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -38,6 +38,7 @@ func (handler *loginHandler) HandlerFunc() HttpHandlerFunc {
LOGIN_RESULT, LOGIN_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -38,6 +38,7 @@ func (handler *logoutHandler) HandlerFunc() HttpHandlerFunc {
LOGOUT_RESULT, LOGOUT_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -33,12 +33,17 @@ func (handler *postToInboxHandler) HandlerFunc() HttpHandlerFunc {
request.Username = x.Param("username") request.Username = x.Param("username")
} }
onRequestProcessed := func(output *PostToInboxResult) (string, []byte) {
return "application/activity+json; charset=utf-8", []byte(output.Body)
}
return pipeline.Handle(x, return pipeline.Handle(x,
"post_to_inbox", "post_to_inbox",
POST_TO_INBOX_REQUEST, POST_TO_INBOX_REQUEST,
POST_TO_INBOX_RESULT, POST_TO_INBOX_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
onRequestProcessed,
false, false,
) )
} }

Wyświetl plik

@ -39,6 +39,7 @@ func (handler *postToOutboxHandler) HandlerFunc() HttpHandlerFunc {
POST_TO_OUTBOX_RESULT, POST_TO_OUTBOX_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -38,6 +38,7 @@ func (handler *signupHandler) HandlerFunc() HttpHandlerFunc {
SIGNUP_RESULT, SIGNUP_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -38,6 +38,7 @@ func (handler *updateProfileByUserHandler) HandlerFunc() HttpHandlerFunc {
UPDATE_PROFILE_BY_USER_RESULT, UPDATE_PROFILE_BY_USER_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -38,6 +38,7 @@ func (handler *verifyHandler) HandlerFunc() HttpHandlerFunc {
VERIFY_RESULT, VERIFY_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -39,6 +39,7 @@ func (handler *webfingerHandler) HandlerFunc() HttpHandlerFunc {
WEBFINGER_RESULT, WEBFINGER_RESULT,
request, result, request, result,
onRequestUnmarshalled, onRequestUnmarshalled,
nil,
false, false,
) )
} }

Wyświetl plik

@ -15,6 +15,7 @@ func (factory *operationFactory) Operations() []IOperation {
UpdateProfileByUserOperation(), UpdateProfileByUserOperation(),
LogoutOperation(), LogoutOperation(),
WebfingerOperation(), WebfingerOperation(),
GetPackagesOperation(),
GetActorOperation(), GetActorOperation(),
FollowActorOperation(), FollowActorOperation(),
AuthorizeInteractionOperation(), AuthorizeInteractionOperation(),

Wyświetl plik

@ -0,0 +1,51 @@
package operations
import (
. "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service"
. "github.com/xeronith/diamante/contracts/system"
. "github.com/xeronith/diamante/operation"
)
type getPackagesOperation struct {
Operation
run func(IContext, *GetPackagesRequest) (*GetPackagesResult, error)
}
func GetPackagesOperation() IOperation {
return &getPackagesOperation{
run: GetPackagesService,
}
}
func (operation *getPackagesOperation) Id() (ID, ID) {
return GET_PACKAGES_REQUEST, GET_PACKAGES_RESULT
}
func (operation *getPackagesOperation) InputContainer() Pointer {
return new(GetPackagesRequest)
}
func (operation *getPackagesOperation) OutputContainer() Pointer {
return new(GetPackagesResult)
}
func (operation *getPackagesOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
return operation.run(context, payload.(*GetPackagesRequest))
}
/*
func (operation *getPackagesOperation) ExecutionTimeLimits() (Duration, Duration, Duration) {
var (
TIME_LIMIT_WARNING Duration = 20_000_000
TIME_LIMIT_ALERT Duration = 35_000_000
TIME_LIMIT_CRITICAL Duration = 50_000_000
)
return TIME_LIMIT_WARNING, TIME_LIMIT_ALERT, TIME_LIMIT_CRITICAL
}
*/

Wyświetl plik

@ -114,6 +114,15 @@ message WebfingerResult {
string subject = 0x00000003; string subject = 0x00000003;
} }
// API: GetPackages
//-----------------------------------------------------------
message GetPackagesRequest {
}
message GetPackagesResult {
string body = 0x00000001;
}
// API: GetActor // API: GetActor
//----------------------------------------------------------- //-----------------------------------------------------------
message GetActorRequest { message GetActorRequest {
@ -224,9 +233,11 @@ message GetOutboxResult {
//----------------------------------------------------------- //-----------------------------------------------------------
message PostToInboxRequest { message PostToInboxRequest {
string username = 0x00000001; string username = 0x00000001;
string body = 0x00000002;
} }
message PostToInboxResult { message PostToInboxResult {
string body = 0x00000001;
} }
// API: GetInbox // API: GetInbox

Wyświetl plik

@ -0,0 +1,29 @@
package services
import (
. "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/contracts"
"github.com/reiver/greatape/components/core"
. "github.com/xeronith/diamante/contracts/service"
)
// noinspection GoUnusedParameter
func GetPackagesService(context IContext, input *GetPackagesRequest) (result *GetPackagesResult, err error) {
conductor := core.Conductor
_ = GET_PACKAGES_REQUEST
conductor.LogRemoteCall(context, INITIALIZE, "get_packages", input, result, err)
defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_packages", input, result, err) }()
_result, _err := conductor.GetPackages(context.Identity())
if _err != nil {
err = _err
return nil, err
}
_ = _result
result = context.ResultContainer().(*GetPackagesResult)
result.Body = _result.Body()
return result, nil
}

Wyświetl plik

@ -15,7 +15,7 @@ func PostToInboxService(context IContext, input *PostToInboxRequest) (result *Po
conductor.LogRemoteCall(context, INITIALIZE, "post_to_inbox", input, result, err) conductor.LogRemoteCall(context, INITIALIZE, "post_to_inbox", input, result, err)
defer func() { conductor.LogRemoteCall(context, FINALIZE, "post_to_inbox", input, result, err) }() defer func() { conductor.LogRemoteCall(context, FINALIZE, "post_to_inbox", input, result, err) }()
_result, _err := conductor.PostToInbox(input.Username, context.Identity()) _result, _err := conductor.PostToInbox(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 PostToInboxService(context IContext, input *PostToInboxRequest) (result *Po
_ = _result _ = _result
result = context.ResultContainer().(*PostToInboxResult) result = context.ResultContainer().(*PostToInboxResult)
result.Body = _result.Body()
return result, nil return result, nil
} }

Wyświetl plik

@ -15,6 +15,7 @@ type IApi interface {
UpdateProfileByUser(*UpdateProfileByUserRequest) (*UpdateProfileByUserResult, error) UpdateProfileByUser(*UpdateProfileByUserRequest) (*UpdateProfileByUserResult, error)
Logout(*LogoutRequest) (*LogoutResult, error) Logout(*LogoutRequest) (*LogoutResult, error)
Webfinger(*WebfingerRequest) (*WebfingerResult, error) Webfinger(*WebfingerRequest) (*WebfingerResult, error)
GetPackages(*GetPackagesRequest) (*GetPackagesResult, error)
GetActor(*GetActorRequest) (*GetActorResult, error) GetActor(*GetActorRequest) (*GetActorResult, error)
FollowActor(*FollowActorRequest) (*FollowActorResult, error) FollowActor(*FollowActorRequest) (*FollowActorResult, error)
AuthorizeInteraction(*AuthorizeInteractionRequest) (*AuthorizeInteractionResult, error) AuthorizeInteraction(*AuthorizeInteractionRequest) (*AuthorizeInteractionResult, error)

Wyświetl plik

@ -40,6 +40,10 @@ const (
WEBFINGER_REQUEST = 0x01FD357C WEBFINGER_REQUEST = 0x01FD357C
WEBFINGER_RESULT = 0xCC81EC52 WEBFINGER_RESULT = 0xCC81EC52
//GetPackagesOperation
GET_PACKAGES_REQUEST = 0x157C555E
GET_PACKAGES_RESULT = 0x4CBD814E
//GetActorOperation //GetActorOperation
GET_ACTOR_REQUEST = 0x5C4AC410 GET_ACTOR_REQUEST = 0x5C4AC410
GET_ACTOR_RESULT = 0x136B82A8 GET_ACTOR_RESULT = 0x136B82A8
@ -95,6 +99,8 @@ var OPCODES = Opcodes{
0x9412D17F: "Logout", 0x9412D17F: "Logout",
0x01FD357C: "WEBFINGER", 0x01FD357C: "WEBFINGER",
0xCC81EC52: "Webfinger", 0xCC81EC52: "Webfinger",
0x157C555E: "GET_PACKAGES",
0x4CBD814E: "GetPackages",
0x5C4AC410: "GET_ACTOR", 0x5C4AC410: "GET_ACTOR",
0x136B82A8: "GetActor", 0x136B82A8: "GetActor",
0xD30C2420: "FOLLOW_ACTOR", 0xD30C2420: "FOLLOW_ACTOR",

Wyświetl plik

@ -62,6 +62,7 @@ type (
UpdateProfileByUser(displayName string, avatar string, banner string, summary string, github string, editor Identity) (IUpdateProfileByUserResult, error) UpdateProfileByUser(displayName string, avatar string, banner string, summary string, github string, editor Identity) (IUpdateProfileByUserResult, error)
Logout(editor Identity) (ILogoutResult, error) Logout(editor Identity) (ILogoutResult, error)
Webfinger(resource string, editor Identity) (IWebfingerResult, error) Webfinger(resource string, editor Identity) (IWebfingerResult, 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, acct string, editor Identity) (IFollowActorResult, error)
AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error) AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error)
@ -69,7 +70,7 @@ type (
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, context string, activityType string, to string, attributedTo string, inReplyTo string, content string, editor Identity) (IPostToOutboxResult, error)
GetOutbox(username string, editor Identity) (IGetOutboxResult, error) GetOutbox(username string, editor Identity) (IGetOutboxResult, error)
PostToInbox(username string, editor Identity) (IPostToInboxResult, error) PostToInbox(username string, body string, editor Identity) (IPostToInboxResult, error)
GetInbox(username string, editor Identity) (IGetInboxResult, error) GetInbox(username string, editor Identity) (IGetInboxResult, error)
} }
@ -117,6 +118,10 @@ type (
Subject() string Subject() string
} }
IGetPackagesResult interface {
Body() string
}
IGetActorResult interface { IGetActorResult interface {
Context() []string Context() []string
Id() string Id() string
@ -175,6 +180,7 @@ type (
} }
IPostToInboxResult interface { IPostToInboxResult interface {
Body() string
} }
IGetInboxResult interface { IGetInboxResult interface {

Wyświetl plik

@ -265,6 +265,7 @@ type (
UpdateProfileByUser(displayName string, avatar string, banner string, summary string, github string, editor Identity) (IUpdateProfileByUserResult, error) UpdateProfileByUser(displayName string, avatar string, banner string, summary string, github string, editor Identity) (IUpdateProfileByUserResult, error)
Logout(editor Identity) (ILogoutResult, error) Logout(editor Identity) (ILogoutResult, error)
Webfinger(resource string, editor Identity) (IWebfingerResult, error) Webfinger(resource string, editor Identity) (IWebfingerResult, 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, acct string, editor Identity) (IFollowActorResult, error)
AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error) AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error)
@ -272,7 +273,7 @@ type (
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, context string, activityType string, to string, attributedTo string, inReplyTo string, content string, editor Identity) (IPostToOutboxResult, error)
GetOutbox(username string, editor Identity) (IGetOutboxResult, error) GetOutbox(username string, editor Identity) (IGetOutboxResult, error)
PostToInbox(username string, editor Identity) (IPostToInboxResult, error) PostToInbox(username string, body string, 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)
@ -300,6 +301,7 @@ 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
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
@ -307,7 +309,7 @@ type (
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(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(ignored interface{}) IPostToInboxResult NewPostToInboxResult(body string, 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
} }

Wyświetl plik

@ -1039,6 +1039,7 @@ type IDispatcher interface {
UpdateProfileByUser(displayName string, avatar string, banner string, summary string, github string) (IUpdateProfileByUserResult, error) UpdateProfileByUser(displayName string, avatar string, banner string, summary string, github string) (IUpdateProfileByUserResult, error)
Logout() (ILogoutResult, error) Logout() (ILogoutResult, error)
Webfinger(resource string) (IWebfingerResult, error) Webfinger(resource string) (IWebfingerResult, error)
GetPackages() (IGetPackagesResult, error)
GetActor(username string) (IGetActorResult, error) GetActor(username string) (IGetActorResult, error)
FollowActor(username string, acct string) (IFollowActorResult, error) FollowActor(username string, acct string) (IFollowActorResult, error)
AuthorizeInteraction(uri string) (IAuthorizeInteractionResult, error) AuthorizeInteraction(uri string) (IAuthorizeInteractionResult, error)
@ -1046,7 +1047,7 @@ type IDispatcher interface {
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, context string, activityType string, to string, attributedTo string, inReplyTo string, content string) (IPostToOutboxResult, error)
GetOutbox(username string) (IGetOutboxResult, error) GetOutbox(username string) (IGetOutboxResult, error)
PostToInbox(username string) (IPostToInboxResult, error) PostToInbox(username string, body string) (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.
@ -1133,6 +1134,8 @@ type IDispatcher interface {
NewLogoutResult() ILogoutResult NewLogoutResult() ILogoutResult
// 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(body string) 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.
@ -1148,7 +1151,7 @@ type IDispatcher interface {
// 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() IPostToInboxResult NewPostToInboxResult(body string) 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.

Wyświetl plik

@ -95,6 +95,16 @@ func (api *api) Webfinger(request *WebfingerRequest) (*WebfingerResult, error) {
} }
} }
func (api *api) GetPackages(request *GetPackagesRequest) (*GetPackagesResult, error) {
result, err := api.call(GET_PACKAGES_REQUEST, request)
if err != nil {
return nil, err
} else {
return result.(*GetPackagesResult), nil
}
}
func (api *api) GetActor(request *GetActorRequest) (*GetActorResult, error) { func (api *api) GetActor(request *GetActorRequest) (*GetActorResult, error) {
result, err := api.call(GET_ACTOR_REQUEST, request) result, err := api.call(GET_ACTOR_REQUEST, request)
@ -195,6 +205,7 @@ func init() {
API_RESULT[UPDATE_PROFILE_BY_USER_RESULT] = UpdateProfileByUserResult{} API_RESULT[UPDATE_PROFILE_BY_USER_RESULT] = UpdateProfileByUserResult{}
API_RESULT[LOGOUT_RESULT] = LogoutResult{} API_RESULT[LOGOUT_RESULT] = LogoutResult{}
API_RESULT[WEBFINGER_RESULT] = WebfingerResult{} API_RESULT[WEBFINGER_RESULT] = WebfingerResult{}
API_RESULT[GET_PACKAGES_RESULT] = GetPackagesResult{}
API_RESULT[GET_ACTOR_RESULT] = GetActorResult{} API_RESULT[GET_ACTOR_RESULT] = GetActorResult{}
API_RESULT[FOLLOW_ACTOR_RESULT] = FollowActorResult{} API_RESULT[FOLLOW_ACTOR_RESULT] = FollowActorResult{}
API_RESULT[AUTHORIZE_INTERACTION_RESULT] = AuthorizeInteractionResult{} API_RESULT[AUTHORIZE_INTERACTION_RESULT] = AuthorizeInteractionResult{}

Wyświetl plik

@ -1127,6 +1127,10 @@ func (conductor *conductor) Webfinger(resource string, editor Identity) (IWebfin
return conductor.spiManager.Webfinger(resource, editor) return conductor.spiManager.Webfinger(resource, editor)
} }
func (conductor *conductor) GetPackages(editor Identity) (IGetPackagesResult, error) {
return conductor.spiManager.GetPackages(editor)
}
func (conductor *conductor) GetActor(username string, editor Identity) (IGetActorResult, error) { func (conductor *conductor) GetActor(username string, editor Identity) (IGetActorResult, error) {
return conductor.spiManager.GetActor(username, editor) return conductor.spiManager.GetActor(username, editor)
} }
@ -1155,8 +1159,8 @@ func (conductor *conductor) GetOutbox(username string, editor Identity) (IGetOut
return conductor.spiManager.GetOutbox(username, editor) return conductor.spiManager.GetOutbox(username, editor)
} }
func (conductor *conductor) PostToInbox(username string, editor Identity) (IPostToInboxResult, error) { func (conductor *conductor) PostToInbox(username string, body string, editor Identity) (IPostToInboxResult, error) {
return conductor.spiManager.PostToInbox(username, editor) return conductor.spiManager.PostToInbox(username, body, editor)
} }
func (conductor *conductor) GetInbox(username string, editor Identity) (IGetInboxResult, error) { func (conductor *conductor) GetInbox(username string, editor Identity) (IGetInboxResult, error) {
@ -1263,6 +1267,10 @@ 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 {
return NewGetPackagesResult(body, nil)
}
func (conductor *conductor) 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, _ interface{}) IGetActorResult { func (conductor *conductor) 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, _ interface{}) IGetActorResult {
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)
} }
@ -1291,8 +1299,8 @@ func (conductor *conductor) NewGetOutboxResult(context string, id string, type_
return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil) return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil)
} }
func (conductor *conductor) NewPostToInboxResult(_ interface{}) IPostToInboxResult { func (conductor *conductor) NewPostToInboxResult(body string, _ interface{}) IPostToInboxResult {
return NewPostToInboxResult(nil) return NewPostToInboxResult(body, nil)
} }
func (conductor *conductor) NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, _ interface{}) IGetInboxResult { func (conductor *conductor) NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, _ interface{}) IGetInboxResult {

Wyświetl plik

@ -267,6 +267,10 @@ func (dispatcher *dispatcher) Webfinger(resource string) (IWebfingerResult, erro
return dispatcher.conductor.SpiManager().Webfinger(resource, dispatcher.identity) return dispatcher.conductor.SpiManager().Webfinger(resource, dispatcher.identity)
} }
func (dispatcher *dispatcher) GetPackages() (IGetPackagesResult, error) {
return dispatcher.conductor.SpiManager().GetPackages(dispatcher.identity)
}
func (dispatcher *dispatcher) GetActor(username string) (IGetActorResult, error) { func (dispatcher *dispatcher) GetActor(username string) (IGetActorResult, error) {
return dispatcher.conductor.SpiManager().GetActor(username, dispatcher.identity) return dispatcher.conductor.SpiManager().GetActor(username, dispatcher.identity)
} }
@ -295,8 +299,8 @@ func (dispatcher *dispatcher) GetOutbox(username string) (IGetOutboxResult, erro
return dispatcher.conductor.SpiManager().GetOutbox(username, dispatcher.identity) return dispatcher.conductor.SpiManager().GetOutbox(username, dispatcher.identity)
} }
func (dispatcher *dispatcher) PostToInbox(username string) (IPostToInboxResult, error) { func (dispatcher *dispatcher) PostToInbox(username string, body string) (IPostToInboxResult, error) {
return dispatcher.conductor.SpiManager().PostToInbox(username, dispatcher.identity) return dispatcher.conductor.SpiManager().PostToInbox(username, body, dispatcher.identity)
} }
func (dispatcher *dispatcher) GetInbox(username string) (IGetInboxResult, error) { func (dispatcher *dispatcher) GetInbox(username string) (IGetInboxResult, error) {

Wyświetl plik

@ -585,6 +585,41 @@ func (manager *spiManager) Webfinger(resource string, editor Identity) (result I
} }
} }
//region IGetPackagesResult Implementation
type getPackagesResult struct {
body string
}
func NewGetPackagesResult(body string, _ interface{}) IGetPackagesResult {
return &getPackagesResult{
body: body,
}
}
func (result getPackagesResult) Body() string {
return result.body
}
//endregion
func (manager *spiManager) GetPackages(editor Identity) (result IGetPackagesResult, err error) {
defer func() {
if reason := recover(); reason != nil {
err = manager.Error(reason)
}
}()
editor.Lock(GET_PACKAGES_REQUEST)
defer editor.Unlock(GET_PACKAGES_REQUEST)
if result, err = commands.GetPackages(NewDispatcher(Conductor, editor)); err != nil {
return nil, err
} else {
return result, nil
}
}
//region IGetActorResult Implementation //region IGetActorResult Implementation
type getActorResult struct { type getActorResult struct {
@ -1006,15 +1041,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
} }
func NewPostToInboxResult(_ interface{}) IPostToInboxResult { func NewPostToInboxResult(body string, _ interface{}) IPostToInboxResult {
return &postToInboxResult{} return &postToInboxResult{
body: body,
}
}
func (result postToInboxResult) Body() string {
return result.body
} }
//endregion //endregion
func (manager *spiManager) PostToInbox(username string, editor Identity) (result IPostToInboxResult, err error) { func (manager *spiManager) PostToInbox(username string, body string, 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)
@ -1024,7 +1066,7 @@ func (manager *spiManager) PostToInbox(username string, editor Identity) (result
editor.Lock(POST_TO_INBOX_REQUEST) editor.Lock(POST_TO_INBOX_REQUEST)
defer editor.Unlock(POST_TO_INBOX_REQUEST) defer editor.Unlock(POST_TO_INBOX_REQUEST)
if result, err = commands.PostToInbox(NewDispatcher(Conductor, editor), username); err != nil { if result, err = commands.PostToInbox(NewDispatcher(Conductor, editor), username, body); err != nil {
return nil, err return nil, err
} else { } else {
return result, nil return result, nil

Wyświetl plik

@ -237,6 +237,17 @@ func TestSpiManager_Webfinger(test *testing.T) {
_ = result _ = result
} }
func TestSpiManager_GetPackages(test *testing.T) {
manager := Conductor.SpiManager()
result, err := manager.GetPackages(nil)
if err != nil {
test.Fatal(err)
}
_ = result
}
func TestSpiManager_GetActor(test *testing.T) { func TestSpiManager_GetActor(test *testing.T) {
manager := Conductor.SpiManager() manager := Conductor.SpiManager()
@ -317,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", nil) result, err := manager.PostToInbox("username", "body", nil)
if err != nil { if err != nil {
test.Fatal(err) test.Fatal(err)
} }

Wyświetl plik

@ -36,6 +36,10 @@ 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 {
return NewGetPackagesResult(body, nil)
}
func (dispatcher *dispatcher) 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 { func (dispatcher *dispatcher) 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 {
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)
} }
@ -64,8 +68,8 @@ func (dispatcher *dispatcher) NewGetOutboxResult(context string, id string, type
return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil) return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil)
} }
func (dispatcher *dispatcher) NewPostToInboxResult() IPostToInboxResult { func (dispatcher *dispatcher) NewPostToInboxResult(body string) IPostToInboxResult {
return NewPostToInboxResult(nil) return NewPostToInboxResult(body, nil)
} }
func (dispatcher *dispatcher) NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetInboxResult { func (dispatcher *dispatcher) NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetInboxResult {

3
go.mod
Wyświetl plik

@ -3,9 +3,10 @@ module github.com/reiver/greatape
go 1.19 go 1.19
require ( require (
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.7.8 github.com/xeronith/diamante v1.8.1
google.golang.org/protobuf v1.28.1 google.golang.org/protobuf v1.28.1
) )

6
go.sum
Wyświetl plik

@ -29,6 +29,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ= github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
@ -45,8 +47,8 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC
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.7.8 h1:Mx6nXm3eqYo79dD3D0SoX/aSYa/23QSYGrVXwQdEuok= github.com/xeronith/diamante v1.8.1 h1:rAEFVfj+3nOrBCGdfOk2F9FuijG+r/Vws5YLEuup/0Y=
github.com/xeronith/diamante v1.7.8/go.mod h1:9Tm1tILSKRFRLqvGkG6fTNdLpQbsTZohTLD6xRoWkx8= github.com/xeronith/diamante v1.8.1/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=