feat(components): get inbox

master
Xeronith 2023-01-04 13:22:15 +03:30
rodzic 8ce7ea668d
commit 15258b76e8
17 zmienionych plików z 495 dodań i 20 usunięć

Wyświetl plik

@ -22,6 +22,7 @@ func (factory *httpHandlerFactory) Handlers() []IHttpHandler {
PostToOutboxHandler(), // │ P . /u/:username/outbox
GetOutboxHandler(), // │ G . /u/:username/outbox
PostToInboxHandler(), // │ P . /u/:username/inbox
GetInboxHandler(), // │ G . /u/:username/inbox
}
}

Wyświetl plik

@ -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 getInboxHandler struct {
}
func GetInboxHandler() IHttpHandler {
return &getInboxHandler{}
}
func (handler *getInboxHandler) Method() string {
return http.MethodGet
}
func (handler *getInboxHandler) Path() string {
return "/u/:username/inbox"
}
func (handler *getInboxHandler) HandlerFunc() HttpHandlerFunc {
return func(x IServerDispatcher) error {
request := &GetInboxRequest{}
result := &GetInboxResult{}
onRequestUnmarshalled := func(request *GetInboxRequest) {
request.Username = x.Param("username")
}
return pipeline.Handle(x,
"get_inbox",
GET_INBOX_REQUEST,
GET_INBOX_RESULT,
request, result,
onRequestUnmarshalled,
false,
)
}
}

Wyświetl plik

@ -23,6 +23,7 @@ func (factory *operationFactory) Operations() []IOperation {
PostToOutboxOperation(),
GetOutboxOperation(),
PostToInboxOperation(),
GetInboxOperation(),
}
}

Wyświetl plik

