Documentation
¶
Index ¶
- Constants
- Variables
- func FormatMarkdown(outputs []MessageOutput, dates DateFormatter, options MarkdownOptions) string
- func FormatPretty(outputs []MessageOutput, dates DateFormatter, options PrettyOptions) string
- func FormatUnreadMarkdown(document UnreadEnvelope, peek []MessageOutput, dates DateFormatter, ...) (string, error)
- func FormatUnreadPretty(document UnreadEnvelope, peek []MessageOutput, dates DateFormatter, ...) (string, error)
- func FormatWatchHumanLine(timestamp time.Time, sender, message string, color bool) string
- func ValidMachineSchema(command, schema string) bool
- func WriteBoundedJSON(w io.Writer, value any) (int, error)
- func WriteMachineJSON(w io.Writer, value MachineDocument) (int, error)
- func WriteMarkdown(w io.Writer, outputs []MessageOutput, dates DateFormatter, ...) (int, error)
- func WritePretty(w io.Writer, outputs []MessageOutput, dates DateFormatter, ...) (int, error)
- func WriteWatchDocument(writer io.Writer, document WatchDocument) error
- type Attachment
- type AttachmentField
- type Channel
- type ChannelEnvelope
- type ChannelItem
- type ChannelTeam
- type ChannelsEnvelope
- type ConfigEnvelope
- type DMSEnvelope
- type DateFormatter
- func (f DateFormatter) DateGroupLabel(date time.Time) string
- func (f DateFormatter) FormatDate(date time.Time, includeYear bool) string
- func (f DateFormatter) FormatDateLong(date time.Time) string
- func (f DateFormatter) FormatRelativeTime(date time.Time) string
- func (f DateFormatter) FormatTime(date time.Time) string
- type DoctorCheck
- type DoctorEnvelope
- type ErrorEnvelope
- type File
- type FileDownloadEnvelope
- type GroupDMSEnvelope
- type Identity
- type JSONLWatchSink
- type MachineChannel
- type MachineCompleteness
- type MachineDocument
- type MachineHistory
- type MachineMessage
- type MachineMetadata
- type MarkdownOptions
- type MentionsEnvelope
- type Message
- type MessageOutput
- type MillisTime
- type PrettyOptions
- type RawChannel
- type RawIdentity
- type RawTeam
- type RawUnreadItem
- type RawUser
- type Reaction
- type ReactionActor
- type Redaction
- type Retrieval
- type SearchEnvelope
- type Selection
- type TeamItem
- type TeamsEnvelope
- type ThreadData
- type ThreadEnvelope
- type UnreadData
- type UnreadEnvelope
- type UnreadItem
- type UnreadProof
- type UserItem
- type UsersEnvelope
- type UsersRetrieval
- type UsersRetrievalProof
- type VisibleThreads
- type WatchDocument
- type WatchSequence
- type WhoAmIEnvelope
Constants ¶
const MaxMachineDocumentBytes = 4 << 20
const MaxSafeMachineInteger int64 = 9007199254740991
const MaxWatchLineBytes = 1 << 20
Variables ¶
var ErrInvalidWatchDocument = errors.New("invalid watch document")
var ErrPartialWatchLine = errors.New("partial JSONL write; stream is no longer recoverable")
var ErrWatchOutput = errors.New("watch output unavailable")
Functions ¶
func FormatMarkdown ¶
func FormatMarkdown(outputs []MessageOutput, dates DateFormatter, options MarkdownOptions) string
FormatMarkdown renders already-presented values without further sanitizing them.
func FormatPretty ¶
func FormatPretty(outputs []MessageOutput, dates DateFormatter, options PrettyOptions) string
FormatPretty renders already-presented values. It deliberately performs no sanitization or redaction of its own.
func FormatUnreadMarkdown ¶
func FormatUnreadMarkdown(document UnreadEnvelope, peek []MessageOutput, dates DateFormatter, options MarkdownOptions) (string, error)
func FormatUnreadPretty ¶
func FormatUnreadPretty(document UnreadEnvelope, peek []MessageOutput, dates DateFormatter, options PrettyOptions) (string, error)
func FormatWatchHumanLine ¶
func ValidMachineSchema ¶
func WriteBoundedJSON ¶
WriteBoundedJSON emits canonical machine JSON using the same byte policy as WriteMachineJSON. It is for versioned machine documents whose concrete type is owned outside output's closed MachineDocument set.
func WriteMachineJSON ¶
func WriteMachineJSON(w io.Writer, value MachineDocument) (int, error)
WriteMachineJSON encodes one bounded value, appends exactly one newline, and performs one write. A short or failed write is returned and never retried.
func WriteMarkdown ¶
func WriteMarkdown(w io.Writer, outputs []MessageOutput, dates DateFormatter, options MarkdownOptions) (int, error)
WriteMarkdown renders and writes exactly once. It never retries an uncertain write.
func WritePretty ¶
func WritePretty(w io.Writer, outputs []MessageOutput, dates DateFormatter, options PrettyOptions) (int, error)
WritePretty renders once and writes once. A short write is returned as io.ErrShortWrite and is never retried, since the writer's state is unknown.
func WriteWatchDocument ¶
func WriteWatchDocument(writer io.Writer, document WatchDocument) error
Types ¶
type Attachment ¶
type Attachment struct {
Fallback string `json:"fallback,omitempty"`
Pretext string `json:"pretext,omitempty"`
Title string `json:"title,omitempty"`
TitleLink string `json:"titleLink,omitempty"`
Text string `json:"text,omitempty"`
Fields []AttachmentField `json:"fields,omitempty"`
AuthorName string `json:"authorName,omitempty"`
AuthorLink string `json:"authorLink,omitempty"`
AuthorIcon string `json:"authorIcon,omitempty"`
Color string `json:"color,omitempty"`
ImageURL string `json:"imageUrl,omitempty"`
ThumbURL string `json:"thumbUrl,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
}
type AttachmentField ¶
type ChannelEnvelope ¶
type ChannelEnvelope struct {
Schema string `json:"schema"`
Data MachineHistory `json:"data"`
}
func NewChannelEnvelope ¶
func NewChannelEnvelope(value MessageOutput, completeness MachineCompleteness) (ChannelEnvelope, error)
type ChannelItem ¶
type ChannelItem struct {
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
DisplayName *string `json:"displayName"`
Team *ChannelTeam `json:"team"`
LastPost *MillisTime `json:"lastPost"`
MessageCount int64 `json:"messageCount"`
}
type ChannelTeam ¶
type ChannelsEnvelope ¶
type ChannelsEnvelope struct {
Schema string `json:"schema"`
Channels []ChannelItem `json:"channels"`
// contains filtered or unexported fields
}
func NewChannelsEnvelope ¶
func NewChannelsEnvelope(raw []RawChannel, options presentation.Options) (ChannelsEnvelope, error)
type ConfigEnvelope ¶
type ConfigEnvelope struct {
Schema string `json:"schema"`
Action string `json:"action"`
SelectedPath string `json:"selectedPath"`
ReadPath *string `json:"readPath"`
Migration *string `json:"migration"`
Exists *bool `json:"exists"`
URLConfigured *bool `json:"urlConfigured"`
TokenConfigured *bool `json:"tokenConfigured"`
StageTTLSeconds *int64 `json:"stageTtlSeconds"`
StagePruneAfterSeconds *int64 `json:"stagePruneAfterSeconds"`
Permissions *string `json:"permissions"`
ReadStatus *string `json:"readStatus"`
ParseStatus *string `json:"parseStatus"`
UnsafeReason *string `json:"unsafeReason"`
Created *bool `json:"created"`
Warning *string `json:"warning"`
}
type DMSEnvelope ¶
type DMSEnvelope struct {
Schema string `json:"schema"`
Channels []MachineHistory `json:"channels"`
}
func NewDMSEnvelope ¶
func NewDMSEnvelope(values []MessageOutput, completeness MachineCompleteness) (DMSEnvelope, error)
type DateFormatter ¶
type DateFormatter struct {
// contains filtered or unexported fields
}
func NewDateFormatter ¶
func NewDateFormatter(now func() time.Time, location *time.Location) DateFormatter
func (DateFormatter) DateGroupLabel ¶
func (f DateFormatter) DateGroupLabel(date time.Time) string
func (DateFormatter) FormatDate ¶
func (f DateFormatter) FormatDate(date time.Time, includeYear bool) string
func (DateFormatter) FormatDateLong ¶
func (f DateFormatter) FormatDateLong(date time.Time) string
func (DateFormatter) FormatRelativeTime ¶
func (f DateFormatter) FormatRelativeTime(date time.Time) string
func (DateFormatter) FormatTime ¶
func (f DateFormatter) FormatTime(date time.Time) string
type DoctorCheck ¶
type DoctorEnvelope ¶
type DoctorEnvelope struct {
Schema string `json:"schema"`
OK bool `json:"ok"`
Checks []DoctorCheck `json:"checks"`
}
func NewDoctorEnvelope ¶
func NewDoctorEnvelope(ok bool, checks []DoctorCheck) (DoctorEnvelope, error)
type ErrorEnvelope ¶
type FileDownloadEnvelope ¶ added in v2.1.0
type FileDownloadEnvelope struct {
Schema string `json:"schema"`
FileID string `json:"fileId"`
Name string `json:"name"`
MIMEType string `json:"mimeType"`
SizeBytes int64 `json:"sizeBytes"`
SHA256 string `json:"sha256"`
Path string `json:"path"`
Temporary bool `json:"temporary"`
}
func NewFileDownloadEnvelope ¶ added in v2.1.0
type GroupDMSEnvelope ¶
type GroupDMSEnvelope struct {
Schema string `json:"schema"`
Channels []MachineHistory `json:"channels"`
}
func NewGroupDMSEnvelope ¶
func NewGroupDMSEnvelope(values []MessageOutput, completeness MachineCompleteness) (GroupDMSEnvelope, error)
type JSONLWatchSink ¶
func (JSONLWatchSink) Diagnostic ¶
func (sink JSONLWatchSink) Diagnostic(value mattermost.WatchDiagnostic) error
func (JSONLWatchSink) Post ¶
func (sink JSONLWatchSink) Post(post mattermost.WatchPost, sequence mattermost.Sequence) error
type MachineChannel ¶
type MachineCompleteness ¶
type MachineCompleteness string
const ( MachineComplete MachineCompleteness = "complete" MachineTruncated MachineCompleteness = "truncated" MachineUnknown MachineCompleteness = "unknown" )
type MachineDocument ¶
type MachineDocument interface {
// contains filtered or unexported methods
}
type MachineHistory ¶
type MachineHistory struct {
Channel MachineChannel `json:"channel"`
Messages []MachineMessage `json:"messages"`
Redactions []Redaction `json:"redactions"`
Metadata MachineMetadata `json:"metadata"`
}
func MachineHistoryFromOutput ¶
func MachineHistoryFromOutput(value MessageOutput, completeness MachineCompleteness) (MachineHistory, error)
MachineHistoryFromOutput converts one independently headed output section.
type MachineMessage ¶
type MachineMessage struct {
ID string `json:"id"`
Permalink string `json:"permalink"`
User string `json:"user"`
UserID string `json:"userId"`
Text string `json:"text"`
Timestamp MillisTime `json:"timestamp"`
UpdatedAt MillisTime `json:"updatedAt"`
EditedAt *MillisTime `json:"editedAt"`
DeletedAt *MillisTime `json:"deletedAt"`
IsDeleted bool `json:"isDeleted"`
PostType string `json:"postType"`
IsSystem bool `json:"isSystem"`
IsPinned bool `json:"isPinned"`
RootID *string `json:"rootId"`
ReplyCount *int `json:"replyCount"`
Files []string `json:"files"`
FileDetails []File `json:"fileDetails"`
Attachments []Attachment `json:"attachments"`
Reactions []Reaction `json:"reactions"`
Replies []MachineMessage `json:"replies"`
}
func MachineMessageFromMessage ¶
func MachineMessageFromMessage(message Message) MachineMessage
MachineMessageFromMessage losslessly copies a presentation message into its machine representation. Timestamps retain their instant and are normalized to UTC; collection and pointer fields do not alias the input.
type MachineMetadata ¶
type MachineMetadata struct {
Completeness MachineCompleteness `json:"completeness"`
Selection Selection `json:"selection"`
VisibleThreads VisibleThreads `json:"visibleThreads"`
VisiblePostCount int `json:"visiblePostCount"`
DeletedPostsIncluded bool `json:"deletedPostsIncluded"`
}
MachineMetadata preserves the distinction between false/empty and unknown. Pointer fields are always encoded: nil is the machine contract's explicit null.
type MarkdownOptions ¶
type MarkdownOptions struct {
Relative bool
}
type MentionsEnvelope ¶
type MentionsEnvelope struct {
Schema string `json:"schema"`
Results []MachineHistory `json:"results"`
}
func NewMentionsEnvelope ¶
func NewMentionsEnvelope(values []MessageOutput, completeness MachineCompleteness) (MentionsEnvelope, error)
type Message ¶
type Message struct {
ID string `json:"id"`
Permalink string `json:"permalink"`
User string `json:"user"`
UserID string `json:"userId"`
Text string `json:"text"`
Timestamp time.Time `json:"timestamp"`
UpdatedAt time.Time `json:"updatedAt"`
EditedAt *time.Time `json:"editedAt,omitempty"`
DeletedAt *time.Time `json:"deletedAt,omitempty"`
IsDeleted bool `json:"isDeleted"`
PostType string `json:"postType"`
IsSystem bool `json:"isSystem"`
IsPinned bool `json:"isPinned"`
Files []string `json:"files"`
FileDetails []File `json:"fileDetails"`
Attachments []Attachment `json:"attachments"`
Reactions []Reaction `json:"reactions"`
RootID string `json:"rootId,omitempty"`
ReplyCount *int `json:"replyCount,omitempty"`
Replies []Message `json:"replies,omitempty"`
// Canonical identities are unsanitized internal values. They drive
// ordering and grouping but are never serialized.
CanonicalID string `json:"-"`
CanonicalRootID string `json:"-"`
CanonicalThreadShapeKnown *bool `json:"-"`
}
func GroupIntoThreads ¶
type MessageOutput ¶
type MessageOutput struct {
Channel Channel
Messages []Message
Redactions []Redaction
Retrieval Retrieval
}
MessageOutput is one independently headed channel section.
type MillisTime ¶
func (MillisTime) MarshalJSON ¶
func (value MillisTime) MarshalJSON() ([]byte, error)
type PrettyOptions ¶
type RawChannel ¶
type RawIdentity ¶
type RawUnreadItem ¶
type RawUnreadItem struct {
Channel RawChannel
UnreadCount int64
MentionCount int64
LastViewedAt int64
}
type Reaction ¶
type Reaction struct {
Emoji string `json:"emoji"`
Count int `json:"count"`
Actors []ReactionActor `json:"actors"`
}
type ReactionActor ¶
type Redaction ¶
type Redaction = presentation.Redaction
Redaction is presentation-owned because its Position is a UTF-16 code-unit offset into the final sanitized text. Output models must not recompute it.
type Retrieval ¶
type Retrieval struct {
Selection Selection `json:"selection"`
VisibleThreads VisibleThreads `json:"visibleThreads"`
VisiblePostCount int `json:"visiblePostCount"`
DeletedPostsIncluded bool `json:"deletedPostsIncluded"`
}
type SearchEnvelope ¶
type SearchEnvelope struct {
Schema string `json:"schema"`
Results []MachineHistory `json:"results"`
}
func NewSearchEnvelope ¶
func NewSearchEnvelope(values []MessageOutput, completeness MachineCompleteness) (SearchEnvelope, error)
type TeamsEnvelope ¶
type TeamsEnvelope struct {
Schema string `json:"schema"`
Teams []TeamItem `json:"teams"`
// contains filtered or unexported fields
}
func NewTeamsEnvelope ¶
func NewTeamsEnvelope(raw []RawTeam, options presentation.Options) (TeamsEnvelope, error)
type ThreadData ¶
type ThreadData struct {
Channel MachineChannel `json:"channel"`
Root *MachineMessage `json:"root"`
UnboundPosts []MachineMessage `json:"unboundPosts"`
Redactions []Redaction `json:"redactions"`
Metadata MachineMetadata `json:"metadata"`
}
type ThreadEnvelope ¶
type ThreadEnvelope struct {
Schema string `json:"schema"`
Data ThreadData `json:"data"`
}
func NewThreadEnvelope ¶
func NewThreadEnvelope(value MessageOutput, completeness MachineCompleteness) (ThreadEnvelope, error)
NewThreadEnvelope preserves a proven root when available and carries rootless partial posts separately. It never promotes unknown shape to root.
type UnreadData ¶
type UnreadData struct {
Unread []UnreadItem `json:"unread"`
Peek []MachineHistory `json:"peek"`
}
type UnreadEnvelope ¶
type UnreadEnvelope struct {
Schema string `json:"schema"`
Data UnreadData `json:"data"`
// contains filtered or unexported fields
}
func NewUnreadEnvelope ¶
func NewUnreadEnvelope(raw []RawUnreadItem, peek []MessageOutput, proof UnreadProof, options presentation.Options) (UnreadEnvelope, error)
type UnreadItem ¶
type UnreadItem struct {
Channel ChannelItem `json:"channel"`
UnreadCount int64 `json:"unreadCount"`
MentionCount int64 `json:"mentionCount"`
LastViewedAt *MillisTime `json:"lastViewedAt"`
}
type UnreadProof ¶
type UnreadProof struct {
// PeekLimit is nil when peek was not requested. A non-nil value requires
// one full history per unread summary channel, including confirmed empties.
PeekLimit *int
}
type UsersEnvelope ¶
type UsersEnvelope struct {
Schema string `json:"schema"`
Users []UserItem `json:"users"`
Retrieval UsersRetrieval `json:"retrieval"`
// contains filtered or unexported fields
}
func NewUsersEnvelope ¶
func NewUsersEnvelope(raw []RawUser, proof UsersRetrievalProof, options presentation.Options) (UsersEnvelope, error)
type UsersRetrieval ¶
type UsersRetrievalProof ¶
type VisibleThreads ¶
type WatchDocument ¶
type WatchDocument interface {
// contains filtered or unexported methods
}
func NewWatchDiagnostic ¶
func NewWatchDiagnostic(value mattermost.WatchDiagnostic) (WatchDocument, error)
func NewWatchEvent ¶
func NewWatchEvent(post mattermost.WatchPost, sequence mattermost.Sequence, disableHeuristics bool) (WatchDocument, error)
type WatchSequence ¶
type WhoAmIEnvelope ¶
type WhoAmIEnvelope struct {
Schema string `json:"schema"`
Data Identity `json:"data"`
// contains filtered or unexported fields
}
func NewWhoAmIEnvelope ¶
func NewWhoAmIEnvelope(raw RawIdentity, options presentation.Options) (WhoAmIEnvelope, error)