unfurl

package
v0.0.0-...-f10651d Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: BSD-3-Clause Imports: 30 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassifyDomain

func ClassifyDomain(domain string) chat1.UnfurlType

func GetDefaultAppleTouchURL

func GetDefaultAppleTouchURL(uri string) (string, error)

func GetDefaultFaviconURL

func GetDefaultFaviconURL(uri string) (string, error)

func GetDomain

func GetDomain(uri string) (res string, err error)

func GetHostname

func GetHostname(uri string) (string, error)

func IsDomain

func IsDomain(domain, target string) bool

Types

type Extractor

type Extractor struct {
	utils.DebugLabeler
	// contains filtered or unexported fields
}

func NewExtractor

func NewExtractor(g *globals.Context) *Extractor

func (*Extractor) AddWhitelistExemption

func (e *Extractor) AddWhitelistExemption(ctx context.Context, uid gregor1.UID,
	exemption types.WhitelistExemption)

func (*Extractor) Extract

func (e *Extractor) Extract(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
	msgID chat1.MessageID, body string, userSettings *Settings) (res []ExtractorHit, err error)

type ExtractorHit

type ExtractorHit struct {
	URL string
	Typ ExtractorHitTyp
}

type ExtractorHitTyp

type ExtractorHitTyp int
const (
	ExtractorHitUnfurl ExtractorHitTyp = iota
	ExtractorHitPrompt
)

type OneTimeWhitelistExemption

type OneTimeWhitelistExemption struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewOneTimeWhitelistExemption

func NewOneTimeWhitelistExemption(convID chat1.ConversationID, msgID chat1.MessageID, domain string) *OneTimeWhitelistExemption

func (*OneTimeWhitelistExemption) Domain

func (o *OneTimeWhitelistExemption) Domain() string

func (*OneTimeWhitelistExemption) Matches

func (o *OneTimeWhitelistExemption) Matches(convID chat1.ConversationID, msgID chat1.MessageID,
	domain string) bool

func (*OneTimeWhitelistExemption) Use

type Packager

type Packager struct {
	globals.Contextified
	utils.DebugLabeler
	// contains filtered or unexported fields
}

func NewPackager

func NewPackager(g *globals.Context, store attachments.Store, s3signer s3.Signer,
	ri func() chat1.RemoteInterface) *Packager

func (*Packager) Package

func (p *Packager) Package(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
	raw chat1.UnfurlRaw) (res chat1.Unfurl, err error)

type Scraper

type Scraper struct {
	globals.Contextified
	utils.DebugLabeler
	// contains filtered or unexported fields
}

func NewScraper

func NewScraper(g *globals.Context) *Scraper

func (*Scraper) Scrape

func (s *Scraper) Scrape(ctx context.Context, uri string, forceTyp *chat1.UnfurlType) (res chat1.UnfurlRaw, err error)

type Settings

type Settings struct {
	utils.DebugLabeler
	// contains filtered or unexported fields
}

func (*Settings) Get

func (s *Settings) Get(ctx context.Context, uid gregor1.UID) (res chat1.UnfurlSettings, err error)

func (*Settings) Set

func (s *Settings) Set(ctx context.Context, uid gregor1.UID, settings chat1.UnfurlSettings) (err error)

func (*Settings) SetMode

func (s *Settings) SetMode(ctx context.Context, uid gregor1.UID, mode chat1.UnfurlMode) (err error)

func (*Settings) WhitelistAdd

func (s *Settings) WhitelistAdd(ctx context.Context, uid gregor1.UID, domain string) (err error)

func (*Settings) WhitelistRemove

func (s *Settings) WhitelistRemove(ctx context.Context, uid gregor1.UID, domain string) (err error)

type SingleMessageWhitelistExemption

type SingleMessageWhitelistExemption struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSingleMessageWhitelistExemption

func NewSingleMessageWhitelistExemption(convID chat1.ConversationID, msgID chat1.MessageID, domain string) *SingleMessageWhitelistExemption

func (*SingleMessageWhitelistExemption) Domain

func (*SingleMessageWhitelistExemption) Matches

func (*SingleMessageWhitelistExemption) Use

type UnfurlMessageSender

type UnfurlMessageSender interface {
	SendUnfurlNonblock(ctx context.Context, convID chat1.ConversationID,
		msg chat1.MessagePlaintext, clientPrev chat1.MessageID, outboxID chat1.OutboxID) (chat1.OutboxID, error)
}

type Unfurler

type Unfurler struct {
	sync.Mutex

	globals.Contextified
	utils.DebugLabeler
	// contains filtered or unexported fields
}

func (*Unfurler) Complete

func (u *Unfurler) Complete(ctx context.Context, outboxID chat1.OutboxID)

func (*Unfurler) GetSettings

func (u *Unfurler) GetSettings(ctx context.Context, uid gregor1.UID) (res chat1.UnfurlSettings, err error)

func (*Unfurler) Prefetch

func (u *Unfurler) Prefetch(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
	msgText string) (numPrefetched int)

Prefetch attempts to parse hits out of `msgText` and scrape/package the unfurl so the result is cached.

func (*Unfurler) Retry

func (u *Unfurler) Retry(ctx context.Context, outboxID chat1.OutboxID)

func (*Unfurler) SetClock

func (u *Unfurler) SetClock(clock clockwork.Clock)

func (*Unfurler) SetMode

func (u *Unfurler) SetMode(ctx context.Context, uid gregor1.UID, mode chat1.UnfurlMode) (err error)

func (*Unfurler) SetSettings

func (u *Unfurler) SetSettings(ctx context.Context, uid gregor1.UID, settings chat1.UnfurlSettings) (err error)

func (*Unfurler) SetTestingRetryCh

func (u *Unfurler) SetTestingRetryCh(ch chan struct{})

func (*Unfurler) SetTestingUnfurlCh

func (u *Unfurler) SetTestingUnfurlCh(ch chan *chat1.Unfurl)

func (*Unfurler) Status

func (u *Unfurler) Status(ctx context.Context, outboxID chat1.OutboxID) (status types.UnfurlerTaskStatus, res *chat1.UnfurlResult, err error)

func (*Unfurler) UnfurlAndSend

func (u *Unfurler) UnfurlAndSend(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID,
	msg chat1.MessageUnboxed)

func (*Unfurler) WhitelistAdd

func (u *Unfurler) WhitelistAdd(ctx context.Context, uid gregor1.UID, domain string) (err error)

func (*Unfurler) WhitelistAddExemption

func (u *Unfurler) WhitelistAddExemption(ctx context.Context, uid gregor1.UID,
	exemption types.WhitelistExemption)

func (*Unfurler) WhitelistRemove

func (u *Unfurler) WhitelistRemove(ctx context.Context, uid gregor1.UID, domain string) (err error)

type WhitelistExemptionList

type WhitelistExemptionList struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewWhitelistExemptionList

func NewWhitelistExemptionList() *WhitelistExemptionList

func (*WhitelistExemptionList) Add

func (*WhitelistExemptionList) Use

func (l *WhitelistExemptionList) Use(convID chat1.ConversationID, msgID chat1.MessageID, domain string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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