notifications

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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