notifications

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindNewTask   = "task_new"
	KindGraded    = "task_graded"
	KindRecording = "recording"
	KindOther     = "other"
)

Kind enumerates the bot post headers we recognize.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notification

type Notification struct {
	PostID     string
	PostURL    string // mm permalink, if available
	PostedAt   time.Time
	Kind       string
	Title      string // link title or first non-header line
	Excerpt    string // short snippet of the message
	CourseID   int    // 0 if not parseable
	ThemeID    int
	LongreadID int
	LMSURL     string // the linked LMS URL, if any
}

Notification is a structured view of one bot message linking back to LMS content.

func Parse

func Parse(postID, message string, postedAt time.Time) *Notification

Parse extracts a Notification from a single post. Returns nil for posts that don't reference any LMS resource we care about.

type Permalinker

type Permalinker interface {
	Permalink(postID string) string
}

Permalinker turns a post ID into a chat permalink. Optional.

type PostSource

type PostSource interface {
	LoadPosts(ctx context.Context) ([]RawPost, error)
}

PostSource hands back the post stream to scan.

type RawPost

type RawPost struct {
	ID       string
	Message  string
	CreateAt time.Time
}

RawPost mirrors the shape used by other usecases.

type UseCase

type UseCase struct {
	// contains filtered or unexported fields
}

UseCase wraps a PostSource with notification extraction + indexing.

func New

func New(src PostSource) *UseCase

func (*UseCase) All

func (uc *UseCase) All(ctx context.Context) ([]Notification, error)

All returns every parsed notification, newest first.

func (*UseCase) ByLongread

func (uc *UseCase) ByLongread(ctx context.Context) (map[int][]Notification, error)

ByLongread indexes every notification by its LongreadID (skipping zero IDs).

func (*UseCase) ForCourse

func (uc *UseCase) ForCourse(ctx context.Context, courseID int) ([]Notification, error)

ForCourse filters notifications by LMS course ID.

func (*UseCase) ForLongread

func (uc *UseCase) ForLongread(ctx context.Context, longreadID int) ([]Notification, error)

ForLongread filters notifications by LMS longread ID.

func (*UseCase) WithPermalinker

func (uc *UseCase) WithPermalinker(p Permalinker) *UseCase

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL