chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package message
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Type string
|
||||
|
||||
const (
|
||||
TypeChat Type = "chat"
|
||||
TypeProposal Type = "proposal"
|
||||
TypeQuestion Type = "question"
|
||||
TypeDecision Type = "decision"
|
||||
TypeSummary Type = "summary"
|
||||
)
|
||||
|
||||
type DeliveryState string
|
||||
|
||||
const (
|
||||
DeliveryPending DeliveryState = "pending"
|
||||
DeliveryReceived DeliveryState = "received"
|
||||
DeliveryArchived DeliveryState = "archived"
|
||||
)
|
||||
|
||||
type Record struct {
|
||||
ID string `json:"id"`
|
||||
WorkspaceID string `json:"workspace_id"`
|
||||
TopicID string `json:"topic_id"`
|
||||
FromRoleName string `json:"from_role_name"`
|
||||
ToExpr string `json:"to_expr"`
|
||||
Type Type `json:"type"`
|
||||
Stage string `json:"stage"`
|
||||
ReplyToMessageID string `json:"reply_to_message_id,omitempty"`
|
||||
BodyMarkdown string `json:"body_markdown"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
type DeliveryClaim struct {
|
||||
Message Record `json:"message"`
|
||||
RecipientRoleName string `json:"recipient_role_name"`
|
||||
State DeliveryState `json:"state"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type PendingDelivery struct {
|
||||
TopicID string `json:"topic_id"`
|
||||
RoleName string `json:"role_name"`
|
||||
Count int `json:"count"`
|
||||
LastUpdated string `json:"last_updated"`
|
||||
}
|
||||
|
||||
func (r Record) Validate() error {
|
||||
if r.WorkspaceID == "" {
|
||||
return fmt.Errorf("workspace id is required")
|
||||
}
|
||||
if r.TopicID == "" {
|
||||
return fmt.Errorf("topic id is required")
|
||||
}
|
||||
if r.FromRoleName == "" {
|
||||
return fmt.Errorf("from role is required")
|
||||
}
|
||||
if r.ToExpr == "" {
|
||||
return fmt.Errorf("to expr is required")
|
||||
}
|
||||
switch r.Type {
|
||||
case TypeChat, TypeProposal, TypeQuestion, TypeDecision, TypeSummary:
|
||||
default:
|
||||
return fmt.Errorf("invalid message type %q", r.Type)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user