2022-11-21 14:14:45 +00:00
|
|
|
package operations
|
|
|
|
|
|
|
|
import (
|
2023-04-21 06:49:17 +00:00
|
|
|
. "github.com/reiver/greatape/components/api/protobuf"
|
|
|
|
. "github.com/reiver/greatape/components/api/services"
|
2023-06-26 07:50:54 +00:00
|
|
|
. "github.com/reiver/greatape/components/constants"
|
2023-04-21 06:49:17 +00:00
|
|
|
. "github.com/reiver/greatape/components/contracts"
|
2022-11-21 14:14:45 +00:00
|
|
|
. "github.com/xeronith/diamante/contracts/operation"
|
|
|
|
. "github.com/xeronith/diamante/contracts/service"
|
|
|
|
. "github.com/xeronith/diamante/contracts/system"
|
|
|
|
. "github.com/xeronith/diamante/operation"
|
|
|
|
)
|
|
|
|
|
2023-06-26 07:50:54 +00:00
|
|
|
type (
|
|
|
|
WebfingerRunner func(IContext, *WebfingerRequest) (*WebfingerResult, error)
|
|
|
|
WebfingerRunners []WebfingerRunner
|
2022-11-21 14:14:45 +00:00
|
|
|
|
2023-06-26 07:50:54 +00:00
|
|
|
webfingerOperation struct {
|
|
|
|
Operation
|
|
|
|
|
|
|
|
runners WebfingerRunners
|
|
|
|
}
|
|
|
|
)
|
2022-11-21 14:14:45 +00:00
|
|
|
|
|
|
|
func WebfingerOperation() IOperation {
|
|
|
|
return &webfingerOperation{
|
2023-06-26 07:50:54 +00:00
|
|
|
runners: WebfingerRunners{
|
|
|
|
WebfingerService,
|
|
|
|
},
|
2022-11-21 14:14:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-26 07:50:54 +00:00
|
|
|
func (operation *webfingerOperation) Tag() string {
|
|
|
|
return "WEBFINGER"
|
|
|
|
}
|
|
|
|
|
2022-11-21 14:14:45 +00:00
|
|
|
func (operation *webfingerOperation) Id() (ID, ID) {
|
|
|
|
return WEBFINGER_REQUEST, WEBFINGER_RESULT
|
|
|
|
}
|
|
|
|
|
|
|
|
func (operation *webfingerOperation) InputContainer() Pointer {
|
|
|
|
return new(WebfingerRequest)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (operation *webfingerOperation) OutputContainer() Pointer {
|
|
|
|
return new(WebfingerResult)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (operation *webfingerOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
2023-06-26 07:50:54 +00:00
|
|
|
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
|
|
|
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
|
|
|
}
|
|
|
|
|
|
|
|
service := operation.runners[operation.ActiveRunner()]
|
|
|
|
if input, valid := payload.(*WebfingerRequest); valid {
|
|
|
|
return service(context, input)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
2022-11-21 14:14:45 +00:00
|
|
|
}
|