Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
// LastMessage specifies the message id from what you want to get new messages.
LastMessage = "messages_since"
)
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(r *echo.Group, service Service, cService connection.Service, logger log.Logger)
RegisterHandlers sets up the routing of the HTTP handlers.
Types ¶
type CreateMessageRequest ¶
type CreateMessageRequest struct { Body string `json:"body"` Options MessageOptions `json:"options,omitempty"` }
func (CreateMessageRequest) Validate ¶
func (m CreateMessageRequest) Validate() *response.Error
Validate validates the CreateMessageRequest fields.
type ExtListResponse ¶
type Message ¶
type Message struct { ID string `json:"id"` ConnectionID string `json:"connection_id"` CID string `json:"cid"` RID string `json:"rid"` Body string `json:"body"` IAT time.Time `json:"iat"` Read bool `json:"read"` Received bool `json:"received"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Message represents the data about an message.
type MessageObject ¶
type MessageObject struct { Link string `json:"link"` Name string `json:"name"` Mime string `json:"mime"` Expires int64 `json:"expires,omitempty"` Key string `json:"key,omitempty"` }
func (MessageObject) Validate ¶
func (m MessageObject) Validate() error
type MessageOptions ¶
type MessageOptions struct {
Objects []MessageObject `json:"objects"`
}
type Repository ¶
type Repository interface { // Get returns the message with the specified message ID. Get(ctx context.Context, connectionID int, id string) (entity.Message, error) // Count returns the number of messages. Count(ctx context.Context, connectionID, messagesSince int) (int, error) // Query returns the list of messages with the given offset and limit. Query(ctx context.Context, connection int, messagesSince int, offset, limit int) ([]entity.Message, error) // Create saves a new message in the storage. Create(ctx context.Context, message *entity.Message) error // Update updates the message with given ID in the storage. Update(ctx context.Context, message entity.Message) error // Delete removes the message with given ID from the storage. Delete(ctx context.Context, connectionID int, id string) error }
Repository encapsulates the logic to access messages from the data source.
func NewRepository ¶
func NewRepository(db *dbcontext.DB, logger log.Logger) Repository
NewRepository creates a new message repository
type Service ¶
type Service interface { Get(ctx context.Context, connectionID int, jti string) (Message, error) Query(ctx context.Context, connection int, messagesSince int, offset, limit int) ([]Message, error) Count(ctx context.Context, connectionID, messagesSince int) (int, error) Create(ctx context.Context, appID, connectionID string, connection int, input CreateMessageRequest) (Message, error) Update(ctx context.Context, appID string, connectionID int, selfID string, jti string, req UpdateMessageRequest) (Message, error) Delete(ctx context.Context, connectionID int, jti string) error MarkAsRead(ctx context.Context, appID, connection, jti string, connectionID int) error MarkAsReceived(ctx context.Context, appID, connection, jti string, connectionID int) error }
Service encapsulates usecase logic for messages.
func NewService ¶
func NewService(repo Repository, runner support.SelfClientGetter, logger log.Logger) Service
NewService creates a new message service.
type UpdateMessageRequest ¶
type UpdateMessageRequest struct {
Body string `json:"body"`
}
UpdateMessageRequest represents an message update request.
func (UpdateMessageRequest) Validate ¶
func (m UpdateMessageRequest) Validate() *response.Error
Validate validates the CreateMessageRequest fields.
Click to show internal directories.
Click to hide internal directories.