kopia lustrzana https://github.com/reiver/greatape
feat(components): ✨ getting outbox
rodzic
739f4c2813
commit
7af27af965
|
|
@ -20,6 +20,7 @@ func (factory *httpHandlerFactory) Handlers() []IHttpHandler {
|
|||
GetFollowersHandler(), // │ G . /u/:username/followers
|
||||
GetFollowingHandler(), // │ G . /u/:username/following
|
||||
PostToOutboxHandler(), // │ P . /u/:username/outbox
|
||||
GetOutboxHandler(), // │ G . /u/:username/outbox
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
. "github.com/xeronith/diamante/contracts/network/http"
|
||||
pipeline "github.com/xeronith/diamante/network/http"
|
||||
. "rail.town/infrastructure/components/api/protobuf"
|
||||
. "rail.town/infrastructure/components/contracts"
|
||||
)
|
||||
|
||||
type getOutboxHandler struct {
|
||||
}
|
||||
|
||||
func GetOutboxHandler() IHttpHandler {
|
||||
return &getOutboxHandler{}
|
||||
}
|
||||
|
||||
func (handler *getOutboxHandler) Method() string {
|
||||
return http.MethodGet
|
||||
}
|
||||
|
||||
func (handler *getOutboxHandler) Path() string {
|
||||
return "/u/:username/outbox"
|
||||
}
|
||||
|
||||
func (handler *getOutboxHandler) HandlerFunc() HttpHandlerFunc {
|
||||
return func(x IServerDispatcher) error {
|
||||
request := &GetOutboxRequest{}
|
||||
result := &GetOutboxResult{}
|
||||
|
||||
onRequestUnmarshalled := func(request *GetOutboxRequest) {
|
||||
request.Username = x.Param("username")
|
||||
}
|
||||
|
||||
return pipeline.Handle(x,
|
||||
"get_outbox",
|
||||
GET_OUTBOX_REQUEST,
|
||||
GET_OUTBOX_RESULT,
|
||||
request, result,
|
||||
onRequestUnmarshalled,
|
||||
false,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ func (factory *operationFactory) Operations() []IOperation {
|
|||
GetFollowersOperation(),
|
||||
GetFollowingOperation(),
|
||||
PostToOutboxOperation(),
|
||||
GetOutboxOperation(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
package operations
|
||||
|
||||
import (
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
. "github.com/xeronith/diamante/contracts/system"
|
||||
. "github.com/xeronith/diamante/operation"
|
||||
. "rail.town/infrastructure/components/api/protobuf"
|
||||
. "rail.town/infrastructure/components/api/services"
|
||||
. "rail.town/infrastructure/components/contracts"
|
||||
)
|
||||
|
||||
type getOutboxOperation struct {
|
||||
Operation
|
||||
|
||||
run func(IContext, *GetOutboxRequest) (*GetOutboxResult, error)
|
||||
}
|
||||
|
||||
func GetOutboxOperation() IOperation {
|
||||
return &getOutboxOperation{
|
||||
run: GetOutboxService,
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *getOutboxOperation) Id() (ID, ID) {
|
||||
return GET_OUTBOX_REQUEST, GET_OUTBOX_RESULT
|
||||
}
|
||||
|
||||
func (operation *getOutboxOperation) InputContainer() Pointer {
|
||||
return new(GetOutboxRequest)
|
||||
}
|
||||
|
||||
func (operation *getOutboxOperation) OutputContainer() Pointer {
|
||||
return new(GetOutboxResult)
|
||||
}
|
||||
|
||||
func (operation *getOutboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*GetOutboxRequest))
|
||||
}
|
||||
|
||||
/*
|
||||
func (operation *getOutboxOperation) 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
|
||||
}
|
||||
*/
|
||||
|
|
@ -1847,6 +1847,142 @@ func (*PostToOutboxResult) Descriptor() ([]byte, []int) {
|
|||
return file_spis_proto_rawDescGZIP(), []int{29}
|
||||
}
|
||||
|
||||
// API: GetOutbox
|
||||
// -----------------------------------------------------------
|
||||
type GetOutboxRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetOutboxRequest) Reset() {
|
||||
*x = GetOutboxRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_spis_proto_msgTypes[30]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetOutboxRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetOutboxRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetOutboxRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_spis_proto_msgTypes[30]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetOutboxRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetOutboxRequest) Descriptor() ([]byte, []int) {
|
||||
return file_spis_proto_rawDescGZIP(), []int{30}
|
||||
}
|
||||
|
||||
func (x *GetOutboxRequest) GetUsername() string {
|
||||
if x != nil {
|
||||
return x.Username
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetOutboxResult struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Context string `protobuf:"bytes,1,opt,name=context,json=@context,proto3" json:"context,omitempty"`
|
||||
Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
|
||||
TotalItems int32 `protobuf:"varint,4,opt,name=totalItems,proto3" json:"totalItems,omitempty"`
|
||||
OrderedItems []*ActivityPubActivity `protobuf:"bytes,5,rep,name=orderedItems,proto3" json:"orderedItems,omitempty"`
|
||||
First string `protobuf:"bytes,6,opt,name=first,proto3" json:"first,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetOutboxResult) Reset() {
|
||||
*x = GetOutboxResult{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_spis_proto_msgTypes[31]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetOutboxResult) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetOutboxResult) ProtoMessage() {}
|
||||
|
||||
func (x *GetOutboxResult) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_spis_proto_msgTypes[31]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetOutboxResult.ProtoReflect.Descriptor instead.
|
||||
func (*GetOutboxResult) Descriptor() ([]byte, []int) {
|
||||
return file_spis_proto_rawDescGZIP(), []int{31}
|
||||
}
|
||||
|
||||
func (x *GetOutboxResult) GetContext() string {
|
||||
if x != nil {
|
||||
return x.Context
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetOutboxResult) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetOutboxResult) GetType() string {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetOutboxResult) GetTotalItems() int32 {
|
||||
if x != nil {
|
||||
return x.TotalItems
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetOutboxResult) GetOrderedItems() []*ActivityPubActivity {
|
||||
if x != nil {
|
||||
return x.OrderedItems
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *GetOutboxResult) GetFirst() string {
|
||||
if x != nil {
|
||||
return x.First
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_spis_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_spis_proto_rawDesc = []byte{
|
||||
|
|
@ -2026,8 +2162,24 @@ var file_spis_proto_rawDesc = []byte{
|
|||
0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x12, 0x18,
|
||||
0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x14, 0x0a, 0x12, 0x50, 0x6f, 0x73, 0x74,
|
||||
0x54, 0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x42, 0x04,
|
||||
0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x54, 0x6f, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x22, 0x2e,
|
||||
0x0a, 0x10, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xc9,
|
||||
0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75,
|
||||
0x6c, 0x74, 0x12, 0x19, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x08, 0x40, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x0e, 0x0a,
|
||||
0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70,
|
||||
0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18,
|
||||
0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x73, 0x12, 0x41, 0x0a, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49, 0x74, 0x65, 0x6d,
|
||||
0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
|
||||
0x75, 0x66, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x50, 0x75, 0x62, 0x41, 0x63,
|
||||
0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x0c, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x65, 0x64, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x18, 0x06, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x72, 0x73, 0x74, 0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -2042,7 +2194,7 @@ func file_spis_proto_rawDescGZIP() []byte {
|
|||
return file_spis_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_spis_proto_msgTypes = make([]protoimpl.MessageInfo, 30)
|
||||
var file_spis_proto_msgTypes = make([]protoimpl.MessageInfo, 32)
|
||||
var file_spis_proto_goTypes = []interface{}{
|
||||
(*SystemCallRequest)(nil), // 0: protobuf.SystemCallRequest
|
||||
(*SystemCallResult)(nil), // 1: protobuf.SystemCallResult
|
||||
|
|
@ -2074,23 +2226,27 @@ var file_spis_proto_goTypes = []interface{}{
|
|||
(*GetFollowingResult)(nil), // 27: protobuf.GetFollowingResult
|
||||
(*PostToOutboxRequest)(nil), // 28: protobuf.PostToOutboxRequest
|
||||
(*PostToOutboxResult)(nil), // 29: protobuf.PostToOutboxResult
|
||||
(*Document)(nil), // 30: protobuf.Document
|
||||
(*ActivityPubLink)(nil), // 31: protobuf.ActivityPubLink
|
||||
(*ActivityPubMedia)(nil), // 32: protobuf.ActivityPubMedia
|
||||
(*ActivityPubPublicKey)(nil), // 33: protobuf.ActivityPubPublicKey
|
||||
(*GetOutboxRequest)(nil), // 30: protobuf.GetOutboxRequest
|
||||
(*GetOutboxResult)(nil), // 31: protobuf.GetOutboxResult
|
||||
(*Document)(nil), // 32: protobuf.Document
|
||||
(*ActivityPubLink)(nil), // 33: protobuf.ActivityPubLink
|
||||
(*ActivityPubMedia)(nil), // 34: protobuf.ActivityPubMedia
|
||||
(*ActivityPubPublicKey)(nil), // 35: protobuf.ActivityPubPublicKey
|
||||
(*ActivityPubActivity)(nil), // 36: protobuf.ActivityPubActivity
|
||||
}
|
||||
var file_spis_proto_depIdxs = []int32{
|
||||
30, // 0: protobuf.EchoRequest.document:type_name -> protobuf.Document
|
||||
30, // 1: protobuf.EchoResult.document:type_name -> protobuf.Document
|
||||
31, // 2: protobuf.WebfingerResult.links:type_name -> protobuf.ActivityPubLink
|
||||
32, // 3: protobuf.GetActorResult.icon:type_name -> protobuf.ActivityPubMedia
|
||||
32, // 4: protobuf.GetActorResult.image:type_name -> protobuf.ActivityPubMedia
|
||||
33, // 5: protobuf.GetActorResult.publicKey:type_name -> protobuf.ActivityPubPublicKey
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
32, // 0: protobuf.EchoRequest.document:type_name -> protobuf.Document
|
||||
32, // 1: protobuf.EchoResult.document:type_name -> protobuf.Document
|
||||
33, // 2: protobuf.WebfingerResult.links:type_name -> protobuf.ActivityPubLink
|
||||
34, // 3: protobuf.GetActorResult.icon:type_name -> protobuf.ActivityPubMedia
|
||||
34, // 4: protobuf.GetActorResult.image:type_name -> protobuf.ActivityPubMedia
|
||||
35, // 5: protobuf.GetActorResult.publicKey:type_name -> protobuf.ActivityPubPublicKey
|
||||
36, // 6: protobuf.GetOutboxResult.orderedItems:type_name -> protobuf.ActivityPubActivity
|
||||
7, // [7:7] is the sub-list for method output_type
|
||||
7, // [7:7] is the sub-list for method input_type
|
||||
7, // [7:7] is the sub-list for extension type_name
|
||||
7, // [7:7] is the sub-list for extension extendee
|
||||
0, // [0:7] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_spis_proto_init() }
|
||||
|
|
@ -2460,6 +2616,30 @@ func file_spis_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_spis_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetOutboxRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_spis_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetOutboxResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
|
|
@ -2467,7 +2647,7 @@ func file_spis_proto_init() {
|
|||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_spis_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 30,
|
||||
NumMessages: 32,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -205,4 +205,19 @@ message PostToOutboxRequest {
|
|||
message PostToOutboxResult {
|
||||
}
|
||||
|
||||
// API: GetOutbox
|
||||
//-----------------------------------------------------------
|
||||
message GetOutboxRequest {
|
||||
string username = 0x00000001;
|
||||
}
|
||||
|
||||
message GetOutboxResult {
|
||||
string context = 0x00000001 [json_name = "@context"];
|
||||
string id = 0x00000002;
|
||||
string type = 0x00000003;
|
||||
int32 totalItems = 0x00000004;
|
||||
repeated ActivityPubActivity orderedItems = 0x00000005;
|
||||
string first = 0x00000006;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -0,0 +1,69 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
. "rail.town/infrastructure/components/api/protobuf"
|
||||
. "rail.town/infrastructure/components/contracts"
|
||||
"rail.town/infrastructure/components/core"
|
||||
)
|
||||
|
||||
// noinspection GoUnusedParameter
|
||||
func GetOutboxService(context IContext, input *GetOutboxRequest) (result *GetOutboxResult, err error) {
|
||||
conductor := core.Conductor
|
||||
_ = GET_OUTBOX_REQUEST
|
||||
|
||||
conductor.LogRemoteCall(context, INITIALIZE, "get_outbox", input, result, err)
|
||||
defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_outbox", input, result, err) }()
|
||||
|
||||
_result, _err := conductor.GetOutbox(input.Username, context.Identity())
|
||||
if _err != nil {
|
||||
err = _err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_ = _result
|
||||
|
||||
outputOrderedItems := make([]*ActivityPubActivity, 0)
|
||||
for _, orderedItem := range _result.OrderedItems() {
|
||||
if orderedItem == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var object *ActivityPubObject
|
||||
if orderedItem.Object() != nil {
|
||||
object = &ActivityPubObject{
|
||||
Context: orderedItem.Object().Context(),
|
||||
Id: orderedItem.Object().Id(),
|
||||
Type: orderedItem.Object().Type(),
|
||||
Actor: orderedItem.Object().Actor(),
|
||||
From: orderedItem.Object().From(),
|
||||
To: orderedItem.Object().To(),
|
||||
InReplyTo: orderedItem.Object().InReplyTo(),
|
||||
Content: orderedItem.Object().Content(),
|
||||
Published: orderedItem.Object().Published(),
|
||||
}
|
||||
}
|
||||
|
||||
outputOrderedItems = append(outputOrderedItems, &ActivityPubActivity{
|
||||
Context: orderedItem.Context(),
|
||||
Id: orderedItem.Id(),
|
||||
Type: orderedItem.Type(),
|
||||
Actor: orderedItem.Actor(),
|
||||
Object: object,
|
||||
From: orderedItem.From(),
|
||||
To: orderedItem.To(),
|
||||
InReplyTo: orderedItem.InReplyTo(),
|
||||
Content: orderedItem.Content(),
|
||||
Published: orderedItem.Published(),
|
||||
})
|
||||
}
|
||||
|
||||
result = context.ResultContainer().(*GetOutboxResult)
|
||||
result.Context = _result.Context()
|
||||
result.Id = _result.Id()
|
||||
result.Type = _result.Type()
|
||||
result.TotalItems = _result.TotalItems()
|
||||
result.OrderedItems = outputOrderedItems
|
||||
result.First = _result.First()
|
||||
return result, nil
|
||||
}
|
||||
|
|
@ -21,4 +21,5 @@ type IApi interface {
|
|||
GetFollowers(*GetFollowersRequest) (*GetFollowersResult, error)
|
||||
GetFollowing(*GetFollowingRequest) (*GetFollowingResult, error)
|
||||
PostToOutbox(*PostToOutboxRequest) (*PostToOutboxResult, error)
|
||||
GetOutbox(*GetOutboxRequest) (*GetOutboxResult, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@ const (
|
|||
//PostToOutboxOperation
|
||||
POST_TO_OUTBOX_REQUEST = 0x9E489553
|
||||
POST_TO_OUTBOX_RESULT = 0xC6C56614
|
||||
|
||||
//GetOutboxOperation
|
||||
GET_OUTBOX_REQUEST = 0x527B6997
|
||||
GET_OUTBOX_RESULT = 0xF94E37A0
|
||||
)
|
||||
|
||||
var OPCODES = Opcodes{
|
||||
|
|
@ -95,4 +99,6 @@ var OPCODES = Opcodes{
|
|||
0xD707408F: "GetFollowing",
|
||||
0x9E489553: "POST_TO_OUTBOX",
|
||||
0xC6C56614: "PostToOutbox",
|
||||
0x527B6997: "GET_OUTBOX",
|
||||
0xF94E37A0: "GetOutbox",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ type (
|
|||
GetFollowers(username string, editor Identity) (IGetFollowersResult, 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)
|
||||
GetOutbox(username string, editor Identity) (IGetOutboxResult, error)
|
||||
}
|
||||
|
||||
IEchoResult interface {
|
||||
|
|
@ -161,4 +162,13 @@ type (
|
|||
|
||||
IPostToOutboxResult interface {
|
||||
}
|
||||
|
||||
IGetOutboxResult interface {
|
||||
Context() string
|
||||
Id() string
|
||||
Type() string
|
||||
TotalItems() int32
|
||||
OrderedItems() []IActivityPubActivity
|
||||
First() string
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -271,6 +271,7 @@ type (
|
|||
GetFollowers(username string, editor Identity) (IGetFollowersResult, 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)
|
||||
GetOutbox(username string, editor Identity) (IGetOutboxResult, error)
|
||||
|
||||
NewDocument(id int64, content string) (IDocument, error)
|
||||
NewSystemSchedule(id int64, enabled bool, config string) (ISystemSchedule, error)
|
||||
|
|
@ -303,6 +304,7 @@ type (
|
|||
NewGetFollowersResult(context string, id string, type_ string, totalItems int32, orderedItems []string, first string, ignored interface{}) IGetFollowersResult
|
||||
NewGetFollowingResult(context string, id string, type_ string, totalItems int32, orderedItems []string, first string, ignored interface{}) IGetFollowingResult
|
||||
NewPostToOutboxResult(ignored interface{}) IPostToOutboxResult
|
||||
NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, ignored interface{}) IGetOutboxResult
|
||||
}
|
||||
|
||||
ISystemComponent interface {
|
||||
|
|
|
|||
|
|
@ -1045,6 +1045,7 @@ type IDispatcher interface {
|
|||
GetFollowers(username string) (IGetFollowersResult, error)
|
||||
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)
|
||||
|
||||
// NewDocument creates a new 'Document' instance using the provided property values.
|
||||
NewDocument(id int64, content string) (IDocument, error)
|
||||
|
|
@ -1142,6 +1143,8 @@ type IDispatcher interface {
|
|||
NewGetFollowingResult(context string, id string, type_ string, totalItems int32, orderedItems []string, first string) IGetFollowingResult
|
||||
// NewPostToOutboxResult creates a new result container for 'Post To Outbox' system action.
|
||||
NewPostToOutboxResult() IPostToOutboxResult
|
||||
// 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
|
||||
// Assert asserts the provided condition and panics if the assertion is not valid.
|
||||
Assert(condition bool) IAssertionResult
|
||||
// AssertNoError panics if the provided error is not nil.
|
||||
|
|
|
|||
|
|
@ -155,6 +155,16 @@ func (api *api) PostToOutbox(request *PostToOutboxRequest) (*PostToOutboxResult,
|
|||
}
|
||||
}
|
||||
|
||||
func (api *api) GetOutbox(request *GetOutboxRequest) (*GetOutboxResult, error) {
|
||||
result, err := api.call(GET_OUTBOX_REQUEST, request)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result.(*GetOutboxResult), nil
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
API_RESULT[SYSTEM_CALL_RESULT] = SystemCallResult{}
|
||||
API_RESULT[ECHO_RESULT] = EchoResult{}
|
||||
|
|
@ -171,4 +181,5 @@ func init() {
|
|||
API_RESULT[GET_FOLLOWERS_RESULT] = GetFollowersResult{}
|
||||
API_RESULT[GET_FOLLOWING_RESULT] = GetFollowingResult{}
|
||||
API_RESULT[POST_TO_OUTBOX_RESULT] = PostToOutboxResult{}
|
||||
API_RESULT[GET_OUTBOX_RESULT] = GetOutboxResult{}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1151,6 +1151,10 @@ func (conductor *conductor) PostToOutbox(username string, context string, activi
|
|||
return conductor.spiManager.PostToOutbox(username, context, activityType, to, attributedTo, inReplyTo, content, editor)
|
||||
}
|
||||
|
||||
func (conductor *conductor) GetOutbox(username string, editor Identity) (IGetOutboxResult, error) {
|
||||
return conductor.spiManager.GetOutbox(username, editor)
|
||||
}
|
||||
|
||||
func (conductor *conductor) NewDocument(id int64, content string) (IDocument, error) {
|
||||
return NewDocument(id, content)
|
||||
}
|
||||
|
|
@ -1275,6 +1279,10 @@ func (conductor *conductor) NewPostToOutboxResult(_ interface{}) IPostToOutboxRe
|
|||
return NewPostToOutboxResult(nil)
|
||||
}
|
||||
|
||||
func (conductor *conductor) NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, _ interface{}) IGetOutboxResult {
|
||||
return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil)
|
||||
}
|
||||
|
||||
func (conductor *conductor) LogRemoteCall(context IContext, eventType uint32, source string, input, result interface{}, err error) {
|
||||
errorMessage := ""
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -290,3 +290,7 @@ func (dispatcher *dispatcher) GetFollowing(username string) (IGetFollowingResult
|
|||
func (dispatcher *dispatcher) PostToOutbox(username string, context string, activityType string, to string, attributedTo string, inReplyTo string, content string) (IPostToOutboxResult, error) {
|
||||
return dispatcher.conductor.SpiManager().PostToOutbox(username, context, activityType, to, attributedTo, inReplyTo, content, dispatcher.identity)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) GetOutbox(username string) (IGetOutboxResult, error) {
|
||||
return dispatcher.conductor.SpiManager().GetOutbox(username, dispatcher.identity)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -937,3 +937,68 @@ func (manager *spiManager) PostToOutbox(username string, context string, activit
|
|||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
//region IGetOutboxResult Implementation
|
||||
|
||||
type getOutboxResult struct {
|
||||
context string
|
||||
id string
|
||||
type_ string
|
||||
totalItems int32
|
||||
orderedItems []IActivityPubActivity
|
||||
first string
|
||||
}
|
||||
|
||||
func NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, _ interface{}) IGetOutboxResult {
|
||||
return &getOutboxResult{
|
||||
context: context,
|
||||
id: id,
|
||||
type_: type_,
|
||||
totalItems: totalItems,
|
||||
orderedItems: orderedItems,
|
||||
first: first,
|
||||
}
|
||||
}
|
||||
|
||||
func (result getOutboxResult) Context() string {
|
||||
return result.context
|
||||
}
|
||||
|
||||
func (result getOutboxResult) Id() string {
|
||||
return result.id
|
||||
}
|
||||
|
||||
func (result getOutboxResult) Type() string {
|
||||
return result.type_
|
||||
}
|
||||
|
||||
func (result getOutboxResult) TotalItems() int32 {
|
||||
return result.totalItems
|
||||
}
|
||||
|
||||
func (result getOutboxResult) OrderedItems() []IActivityPubActivity {
|
||||
return result.orderedItems
|
||||
}
|
||||
|
||||
func (result getOutboxResult) First() string {
|
||||
return result.first
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
func (manager *spiManager) GetOutbox(username string, editor Identity) (result IGetOutboxResult, err error) {
|
||||
defer func() {
|
||||
if reason := recover(); reason != nil {
|
||||
err = manager.Error(reason)
|
||||
}
|
||||
}()
|
||||
|
||||
editor.Lock(GET_OUTBOX_REQUEST)
|
||||
defer editor.Unlock(GET_OUTBOX_REQUEST)
|
||||
|
||||
if result, err = commands.GetOutbox(NewDispatcher(Conductor, editor), username); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,4 +60,8 @@ func (dispatcher *dispatcher) NewPostToOutboxResult() IPostToOutboxResult {
|
|||
return NewPostToOutboxResult(nil)
|
||||
}
|
||||
|
||||
func (dispatcher *dispatcher) NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetOutboxResult {
|
||||
return NewGetOutboxResult(context, id, type_, totalItems, orderedItems, first, nil)
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue