kopia lustrzana https://github.com/reiver/greatape
Porównaj commity
5 Commity
b7cfb2e4d3
...
ab7151060e
Autor | SHA1 | Data |
---|---|---|
Xeronith | ab7151060e | |
Xeronith | d21cfef455 | |
Xeronith | 30ff977c2c | |
Xeronith | 7e5bef51fa | |
Xeronith | 53f9bf25cd |
|
@ -20,11 +20,11 @@ type Actor struct {
|
|||
Url string `json:"url"`
|
||||
Summary string `json:"summary"`
|
||||
Published time.Time `json:"published"`
|
||||
Icon Icon `json:"icon,omitempty"`
|
||||
Image Icon `json:"image,omitempty"`
|
||||
Icon Media `json:"icon,omitempty"`
|
||||
Image Media `json:"image,omitempty"`
|
||||
}
|
||||
|
||||
type Icon struct {
|
||||
type Media struct {
|
||||
Height int64 `json:"height,omitempty"`
|
||||
MediaType string `json:"mediaType,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
|
@ -39,11 +39,11 @@ type PublicKey struct {
|
|||
}
|
||||
|
||||
func UnmarshalActor(data []byte) (Actor, error) {
|
||||
var r Actor
|
||||
err := json.Unmarshal(data, &r)
|
||||
return r, err
|
||||
var actor Actor
|
||||
err := json.Unmarshal(data, &actor)
|
||||
return actor, err
|
||||
}
|
||||
|
||||
func (r *Actor) Marshal() ([]byte, error) {
|
||||
return json.Marshal(r)
|
||||
func (actor *Actor) Marshal() ([]byte, error) {
|
||||
return json.Marshal(actor)
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ func NewOrderedCollection(id string, items interface{}, length int) *OrderedColl
|
|||
}
|
||||
|
||||
func UnmarshalOrderedCollection(data []byte) (OrderedCollection, error) {
|
||||
var o OrderedCollection
|
||||
err := json.Unmarshal(data, &o)
|
||||
return o, err
|
||||
var orderedCollection OrderedCollection
|
||||
err := json.Unmarshal(data, &orderedCollection)
|
||||
return orderedCollection, err
|
||||
}
|
||||
|
||||
func (o *OrderedCollection) Marshal() ([]byte, error) {
|
||||
return json.Marshal(o)
|
||||
func (orderedCollection *OrderedCollection) Marshal() ([]byte, error) {
|
||||
return json.Marshal(orderedCollection)
|
||||
}
|
||||
|
|
|
@ -11,11 +11,11 @@ type Followers struct {
|
|||
}
|
||||
|
||||
func UnmarshalFollowers(data []byte) (Followers, error) {
|
||||
var o Followers
|
||||
err := json.Unmarshal(data, &o)
|
||||
return o, err
|
||||
var followers Followers
|
||||
err := json.Unmarshal(data, &followers)
|
||||
return followers, err
|
||||
}
|
||||
|
||||
func (o *Followers) Marshal() ([]byte, error) {
|
||||
return json.Marshal(o)
|
||||
func (followers *Followers) Marshal() ([]byte, error) {
|
||||
return json.Marshal(followers)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
|
@ -11,11 +11,11 @@ type Outbox struct {
|
|||
}
|
||||
|
||||
func UnmarshalOutbox(data []byte) (Outbox, error) {
|
||||
var o Outbox
|
||||
err := json.Unmarshal(data, &o)
|
||||
return o, err
|
||||
var outbox Outbox
|
||||
err := json.Unmarshal(data, &outbox)
|
||||
return outbox, err
|
||||
}
|
||||
|
||||
func (o *Outbox) Marshal() ([]byte, error) {
|
||||
return json.Marshal(o)
|
||||
func (outbox *Outbox) Marshal() ([]byte, error) {
|
||||
return json.Marshal(outbox)
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ const (
|
|||
TypeFollow = "Follow"
|
||||
TypeAccept = "Accept"
|
||||
TypeNote = "Note"
|
||||
TypeLike = "Like"
|
||||
TypeOrderedCollection = "OrderedCollection"
|
||||
|
||||
Public = ActivityStreams + "#Public"
|
||||
|
|
|
@ -2,16 +2,6 @@ package activitypub
|
|||
|
||||
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 {
|
||||
Aliases []string `json:"aliases"`
|
||||
Links []Link `json:"links"`
|
||||
|
@ -36,3 +26,13 @@ func (webfinger *Webfinger) Self() string {
|
|||
|
||||
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)
|
||||
}
|
||||
|
|
|
@ -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
|
|
@ -1,6 +1,9 @@
|
|||
package spi
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/reiver/greatape/app/activitypub"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "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())
|
||||
|
||||
activities := x.FilterActivityPubIncomingActivities(func(activity IActivityPubIncomingActivity) bool {
|
||||
return activity.From() == actor && activity.To() == ACTIVITY_PUB_PUBLIC
|
||||
})
|
||||
|
||||
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(
|
||||
ACTIVITY_STREAMS, // context
|
||||
x.Format("%s/inbox", actor), // id
|
||||
ACTIVITY_PUB_ORDERED_COLLECTION, // type
|
||||
0, // totalItems
|
||||
int32(len(orderedItems)), // totalItems
|
||||
orderedItems, // orderedItems
|
||||
"", // first
|
||||
), nil
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -1,10 +1,110 @@
|
|||
package spi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/reiver/greatape/app/activitypub"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
)
|
||||
|
||||
func PostToInbox(x IDispatcher, username string) (IPostToInboxResult, error) {
|
||||
return nil, ERROR_NOT_IMPLEMENTED
|
||||
func PostToInbox(x IDispatcher, username string, body string) (IPostToInboxResult, error) {
|
||||
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
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
input := &GetActorRequest{
|
||||
Username: "username",
|
||||
|
@ -228,6 +238,7 @@ func TestGetOutboxApi(test *testing.T) {
|
|||
func TestPostToInboxApi(test *testing.T) {
|
||||
input := &PostToInboxRequest{
|
||||
Username: "username",
|
||||
Body: "body",
|
||||
}
|
||||
|
||||
if output, err := api.PostToInbox(input); err != nil {
|
||||
|
|
|
@ -39,6 +39,7 @@ func (handler *authorizeInteractionHandler) HandlerFunc() HttpHandlerFunc {
|
|||
AUTHORIZE_INTERACTION_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ func (handler *echoHandler) HandlerFunc() HttpHandlerFunc {
|
|||
ECHO_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ func (factory *httpHandlerFactory) Handlers() []IHttpHandler {
|
|||
UpdateProfileByUserHandler(), // │ P . /api/v1/profile
|
||||
LogoutHandler(), // │ P . /api/v1/logout
|
||||
WebfingerHandler(), // │ G . /.well-known/webfinger
|
||||
GetPackagesHandler(), // │ G . /.well-known/packages.txt
|
||||
GetActorHandler(), // │ G . /u/:username
|
||||
FollowActorHandler(), // │ G . /u/:username/follow
|
||||
AuthorizeInteractionHandler(), // │ G . /authorize_interaction
|
||||
|
|
|
@ -40,6 +40,7 @@ func (handler *followActorHandler) HandlerFunc() HttpHandlerFunc {
|
|||
FOLLOW_ACTOR_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
true,
|
||||
); err != nil {
|
||||
return err
|
||||
|
|
|
@ -39,6 +39,7 @@ func (handler *getActorHandler) HandlerFunc() HttpHandlerFunc {
|
|||
GET_ACTOR_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ func (handler *getFollowersHandler) HandlerFunc() HttpHandlerFunc {
|
|||
GET_FOLLOWERS_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ func (handler *getFollowingHandler) HandlerFunc() HttpHandlerFunc {
|
|||
GET_FOLLOWING_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ func (handler *getInboxHandler) HandlerFunc() HttpHandlerFunc {
|
|||
GET_INBOX_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ func (handler *getOutboxHandler) HandlerFunc() HttpHandlerFunc {
|
|||
GET_OUTBOX_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
|
@ -38,6 +38,7 @@ func (handler *getProfileByUserHandler) HandlerFunc() HttpHandlerFunc {
|
|||
GET_PROFILE_BY_USER_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ func (handler *loginHandler) HandlerFunc() HttpHandlerFunc {
|
|||
LOGIN_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ func (handler *logoutHandler) HandlerFunc() HttpHandlerFunc {
|
|||
LOGOUT_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -33,12 +33,17 @@ func (handler *postToInboxHandler) HandlerFunc() HttpHandlerFunc {
|
|||
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,
|
||||
"post_to_inbox",
|
||||
POST_TO_INBOX_REQUEST,
|
||||
POST_TO_INBOX_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
onRequestProcessed,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ func (handler *postToOutboxHandler) HandlerFunc() HttpHandlerFunc {
|
|||
POST_TO_OUTBOX_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ func (handler *signupHandler) HandlerFunc() HttpHandlerFunc {
|
|||
SIGNUP_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ func (handler *updateProfileByUserHandler) HandlerFunc() HttpHandlerFunc {
|
|||
UPDATE_PROFILE_BY_USER_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ func (handler *verifyHandler) HandlerFunc() HttpHandlerFunc {
|
|||
VERIFY_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ func (handler *webfingerHandler) HandlerFunc() HttpHandlerFunc {
|
|||
WEBFINGER_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ func (factory *operationFactory) Operations() []IOperation {
|
|||
UpdateProfileByUserOperation(),
|
||||
LogoutOperation(),
|
||||
WebfingerOperation(),
|
||||
GetPackagesOperation(),
|
||||
GetActorOperation(),
|
||||
FollowActorOperation(),
|
||||
AuthorizeInteractionOperation(),
|
||||
|
|
|
@ -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
|
||||
}
|
||||
*/
|
Plik diff jest za duży
Load Diff
|
@ -114,6 +114,15 @@ message WebfingerResult {
|
|||
string subject = 0x00000003;
|
||||
}
|
||||
|
||||
// API: GetPackages
|
||||
//-----------------------------------------------------------
|
||||
message GetPackagesRequest {
|
||||
}
|
||||
|
||||
message GetPackagesResult {
|
||||
string body = 0x00000001;
|
||||
}
|
||||
|
||||
// API: GetActor
|
||||
//-----------------------------------------------------------
|
||||
message GetActorRequest {
|
||||
|
@ -224,9 +233,11 @@ message GetOutboxResult {
|
|||
//-----------------------------------------------------------
|
||||
message PostToInboxRequest {
|
||||
string username = 0x00000001;
|
||||
string body = 0x00000002;
|
||||
}
|
||||
|
||||
message PostToInboxResult {
|
||||
string body = 0x00000001;
|
||||
}
|
||||
|
||||
// API: GetInbox
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -15,7 +15,7 @@ func PostToInboxService(context IContext, input *PostToInboxRequest) (result *Po
|
|||
conductor.LogRemoteCall(context, INITIALIZE, "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 {
|
||||
err = _err
|
||||
return nil, err
|
||||
|
@ -24,5 +24,6 @@ func PostToInboxService(context IContext, input *PostToInboxRequest) (result *Po
|
|||
_ = _result
|
||||
|
||||
result = context.ResultContainer().(*PostToInboxResult)
|
||||
result.Body = _result.Body()
|
||||
return result, nil
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ type IApi interface {
|
|||
UpdateProfileByUser(*UpdateProfileByUserRequest) (*UpdateProfileByUserResult, error)
|
||||
Logout(*LogoutRequest) (*LogoutResult, error)
|
||||
Webfinger(*WebfingerRequest) (*WebfingerResult, error)
|
||||
GetPackages(*GetPackagesRequest) (*GetPackagesResult, error)
|
||||
GetActor(*GetActorRequest) (*GetActorResult, error)
|
||||
FollowActor(*FollowActorRequest) (*FollowActorResult, error)
|
||||
AuthorizeInteraction(*AuthorizeInteractionRequest) (*AuthorizeInteractionResult, error)
|
||||
|
|
|
@ -40,6 +40,10 @@ const (
|
|||
WEBFINGER_REQUEST = 0x01FD357C
|
||||
WEBFINGER_RESULT = 0xCC81EC52
|
||||
|
||||
//GetPackagesOperation
|
||||
GET_PACKAGES_REQUEST = 0x157C555E
|
||||
GET_PACKAGES_RESULT = 0x4CBD814E
|
||||
|
||||
//GetActorOperation
|
||||
GET_ACTOR_REQUEST = 0x5C4AC410
|
||||
GET_ACTOR_RESULT = 0x136B82A8
|
||||
|
@ -95,6 +99,8 @@ var OPCODES = Opcodes{
|
|||
0x9412D17F: "Logout",
|
||||
0x01FD357C: "WEBFINGER",
|
||||
0xCC81EC52: "Webfinger",
|
||||
0x157C555E: "GET_PACKAGES",
|
||||
0x4CBD814E: "GetPackages",
|
||||
0x5C4AC410: "GET_ACTOR",
|
||||
0x136B82A8: "GetActor",
|
||||
0xD30C2420: "FOLLOW_ACTOR",
|
||||
|
|
|
@ -62,6 +62,7 @@ type (
|
|||
UpdateProfileByUser(displayName string, avatar string, banner string, summary string, github string, editor Identity) (IUpdateProfileByUserResult, error)
|
||||
Logout(editor Identity) (ILogoutResult, error)
|
||||
Webfinger(resource string, editor Identity) (IWebfingerResult, error)
|
||||
GetPackages(editor Identity) (IGetPackagesResult, error)
|
||||
GetActor(username string, editor Identity) (IGetActorResult, error)
|
||||
FollowActor(username string, acct string, editor Identity) (IFollowActorResult, error)
|
||||
AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error)
|
||||
|
@ -69,7 +70,7 @@ type (
|
|||
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)
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -117,6 +118,10 @@ type (
|
|||
Subject() string
|
||||
}
|
||||
|
||||
IGetPackagesResult interface {
|
||||
Body() string
|
||||
}
|
||||
|
||||
IGetActorResult interface {
|
||||
Context() []string
|
||||
Id() string
|
||||
|
@ -175,6 +180,7 @@ type (
|
|||
}
|
||||
|
||||
IPostToInboxResult interface {
|
||||
Body() string
|
||||
}
|
||||
|
||||
IGetInboxResult interface {
|
||||
|
|
|
@ -265,6 +265,7 @@ type (
|
|||
UpdateProfileByUser(displayName string, avatar string, banner string, summary string, github string, editor Identity) (IUpdateProfileByUserResult, error)
|
||||
Logout(editor Identity) (ILogoutResult, error)
|
||||
Webfinger(resource string, editor Identity) (IWebfingerResult, error)
|
||||
GetPackages(editor Identity) (IGetPackagesResult, error)
|
||||
GetActor(username string, editor Identity) (IGetActorResult, error)
|
||||
FollowActor(username string, acct string, editor Identity) (IFollowActorResult, error)
|
||||
AuthorizeInteraction(uri string, editor Identity) (IAuthorizeInteractionResult, error)
|
||||
|
@ -272,7 +273,7 @@ type (
|
|||
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)
|
||||
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)
|
||||
|
||||
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
|
||||
NewLogoutResult(ignored interface{}) ILogoutResult
|
||||
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
|
||||
NewFollowActorResult(url string, ignored interface{}) IFollowActorResult
|
||||
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
|
||||
NewPostToOutboxResult(ignored interface{}) IPostToOutboxResult
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -1039,6 +1039,7 @@ type IDispatcher interface {
|
|||
UpdateProfileByUser(displayName string, avatar string, banner string, summary string, github string) (IUpdateProfileByUserResult, error)
|
||||
Logout() (ILogoutResult, error)
|
||||
Webfinger(resource string) (IWebfingerResult, error)
|
||||
GetPackages() (IGetPackagesResult, error)
|
||||
GetActor(username string) (IGetActorResult, error)
|
||||
FollowActor(username string, acct string) (IFollowActorResult, error)
|
||||
AuthorizeInteraction(uri string) (IAuthorizeInteractionResult, error)
|
||||
|
@ -1046,7 +1047,7 @@ type IDispatcher interface {
|
|||
GetFollowing(username string) (IGetFollowingResult, error)
|
||||
PostToOutbox(username string, context string, activityType string, to string, attributedTo string, inReplyTo string, content string) (IPostToOutboxResult, error)
|
||||
GetOutbox(username string) (IGetOutboxResult, error)
|
||||
PostToInbox(username string) (IPostToInboxResult, error)
|
||||
PostToInbox(username string, body string) (IPostToInboxResult, error)
|
||||
GetInbox(username string) (IGetInboxResult, error)
|
||||
|
||||
// NewDocument creates a new 'Document' instance using the provided property values.
|
||||
|
@ -1133,6 +1134,8 @@ type IDispatcher interface {
|
|||
NewLogoutResult() ILogoutResult
|
||||
// NewWebfingerResult creates a new result container for 'Webfinger' system action.
|
||||
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(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.
|
||||
|
@ -1148,7 +1151,7 @@ type IDispatcher interface {
|
|||
// 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
|
||||
// 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(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.
|
||||
|
|
|
@ -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) {
|
||||
result, err := api.call(GET_ACTOR_REQUEST, request)
|
||||
|
||||
|
@ -195,6 +205,7 @@ func init() {
|
|||
API_RESULT[UPDATE_PROFILE_BY_USER_RESULT] = UpdateProfileByUserResult{}
|
||||
API_RESULT[LOGOUT_RESULT] = LogoutResult{}
|
||||
API_RESULT[WEBFINGER_RESULT] = WebfingerResult{}
|
||||
API_RESULT[GET_PACKAGES_RESULT] = GetPackagesResult{}
|
||||
API_RESULT[GET_ACTOR_RESULT] = GetActorResult{}
|
||||
API_RESULT[FOLLOW_ACTOR_RESULT] = FollowActorResult{}
|
||||
API_RESULT[AUTHORIZE_INTERACTION_RESULT] = AuthorizeInteractionResult{}
|
||||
|
|
|
@ -1127,6 +1127,10 @@ func (conductor *conductor) Webfinger(resource string, editor Identity) (IWebfin
|
|||
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) {
|
||||
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)
|
||||
}
|
||||
|
||||
func (conductor *conductor) PostToInbox(username string, editor Identity) (IPostToInboxResult, error) {
|
||||
return conductor.spiManager.PostToInbox(username, editor)
|
||||
func (conductor *conductor) PostToInbox(username string, body string, editor Identity) (IPostToInboxResult, error) {
|
||||
return conductor.spiManager.PostToInbox(username, body, editor)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
|
||||
func (conductor *conductor) NewPostToInboxResult(_ interface{}) IPostToInboxResult {
|
||||
return NewPostToInboxResult(nil)
|
||||
func (conductor *conductor) NewPostToInboxResult(body string, _ interface{}) IPostToInboxResult {
|
||||
return NewPostToInboxResult(body, nil)
|
||||
}
|
||||
|
||||
func (conductor *conductor) NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, _ interface{}) IGetInboxResult {
|
||||
|
|
|
@ -267,6 +267,10 @@ func (dispatcher *dispatcher) Webfinger(resource string) (IWebfingerResult, erro
|
|||
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) {
|
||||
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)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) PostToInbox(username string) (IPostToInboxResult, error) {
|
||||
return dispatcher.conductor.SpiManager().PostToInbox(username, dispatcher.identity)
|
||||
func (dispatcher *dispatcher) PostToInbox(username string, body string) (IPostToInboxResult, error) {
|
||||
return dispatcher.conductor.SpiManager().PostToInbox(username, body, dispatcher.identity)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) GetInbox(username string) (IGetInboxResult, error) {
|
||||
|
|
|
@ -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
|
||||
|
||||
type getActorResult struct {
|
||||
|
@ -1006,15 +1041,22 @@ func (manager *spiManager) GetOutbox(username string, editor Identity) (result I
|
|||
//region IPostToInboxResult Implementation
|
||||
|
||||
type postToInboxResult struct {
|
||||
body string
|
||||
}
|
||||
|
||||
func NewPostToInboxResult(_ interface{}) IPostToInboxResult {
|
||||
return &postToInboxResult{}
|
||||
func NewPostToInboxResult(body string, _ interface{}) IPostToInboxResult {
|
||||
return &postToInboxResult{
|
||||
body: body,
|
||||
}
|
||||
}
|
||||
|
||||
func (result postToInboxResult) Body() string {
|
||||
return result.body
|
||||
}
|
||||
|
||||
//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() {
|
||||
if reason := recover(); reason != nil {
|
||||
err = manager.Error(reason)
|
||||
|
@ -1024,7 +1066,7 @@ func (manager *spiManager) PostToInbox(username string, editor Identity) (result
|
|||
editor.Lock(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
|
||||
} else {
|
||||
return result, nil
|
||||
|
|
|
@ -237,6 +237,17 @@ func TestSpiManager_Webfinger(test *testing.T) {
|
|||
_ = 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) {
|
||||
manager := Conductor.SpiManager()
|
||||
|
||||
|
@ -317,7 +328,7 @@ func TestSpiManager_GetOutbox(test *testing.T) {
|
|||
func TestSpiManager_PostToInbox(test *testing.T) {
|
||||
manager := Conductor.SpiManager()
|
||||
|
||||
result, err := manager.PostToInbox("username", nil)
|
||||
result, err := manager.PostToInbox("username", "body", nil)
|
||||
if err != nil {
|
||||
test.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@ func (dispatcher *dispatcher) NewWebfingerResult(aliases []string, links []IActi
|
|||
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 {
|
||||
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)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) NewPostToInboxResult() IPostToInboxResult {
|
||||
return NewPostToInboxResult(nil)
|
||||
func (dispatcher *dispatcher) NewPostToInboxResult(body string) IPostToInboxResult {
|
||||
return NewPostToInboxResult(body, nil)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetInboxResult {
|
||||
|
|
3
go.mod
3
go.mod
|
@ -3,9 +3,10 @@ module github.com/reiver/greatape
|
|||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/robfig/cron v1.2.0
|
||||
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
|
||||
)
|
||||
|
||||
|
|
6
go.sum
6
go.sum
|
@ -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.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||
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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
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.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||
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.7.8/go.mod h1:9Tm1tILSKRFRLqvGkG6fTNdLpQbsTZohTLD6xRoWkx8=
|
||||
github.com/xeronith/diamante v1.8.1 h1:rAEFVfj+3nOrBCGdfOk2F9FuijG+r/Vws5YLEuup/0Y=
|
||||
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/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||
|
|
Ładowanie…
Reference in New Issue