@ -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 getInboxOperation struct {
Operation
run func(IContext, *GetInboxRequest) (*GetInboxResult, error)
}
func GetInboxOperation() IOperation {
return &getInboxOperation{
run: GetInboxService,
}
}
func (operation *getInboxOperation) Id() (ID, ID) {
return GET_INBOX_REQUEST, GET_INBOX_RESULT
}
func (operation *getInboxOperation) InputContainer() Pointer {
return new(GetInboxRequest)
}
func (operation *getInboxOperation) OutputContainer() Pointer {
return new(GetInboxResult)
}
func (operation *getInboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
return operation.run(context, payload.(*GetInboxRequest))
}
/*
func (operation *getInboxOperation) 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

@ -2070,6 +2070,142 @@ func (*PostToInboxResult) Descriptor() ([]byte, []int) {
return file_spis_proto_rawDescGZIP(), []int{33}
}
// API: GetInbox
// -----------------------------------------------------------
type GetInboxRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
}
func (x *GetInboxRequest) Reset() {
*x = GetInboxRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_spis_proto_msgTypes[34]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetInboxRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetInboxRequest) ProtoMessage() {}
func (x *GetInboxRequest) ProtoReflect() protoreflect.Message {
mi := &file_spis_proto_msgTypes[34]
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 GetInboxRequest.ProtoReflect.Descriptor instead.
func (*GetInboxRequest) Descriptor() ([]byte, []int) {
return file_spis_proto_rawDescGZIP(), []int{34}
}
func (x *GetInboxRequest) GetUsername() string {
if x != nil {
return x.Username
}
return ""
}
type GetInboxResult 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 *GetInboxResult) Reset() {
*x = GetInboxResult{}
if protoimpl.UnsafeEnabled {
mi := &file_spis_proto_msgTypes[35]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetInboxResult) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetInboxResult) ProtoMessage() {}
func (x *GetInboxResult) ProtoReflect() protoreflect.Message {
mi := &file_spis_proto_msgTypes[35]
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 GetInboxResult.ProtoReflect.Descriptor instead.
func (*GetInboxResult) Descriptor() ([]byte, []int) {
return file_spis_proto_rawDescGZIP(), []int{35}
}
func (x *GetInboxResult) GetContext() string {
if x != nil {
return x.Context
}
return ""
}
func (x *GetInboxResult) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *GetInboxResult) GetType() string {
if x != nil {
return x.Type
}
return ""
}
func (x *GetInboxResult) GetTotalItems() int32 {
if x != nil {
return x.TotalItems
}
return 0
}
func (x *GetInboxResult) GetOrderedItems() []*ActivityPubActivity {
if x != nil {
return x.OrderedItems
}
return nil
}
func (x *GetInboxResult) GetFirst() string {
if x != nil {
return x.First
}
return ""
}
var File_spis_proto protoreflect.FileDescriptor
var file_spis_proto_rawDesc = []byte{
@ -2270,7 +2406,23 @@ var file_spis_proto_rawDesc = []byte{
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, 0x13, 0x0a, 0x11,
0x50, 0x6f, 0x73, 0x74, 0x54, 0x6f, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c,
0x74, 0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x22, 0x2d, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65,
0x22, 0xc8, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x49, 0x6e, 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 (
@ -2285,7 +2437,7 @@ func file_spis_proto_rawDescGZIP() []byte {
return file_spis_proto_rawDescData
}
var file_spis_proto_msgTypes = make([]protoimpl.MessageInfo, 34)
var file_spis_proto_msgTypes = make([]protoimpl.MessageInfo, 36)
var file_spis_proto_goTypes = []interface{}{
(*SystemCallRequest)(nil), // 0: protobuf.SystemCallRequest
(*SystemCallResult)(nil), // 1: protobuf.SystemCallResult
@ -2321,25 +2473,28 @@ var file_spis_proto_goTypes = []interface{}{
(*GetOutboxResult)(nil), // 31: protobuf.GetOutboxResult
(*PostToInboxRequest)(nil), // 32: protobuf.PostToInboxRequest
(*PostToInboxResult)(nil), // 33: protobuf.PostToInboxResult
(*Document)(nil), // 34: protobuf.Document
(*ActivityPubLink)(nil), // 35: protobuf.ActivityPubLink
(*ActivityPubMedia)(nil), // 36: protobuf.ActivityPubMedia
(*ActivityPubPublicKey)(nil), // 37: protobuf.ActivityPubPublicKey
(*ActivityPubActivity)(nil), // 38: protobuf.ActivityPubActivity
(*GetInboxRequest)(nil), // 34: protobuf.GetInboxRequest
(*GetInboxResult)(nil), // 35: protobuf.GetInboxResult
(*Document)(nil), // 36: protobuf.Document
(*ActivityPubLink)(nil), // 37: protobuf.ActivityPubLink
(*ActivityPubMedia)(nil), // 38: protobuf.ActivityPubMedia
(*ActivityPubPublicKey)(nil), // 39: protobuf.ActivityPubPublicKey
(*ActivityPubActivity)(nil), // 40: protobuf.ActivityPubActivity
}
var file_spis_proto_depIdxs = []int32{
34, // 0: protobuf.EchoRequest.document:type_name -> protobuf.Document
34, // 1: protobuf.EchoResult.document:type_name -> protobuf.Document
35, // 2: protobuf.WebfingerResult.links:type_name -> protobuf.ActivityPubLink
36, // 3: protobuf.GetActorResult.icon:type_name -> protobuf.ActivityPubMedia
36, // 4: protobuf.GetActorResult.image:type_name -> protobuf.ActivityPubMedia
37, // 5: protobuf.GetActorResult.publicKey:type_name -> protobuf.ActivityPubPublicKey
38, // 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
36, // 0: protobuf.EchoRequest.document:type_name -> protobuf.Document
36, // 1: protobuf.EchoResult.document:type_name -> protobuf.Document
37, // 2: protobuf.WebfingerResult.links:type_name -> protobuf.ActivityPubLink
38, // 3: protobuf.GetActorResult.icon:type_name -> protobuf.ActivityPubMedia
38, // 4: protobuf.GetActorResult.image:type_name -> protobuf.ActivityPubMedia
39, // 5: protobuf.GetActorResult.publicKey:type_name -> protobuf.ActivityPubPublicKey
40, // 6: protobuf.GetOutboxResult.orderedItems:type_name -> protobuf.ActivityPubActivity
40, // 7: protobuf.GetInboxResult.orderedItems:type_name -> protobuf.ActivityPubActivity
8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
}
func init() { file_spis_proto_init() }
@ -2757,6 +2912,30 @@ func file_spis_proto_init() {
return nil
}
}
file_spis_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetInboxRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_spis_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetInboxResult); 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{
@ -2764,7 +2943,7 @@ func file_spis_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_spis_proto_rawDesc,
NumEnums: 0,
NumMessages: 34,
NumMessages: 36,
NumExtensions: 0,
NumServices: 0,
},

Wyświetl plik

@ -229,4 +229,19 @@ message PostToInboxRequest {
message PostToInboxResult {
}
// API: GetInbox
//-----------------------------------------------------------
message GetInboxRequest {
string username = 0x00000001;
}
message GetInboxResult {
string context = 0x00000001 [json_name = "@context"];
string id = 0x00000002;
string type = 0x00000003;
int32 totalItems = 0x00000004;
repeated ActivityPubActivity orderedItems = 0x00000005;
string first = 0x00000006;
}
//-----------------------------------------------------------

Wyświetl plik

@ -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 GetInboxService(context IContext, input *GetInboxRequest) (result *GetInboxResult, err error) {
conductor := core.Conductor
_ = GET_INBOX_REQUEST
conductor.LogRemoteCall(context, INITIALIZE, "get_inbox", input, result, err)
defer func() { conductor.LogRemoteCall(context, FINALIZE, "get_inbox", input, result, err) }()
_result, _err := conductor.GetInbox(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().(*GetInboxResult)
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
}

Wyświetl plik

@ -23,4 +23,5 @@ type IApi interface {
PostToOutbox(*PostToOutboxRequest) (*PostToOutboxResult, error)
GetOutbox(*GetOutboxRequest) (*GetOutboxResult, error)
PostToInbox(*PostToInboxRequest) (*PostToInboxResult, error)
GetInbox(*GetInboxRequest) (*GetInboxResult, error)
}

Wyświetl plik

@ -71,6 +71,10 @@ const (
//PostToInboxOperation
POST_TO_INBOX_REQUEST = 0x7400C331
POST_TO_INBOX_RESULT = 0x5BD43D90
//GetInboxOperation
GET_INBOX_REQUEST = 0x4B8B9285
GET_INBOX_RESULT = 0x65835436
)
var OPCODES = Opcodes{
@ -107,4 +111,6 @@ var OPCODES = Opcodes{
0xF94E37A0: "GetOutbox",
0x7400C331: "POST_TO_INBOX",
0x5BD43D90: "PostToInbox",
0x4B8B9285: "GET_INBOX",
0x65835436: "GetInbox",
}

Wyświetl plik

@ -70,6 +70,7 @@ type (
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)
GetInbox(username string, editor Identity) (IGetInboxResult, error)
}
IEchoResult interface {
@ -175,4 +176,13 @@ type (
IPostToInboxResult interface {
}
IGetInboxResult interface {
Context() string
Id() string
Type() string
TotalItems() int32
OrderedItems() []IActivityPubActivity
First() string
}
)

Wyświetl plik

@ -273,6 +273,7 @@ type (
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)
GetInbox(username string, editor Identity) (IGetInboxResult, error)
NewDocument(id int64, content string) (IDocument, error)
NewSystemSchedule(id int64, enabled bool, config string) (ISystemSchedule, error)
@ -307,6 +308,7 @@ type (
NewPostToOutboxResult(ignored interface{}) IPostToOutboxResult
NewGetOutboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, ignored interface{}) IGetOutboxResult
NewPostToInboxResult(ignored interface{}) IPostToInboxResult
NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, ignored interface{}) IGetInboxResult
}
ISystemComponent interface {

Wyświetl plik

@ -1047,6 +1047,7 @@ type IDispatcher interface {
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)
GetInbox(username string) (IGetInboxResult, error)
// NewDocument creates a new 'Document' instance using the provided property values.
NewDocument(id int64, content string) (IDocument, error)
@ -1148,6 +1149,8 @@ type IDispatcher interface {
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
// 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.
Assert(condition bool) IAssertionResult
// AssertNoError panics if the provided error is not nil.

Wyświetl plik

@ -175,6 +175,16 @@ func (api *api) PostToInbox(request *PostToInboxRequest) (*PostToInboxResult, er
}
}
func (api *api) GetInbox(request *GetInboxRequest) (*GetInboxResult, error) {
result, err := api.call(GET_INBOX_REQUEST, request)
if err != nil {
return nil, err
} else {
return result.(*GetInboxResult), nil
}
}
func init() {
API_RESULT[SYSTEM_CALL_RESULT] = SystemCallResult{}
API_RESULT[ECHO_RESULT] = EchoResult{}
@ -193,4 +203,5 @@ func init() {
API_RESULT[POST_TO_OUTBOX_RESULT] = PostToOutboxResult{}
API_RESULT[GET_OUTBOX_RESULT] = GetOutboxResult{}
API_RESULT[POST_TO_INBOX_RESULT] = PostToInboxResult{}
API_RESULT[GET_INBOX_RESULT] = GetInboxResult{}
}

Wyświetl plik

@ -1159,6 +1159,10 @@ func (conductor *conductor) PostToInbox(username string, editor Identity) (IPost
return conductor.spiManager.PostToInbox(username, editor)
}
func (conductor *conductor) GetInbox(username string, editor Identity) (IGetInboxResult, error) {
return conductor.spiManager.GetInbox(username, editor)
}
func (conductor *conductor) NewDocument(id int64, content string) (IDocument, error) {
return NewDocument(id, content)
}
@ -1291,6 +1295,10 @@ func (conductor *conductor) NewPostToInboxResult(_ interface{}) IPostToInboxResu
return NewPostToInboxResult(nil)
}
func (conductor *conductor) NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, _ interface{}) IGetInboxResult {
return NewGetInboxResult(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 {

Wyświetl plik

@ -298,3 +298,7 @@ func (dispatcher *dispatcher) GetOutbox(username string) (IGetOutboxResult, erro
func (dispatcher *dispatcher) PostToInbox(username string) (IPostToInboxResult, error) {
return dispatcher.conductor.SpiManager().PostToInbox(username, dispatcher.identity)
}
func (dispatcher *dispatcher) GetInbox(username string) (IGetInboxResult, error) {
return dispatcher.conductor.SpiManager().GetInbox(username, dispatcher.identity)
}

Wyświetl plik

@ -1030,3 +1030,68 @@ func (manager *spiManager) PostToInbox(username string, editor Identity) (result
return result, nil
}
}
//region IGetInboxResult Implementation
type getInboxResult struct {
context string
id string
type_ string
totalItems int32
orderedItems []IActivityPubActivity
first string
}
func NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string, _ interface{}) IGetInboxResult {
return &getInboxResult{
context: context,
id: id,
type_: type_,
totalItems: totalItems,
orderedItems: orderedItems,
first: first,
}
}
func (result getInboxResult) Context() string {
return result.context
}
func (result getInboxResult) Id() string {
return result.id
}
func (result getInboxResult) Type() string {
return result.type_
}
func (result getInboxResult) TotalItems() int32 {
return result.totalItems
}
func (result getInboxResult) OrderedItems() []IActivityPubActivity {
return result.orderedItems
}
func (result getInboxResult) First() string {
return result.first
}
//endregion
func (manager *spiManager) GetInbox(username string, editor Identity) (result IGetInboxResult, err error) {
defer func() {
if reason := recover(); reason != nil {
err = manager.Error(reason)
}
}()
editor.Lock(GET_INBOX_REQUEST)
defer editor.Unlock(GET_INBOX_REQUEST)
if result, err = commands.GetInbox(NewDispatcher(Conductor, editor), username); err != nil {
return nil, err
} else {
return result, nil
}
}

Wyświetl plik

@ -68,4 +68,8 @@ func (dispatcher *dispatcher) NewPostToInboxResult() IPostToInboxResult {
return NewPostToInboxResult(nil)
}
func (dispatcher *dispatcher) NewGetInboxResult(context string, id string, type_ string, totalItems int32, orderedItems []IActivityPubActivity, first string) IGetInboxResult {
return NewGetInboxResult(context, id, type_, totalItems, orderedItems, first, nil)
}
//endregion