brutalinks

package module
v0.0.0-...-b75ba5b Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 56 Imported by: 0

README

About

This project represents a new attempt at the social link aggregator service. It is modeled after (old)Reddit, HackerNews, and Lobste.rs trying to combine the good parts of these services while mapping them on the foundation of an ActivityPub generic service called FedBOX.

It targets small to medium communities which ideally focus on a single topic. At the same it allows the community to reach other similar services and the rest of the fediverse ecosystem through the ability to federate.

The community can be built using an invitation based model, where a user shares the responsibility for moderating the other accounts they invited to the service. The moderation actions are kept public and presented in an anonymized layout.

Built using a performant stack, and with minimal dependencies, it tries to provide an easy out of the box installation.


MIT Licensed Builds status

Documentation

Index

Constants

View Source
const (
	// Deleted label
	Deleted = "deleted"
	// Anonymous label
	Anonymous = "anonymous"
	// System label
	System = "system"
)
View Source
const (
	FlagsDeleted = FlagBits(1 << iota)
	FlagsOperator
	FlagsModerator
	FlagsApplication
	FlagsGroup
	FlagsService
	FlagsPrivate

	FlagsNone = FlagBits(0)
)
View Source
const (
	MimeTypeURL      = "application/url"
	MimeTypeHTML     = "text/html"
	MimeTypeMarkdown = "text/markdown"
	MimeTypeText     = "text/plain"
	MimeTypeSVG      = "image/svg+xml"
	MimeTypeCss      = "text/css"
)
View Source
const (
	DiasporaProfile = vocab.IRI("https://nodeinfo.diaspora.software/ns/schema")
	Mastodon        = "mastodon"
)
View Source
const (
	Success flashType = "success"
	Info    flashType = "info"
	Warning flashType = "warning"
	Error   flashType = "error"
)
View Source
const (
	TagMention = "mention"
	TagTag     = "tag"
)
View Source
const (
	ScoreMultiplier = 1
	ScoreMaxK       = 10000.0
	ScoreMaxM       = 10000000.0
	ScoreMaxB       = 10000000000.0
)
View Source
const (
	ScoreItem = ScoreType(iota)
	ScoreAccount
)
View Source
const Delete = "rm"
View Source
const Edit = "edit"
View Source
const (
	MaxContentItems = 35
)
View Source
const Nay = "nay"
View Source
const Report = "bad"
View Source
const SessionUserKey = "__current_acct"
View Source
const Yay = "yay"

Variables

View Source
var (
	// DeletedAccount is a default static value for a deleted account
	DeletedAccount = Account{Handle: Anonymous, Hash: AnonymousHash, Metadata: new(AccountMetadata), Pub: &vocab.Tombstone{}}
	// AnonymousAccount is a default static value for the anonymous account
	AnonymousAccount = Account{Handle: Anonymous, Hash: AnonymousHash, Metadata: new(AccountMetadata)}
	// SystemAccount is a default static value for the system account
	SystemAccount = Account{Handle: System, Hash: SystemHash, Metadata: new(AccountMetadata)}
	// DeletedItem is a default static value for a deleted item
	DeletedItem = Item{Title: Deleted, Hash: AnonymousHash, Metadata: new(ItemMetadata), Pub: &vocab.Tombstone{}}
)
View Source
var (
	CreateActivitiesFilter       = ActivityTypesFilter(vocab.CreateType)
	AppreciationActivitiesFilter = ActivityTypesFilter(vocab.LikeType, vocab.DislikeType)
)
View Source
var (
	AnonymousHash = Hash{}
	SystemHash    = Hash{0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
)

AnonymousHash is the sha hash for the anonymous account

View Source
var ContentManagementActivitiesFilter = ActivityTypesFilter(ValidContentManagementTypes...)
View Source
var CreateFollowActivitiesFilter = CompStrs{
	CompStr{Str: string(vocab.CreateType)},
	CompStr{Str: string(vocab.FollowType)},
}
View Source
var HNGravity = 1.5

represents how fast elapsed hours affect the order of an item

View Source
var LocalHTMLPolicy = BlueMondayPolicy()
View Source
var ModerationActivitiesFilter = ActivityTypesFilter(ValidModerationActivityTypes...)
View Source
var StatisticalConfidence = 1.94

represents the statistical confidence var StatisticalConfidence = 1.0 => ~69%, 1.96 => ~95% (default)

Functions

func AccountBlocks

func AccountBlocks(by, b *Account) bool

func AccountFollows

func AccountFollows(a, by *Account) bool

func AccountIgnores

func AccountIgnores(by, b *Account) bool

func AccountIsBlocked

func AccountIsBlocked(by, a *Account) bool

func AccountIsFollowed

func AccountIsFollowed(a, by *Account) bool

func AccountIsIgnored

func AccountIsIgnored(by, a *Account) bool

func AccountIsRejected

func AccountIsRejected(by, a *Account) bool

func AccountIsReported

func AccountIsReported(by, a *Account) bool

func AccountListingModelMw

func AccountListingModelMw(next http.Handler) http.Handler
func AccountLocalLink(a *Account) string
func AccountPermaLink(a *Account) string

AccountPermaLink

func ActivityPubService

func ActivityPubService(c appConfig) (*repository, error)

func ActorsFiltersMw

func ActorsFiltersMw(next http.Handler) http.Handler

func AddModelMw

func AddModelMw(next http.Handler) http.Handler

func AllFilters

func AllFilters(next http.Handler) http.Handler

func Authors

func Authors(d *deps)

func BlockAccountModelMw

func BlockAccountModelMw(next http.Handler) http.Handler

func BlockContentModelMw

func BlockContentModelMw(next http.Handler) http.Handler

func BlueMondayPolicy

func BlueMondayPolicy() *bluemonday.Policy

func BuildID

func BuildID(r Renderable) (vocab.ID, bool)

func BuildIDFromItem

func BuildIDFromItem(i Item) (vocab.ID, bool)

func ConnectFedBOX

func ConnectFedBOX(h *handler, c appConfig) error

func Contains

func Contains[T Renderable](sl []T, it T) bool

func ContentModelMw

func ContentModelMw(next http.Handler) http.Handler

func ContextContentModel

func ContextContentModel(ctx context.Context) *contentModel

func ContextDependentLoads

func ContextDependentLoads(ctx context.Context) *deps

func ContextListingModel

func ContextListingModel(ctx context.Context) *listingModel

func ContextModerationModel

func ContextModerationModel(ctx context.Context) *moderationModel

func ContextRegisterModel

func ContextRegisterModel(ctx context.Context) *registerModel

func ContextRepository

func ContextRepository(ctx context.Context) *repository

func CurrentTab

func CurrentTab(r *http.Request) func(h headerEl) bool

func DefaultFilters

func DefaultFilters(next http.Handler) http.Handler

func Deps

func Deps(depsSetFn ...func(*deps)) func(next http.Handler) http.Handler

func DomainFiltersMw

func DomainFiltersMw(next http.Handler) http.Handler

func EditContentModelMw

func EditContentModelMw(next http.Handler) http.Handler

func FederatedFiltersMw

func FederatedFiltersMw(id vocab.IRI) func(next http.Handler) http.Handler

func FollowFilterMw

func FollowFilterMw(next http.Handler) http.Handler

func FollowedFiltersMw

func FollowedFiltersMw(next http.Handler) http.Handler

func Follows

func Follows(d *deps)

func FromActor

func FromActor(a *Account, p *vocab.Actor) error

func FromArticle

func FromArticle(i *Item, a *vocab.Object) error

func FromMention

func FromMention(t *Tag, a *vocab.Mention) error

func FromObject

func FromObject(a *Account, o *vocab.Object) error

func FromObjectWithBinaryData

func FromObjectWithBinaryData(i *Item, a *vocab.Object) error

func FromTag

func FromTag(t *Tag, a *vocab.Object) error

func GetID

func GetID(a Renderable) vocab.ID
func GetInviteLink(v *view) func(invitee *Account) template.HTMLAttr

func HostIsLocal

func HostIsLocal(s string) bool

func InOutbox

func InOutbox(a *Account, it ...vocab.Item) bool

func ItemIsReported

func ItemIsReported(by *Account, i *Item) bool
func ItemLocalLink(i *Item) string

ItemLocalLink

func ItemPermaLink(i *Item) string

ItemPermaLink

func ListingModelMw

func ListingModelMw(next http.Handler) http.Handler

func LoadFromSearches

func LoadFromSearches(ctx context.Context, repo *repository, loads RemoteLoads, fn searchFn) error

func LoadInvitedMw

func LoadInvitedMw(next http.Handler) http.Handler

func LoadMw

func LoadMw(next http.Handler) http.Handler

func LoadSingleItemMw

func LoadSingleItemMw(next http.Handler) http.Handler

func LoadSingleObjectMw

func LoadSingleObjectMw(next http.Handler) http.Handler

func Markdown

func Markdown(data string) template.HTML

Markdown outputs the markdown render of a string

func MessageFiltersMw

func MessageFiltersMw(next http.Handler) http.Handler

func MessageUserContentModelMw

func MessageUserContentModelMw(next http.Handler) http.Handler

func ModerationFiltersMw

func ModerationFiltersMw(next http.Handler) http.Handler

func ModerationListingFiltersMw

func ModerationListingFiltersMw(next http.Handler) http.Handler

func Moderations

func Moderations(d *deps)

func NewClient

func NewClient(o ...OptionFn) (*fedbox, error)

func NodeInfoConfig

func NodeInfoConfig() nodeinfo.Config

func OperatorSearches

func OperatorSearches(next http.Handler) http.Handler

func OutOfOrderMw

func OutOfOrderMw(v *view) func(next http.Handler) http.Handler
func PermaLink(r Renderable) string

PermaLink

func Reddit

func Reddit(ups, downs int64, date time.Duration) float64

reddit's hot sort http://amix.dk/blog/post/19588

func Replies

func Replies(d *deps)

func ReportAccountModelMw

func ReportAccountModelMw(next http.Handler) http.Handler

func ReportContentModelMw

func ReportContentModelMw(next http.Handler) http.Handler

func SearchInCollectionsMw

func SearchInCollectionsMw(getActorsFn func(r *http.Request) vocab.ItemCollection, collections ...LoadFn) func(next http.Handler) http.Handler

func SelfFiltersMw

func SelfFiltersMw(id vocab.IRI) func(next http.Handler) http.Handler

func ShowAccountHandle

func ShowAccountHandle(a *Account) string

ShowAccountHandle

func SignByAppMw

func SignByAppMw(next http.Handler) http.Handler

func SingleItemModelMw

func SingleItemModelMw(next http.Handler) http.Handler

func SortByDate

func SortByDate(next http.Handler) http.Handler

func SortByRecentActivity

func SortByRecentActivity(next http.Handler) http.Handler

func SortByScore

func SortByScore(next http.Handler) http.Handler

func TagFiltersMw

func TagFiltersMw(next http.Handler) http.Handler

func ToTitle

func ToTitle(s string) string

func Values

func Values(f interface{}) client.FilterFn

func ViewInit

func ViewInit(c appConfig, l log.Logger) (*view, error)

func Votes

func Votes(d *deps)

func WarmupCaches

func WarmupCaches(r *repository, self vocab.Item) error

func Wilson

func Wilson(ups, downs int64) float64

wilson score interval sort http://www.evanmiller.org/how-not-to-sort-by-average-rating.html

Types

type Account

type Account struct {
	Hash      Hash              `json:"hash,omitempty"`
	Handle    string            `json:"handle,omitempty"`
	CreatedAt time.Time         `json:"-"`
	CreatedBy *Account          `json:"-"`
	UpdatedAt time.Time         `json:"-"`
	Flags     FlagBits          `json:"flags,omitempty"`
	Metadata  *AccountMetadata  `json:"metadata,omitempty"`
	Pub       vocab.Item        `json:"-"`
	Followers AccountCollection `json:"-"`
	Following AccountCollection `json:"-"`
	Blocked   AccountCollection `json:"-"`
	Ignored   AccountCollection `json:"-"`
	Level     uint8             `json:"-"`
	Parent    Renderable        `json:"-"`
	// contains filtered or unexported fields
}

func AuthorizeOAuthClient

func AuthorizeOAuthClient(storage *repository, c appConfig) (*Account, error)

func ContextAccount

func ContextAccount(ctx context.Context) *Account

func (*Account) AP

func (a *Account) AP() vocab.Item

AP returns the underlying actvitypub item

func (*Account) Children

func (a *Account) Children() *RenderableList

func (Account) Date

func (a Account) Date() time.Time

func (*Account) Deleted

func (a *Account) Deleted() bool

Deleted

func (*Account) FromActivityPub

func (a *Account) FromActivityPub(it vocab.Item) error
func (a Account) GetLink() string

func (*Account) HasIcon

func (a *Account) HasIcon() bool

HasIcon

func (*Account) HasMetadata

func (a *Account) HasMetadata() bool

HasMetadata

func (*Account) HasPublicKey

func (a *Account) HasPublicKey() bool

HasPublicKey returns if current account had a public ssh key generated

func (*Account) ID

func (a *Account) ID() Hash

func (*Account) IsApplication

func (a *Account) IsApplication() bool

IsApplication

func (*Account) IsFederated

func (a *Account) IsFederated() bool

IsFederated

func (*Account) IsGroup

func (a *Account) IsGroup() bool

IsGroup

func (*Account) IsLocal

func (a *Account) IsLocal() bool

IsLocal

func (*Account) IsLogged

func (a *Account) IsLogged() bool

IsLogged should show if current user was loaded from a session

func (*Account) IsModerator

func (a *Account) IsModerator() bool

IsModerator

func (*Account) IsOperator

func (a *Account) IsOperator() bool

IsOperator

func (*Account) IsService

func (a *Account) IsService() bool

IsService

func (*Account) IsValid

func (a *Account) IsValid() bool

IsValid returns if the current account has a handle or a hash with length greater than 0

func (*Account) Private

func (a *Account) Private() bool

Private

func (Account) Type

func (a Account) Type() RenderType

func (Account) VotedOn

func (a Account) VotedOn(i Item) *Vote

func (Account) Votes

func (a Account) Votes() VoteCollection

type AccountCollection

type AccountCollection []Account

func ContextAuthors

func ContextAuthors(ctx context.Context) AccountCollection

func (AccountCollection) Contains

func (a AccountCollection) Contains(b Account) bool

func (AccountCollection) First

func (a AccountCollection) First() (*Account, error)

First

func (AccountCollection) Split

func (a AccountCollection) Split(pieceCount int) []AccountCollection

type AccountMetadata

type AccountMetadata struct {
	Password              []byte               `json:"pw,omitempty"`
	Key                   *SSHKey              `json:"key,omitempty"`
	Blurb                 string               `json:"blurb,omitempty"`
	Icon                  ImageMetadata        `json:"icon,omitempty"`
	Name                  string               `json:"name,omitempty"`
	ID                    string               `json:"id,omitempty"`
	URL                   string               `json:"url,omitempty"`
	Tags                  TagCollection        `json:"tags,omitempty"`
	InboxIRI              string               `json:"inbox,omitempty"`
	OutboxIRI             string               `json:"outbox,omitempty"`
	LikedIRI              string               `json:"liked,omitempty"`
	FollowersIRI          string               `json:"followers,omitempty"`
	FollowingIRI          string               `json:"following,omitempty"`
	OAuth                 OAuth                `json:"-"`
	AuthorizationEndPoint string               `json:"authorizationEndPoint,omitempty"`
	TokenEndPoint         string               `json:"tokenEndPoint,omitempty"`
	OutboxUpdated         time.Time            `json:"outboxUpdated,omitempty"`
	Outbox                vocab.ItemCollection `json:"-"`
}

func (*AccountMetadata) InvalidateOutbox

func (m *AccountMetadata) InvalidateOutbox()

type AccountPtrCollection

type AccountPtrCollection []*Account

type ActivityMetadata

type ActivityMetadata struct {
	ID        string     `json:"-"`
	InReplyTo vocab.IRIs `json:"-"`
}

ActivityMetadata

type Application

type Application struct {
	Version string
	BaseURL url.URL
	Conf    *config.Configuration
	ModTags TagCollection
	Logger  log.Logger

	Mux *chi.Mux
	// contains filtered or unexported fields
}

Application is the global state of our application

var Instance *Application

Instance is the default instance of our application

func New

func New(c *config.Configuration, l log.Logger, host string, port int, ver string) (*Application, error)

New instantiates a new Application

func (*Application) Front

func (a *Application) Front() error

func (Application) NodeInfo

func (a Application) NodeInfo() WebInfo

func (*Application) Reload

func (a *Application) Reload() error

func (*Application) Routes

func (a *Application) Routes()

type Cacheable

type Cacheable interface {
	GetAge() int
}

type CollectionFilterFn

type CollectionFilterFn func(context.Context, ...client.FilterFn) (vocab.CollectionInterface, error)

type CollectionFn

type CollectionFn func(context.Context, *Filters) (vocab.CollectionInterface, error)

type CollectionLoadFn

type CollectionLoadFn func(vocab.CollectionInterface) error

type CompStr

type CompStr = qstring.ComparativeString

func DifferentThanString

func DifferentThanString(s string) CompStr

func EqualsString

func EqualsString(s string) CompStr

func LikeString

func LikeString(s string) CompStr

type CompStrs

type CompStrs []CompStr

func AccountsIRIFilter

func AccountsIRIFilter(accounts ...Account) CompStrs

func ActivityTypesFilter

func ActivityTypesFilter(t ...vocab.ActivityVocabularyType) CompStrs

func IRIsFilter

func IRIsFilter(iris ...vocab.IRI) CompStrs

func IRIsLikeFilter

func IRIsLikeFilter(iris ...vocab.IRI) CompStrs

func ItemIRIFilter

func ItemIRIFilter(items ...Item) CompStrs

func ModerationSubmittedByHashFilter

func ModerationSubmittedByHashFilter(items ...ModerationOp) CompStrs

func (CompStrs) Contains

func (cs CompStrs) Contains(f CompStr) bool

type Converter

type Converter interface {
	FromActivityPub(ob vocab.Item) error
}

type CtxLogFn

type CtxLogFn func(...log.Ctx) LogFn

type CtxtKey

type CtxtKey string
var (
	ServicesCtxtKey      CtxtKey = "__di"
	LoggedAccountCtxtKey CtxtKey = "__acct"
	RepositoryCtxtKey    CtxtKey = "__repository"
	FilterCtxtKey        CtxtKey = "__filter"
	LoadsCtxtKey         CtxtKey = "__loads"
	ModelCtxtKey         CtxtKey = "__model"
	AuthorCtxtKey        CtxtKey = "__author"
	CursorCtxtKey        CtxtKey = "__cursor"
	ContentCtxtKey       CtxtKey = "__content"
	DependenciesCtxtKey  CtxtKey = "__deps"
)

type Cursor

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

func ContextCursor

func ContextCursor(ctx context.Context) *Cursor

type Deletable

type Deletable interface {
	Deleted() bool
	Delete()
	UnDelete()
}

Deletable

type Desc

type Desc struct {
	Description string   `json:"description"`
	Email       string   `json:"email"`
	Stats       Stats    `json:"stats"`
	Thumbnail   string   `json:"thumbnail,omitempty"`
	Title       string   `json:"title"`
	Lang        []string `json:"languages"`
	URI         string   `json:"uri"`
	Urls        []string `json:"urls,omitempty"`
	Version     string   `json:"version"`
}

Desc holds data for keeping compatibility with Mastodon instances

type ErrorHandler

type ErrorHandler func(http.ResponseWriter, *http.Request, ...error)

type ErrorHandlerFn

type ErrorHandlerFn func(eh ErrorHandler) Handler

type FedInstance

type FedInstance struct {
	BaseURL     string
	SharedInbox string
	Name        string
	Description string
	Email       string
}

type Filters

type Filters struct {
	Name       CompStrs  `qstring:"name,omitempty"`
	Cont       CompStrs  `qstring:"content,omitempty"`
	MedTypes   CompStrs  `qstring:"mediaType,omitempty"`
	URL        CompStrs  `qstring:"url,omitempty"`
	IRI        CompStrs  `qstring:"iri,omitempty"`
	Generator  CompStrs  `qstring:"generator,omitempty"`
	Type       CompStrs  `qstring:"type,omitempty"`
	AttrTo     CompStrs  `qstring:"attributedTo,omitempty"`
	InReplTo   CompStrs  `qstring:"inReplyTo,omitempty"`
	OP         CompStrs  `qstring:"context,omitempty"`
	Recipients CompStrs  `qstring:"recipients,omitempty"`
	Next       vocab.IRI `qstring:"after,omitempty"`
	Prev       vocab.IRI `qstring:"before,omitempty"`
	MaxItems   int       `qstring:"maxItems,omitempty"`
	Object     *Filters  `qstring:"object,omitempty"`
	Tag        *Filters  `qstring:"tag,omitempty"`
	Actor      *Filters  `qstring:"actor,omitempty"`
}

func ContextActivityFilters

func ContextActivityFilters(ctx context.Context) []*Filters

ContextActivityFilters loads the filters we use for generating storage queries from the HTTP request

func FilterAccountByHandle

func FilterAccountByHandle(handle string) *Filters

func FiltersFromRequest

func FiltersFromRequest(r *http.Request) *Filters

FiltersFromRequest loads the filters we use for generating storage queries from the HTTP request

type FlagBits

type FlagBits uint8

func (*FlagBits) FromInt64

func (f *FlagBits) FromInt64() error

func (FlagBits) MarshalJSON

func (f FlagBits) MarshalJSON() ([]byte, error)

type FollowRequest

type FollowRequest struct {
	Hash        Hash              `json:"hash"`
	SubmittedAt time.Time         `json:"-"`
	SubmittedBy *Account          `json:"by,omitempty"`
	Object      *Account          `json:"-"`
	Metadata    *ActivityMetadata `json:"-"`

	Flags FlagBits `json:"flags,omitempty"`
	// contains filtered or unexported fields
}

FollowRequest

func ContextFollowRequest

func ContextFollowRequest(ctx context.Context) *FollowRequest

func FollowRequestFromContext

func FollowRequestFromContext(ctx context.Context, hash string) (FollowRequest, error)

func (*FollowRequest) AP

func (f *FollowRequest) AP() vocab.Item

AP returns the underlying actvitypub item

func (*FollowRequest) Children

func (f *FollowRequest) Children() *RenderableList

func (FollowRequest) Date

func (f FollowRequest) Date() time.Time

Date

func (*FollowRequest) Deleted

func (f *FollowRequest) Deleted() bool

Deleted

func (*FollowRequest) FromActivityPub

func (f *FollowRequest) FromActivityPub(it vocab.Item) error

FromActivityPub

func (*FollowRequest) ID

func (f *FollowRequest) ID() Hash

func (*FollowRequest) IsValid

func (f *FollowRequest) IsValid() bool

IsValid returns if the current follow request has a hash with length greater than 0

func (*FollowRequest) Private

func (f *FollowRequest) Private() bool

Private

func (*FollowRequest) Type

func (f *FollowRequest) Type() RenderType

Type

type FollowRequests

type FollowRequests []FollowRequest

FollowRequests

type Handler

type Handler func(http.Handler) http.Handler

func ModelMw

func ModelMw(m Model) Handler

type HasContent

type HasContent interface {
	Content() map[string][]byte
	Tags() TagCollection
	Mentions() TagCollection
}

type Hash

type Hash uuid.UUID

Hash is a local type for string, it should hold a [32]byte array actually

func HashFromIRI

func HashFromIRI(i vocab.IRI) Hash

func HashFromItem

func HashFromItem(obj vocab.Item) Hash

func HashFromString

func HashFromString(s string) Hash

func (*Hash) FromActivityPub

func (h *Hash) FromActivityPub(it vocab.Item) error

func (Hash) IsValid

func (h Hash) IsValid() bool

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

MarshalText

func (Hash) String

func (h Hash) String() string

String returns the hash as a string

type Hashes

type Hashes []Hash

func (Hashes) Contains

func (h Hashes) Contains(s Hash) bool

func (Hashes) String

func (h Hashes) String() string

type Identifiable

type Identifiable interface {
	Id() int64
}

type ImageMetadata

type ImageMetadata struct {
	URI      string `json:"uri,omitempty"`
	MimeType string `json:"mimeType,omitempty"`
}

type Item

type Item struct {
	Hash        Hash           `json:"hash"`
	Title       string         `json:"-"`
	MimeType    string         `json:"-"`
	Data        string         `json:"-"`
	Votes       VoteCollection `json:"-"`
	SubmittedAt time.Time      `json:"-"`
	SubmittedBy *Account       `json:"by,omitempty"`
	UpdatedAt   time.Time      `json:"-"`
	UpdatedBy   *Account       `json:"-"`
	Flags       FlagBits       `json:"-"`
	Metadata    *ItemMetadata  `json:"-"`
	Pub         vocab.Item     `json:"-"`
	Parent      Renderable     `json:"-"`
	OP          Renderable     `json:"-"`
	Level       uint8          `json:"-"`
	// contains filtered or unexported fields
}

Item

func ContentFromRequest

func ContentFromRequest(r *http.Request, author Account) (Item, error)

func ContextItem

func ContextItem(ctx context.Context) *Item

func ItemFromContext

func ItemFromContext(ctx context.Context, repo *repository, hash string) (Item, error)

func (*Item) AP

func (i *Item) AP() vocab.Item

AP returns the underlying actvitypub item

func (*Item) Children

func (i *Item) Children() *RenderableList

func (Item) Content

func (i Item) Content() map[string][]byte

Content returns the content of the Item

func (Item) Date

func (i Item) Date() time.Time

func (*Item) Delete

func (i *Item) Delete()

Delete add the deleted flag on an item

func (*Item) Deleted

func (i *Item) Deleted() bool

func (*Item) FromActivityPub

func (i *Item) FromActivityPub(it vocab.Item) error

func (*Item) HasMetadata

func (i *Item) HasMetadata() bool

HasMetadata

func (*Item) ID

func (i *Item) ID() Hash

func (Item) IsFederated

func (i Item) IsFederated() bool

IsFederated

func (i Item) IsLink() bool

func (Item) IsLocal

func (i Item) IsLocal() bool

IsLocal

func (Item) IsSelf

func (i Item) IsSelf() bool

func (*Item) IsTop

func (i *Item) IsTop() bool

IsTop returns true if current item is a top level submission

func (*Item) IsValid

func (i *Item) IsValid() bool

func (*Item) MakePrivate

func (i *Item) MakePrivate()

func (*Item) MakePublic

func (i *Item) MakePublic()

func (Item) Mentions

func (i Item) Mentions() TagCollection

Mentions returns the mentions associated with the current Item

func (*Item) Private

func (i *Item) Private() bool

func (*Item) Public

func (i *Item) Public() bool

func (Item) Score

func (i Item) Score() int

func (Item) Tags

func (i Item) Tags() TagCollection

Tags returns the tags associated with the current Item

func (*Item) Type

func (i *Item) Type() RenderType

func (*Item) UnDelete

func (i *Item) UnDelete()

UnDelete remove the deleted flag from an item

type ItemCollection

type ItemCollection []Item

func (ItemCollection) Contains

func (i ItemCollection) Contains(cc Item) bool

func (ItemCollection) First

func (i ItemCollection) First() (*Item, error)

func (ItemCollection) Split

func (i ItemCollection) Split(pieceCount int) []ItemCollection

type ItemMetadata

type ItemMetadata struct {
	To         AccountCollection `json:"to,omitempty"`
	CC         AccountCollection `json:"to,omitempty"`
	Tags       TagCollection     `json:"tags,omitempty"`
	Mentions   TagCollection     `json:"mentions,omitempty"`
	ID         string            `json:"id,omitempty"`
	URL        string            `json:"url,omitempty"`
	RepliesURI string            `json:"replies,omitempty"`
	LikesURI   string            `json:"likes,omitempty"`
	SharesURI  string            `json:"shares,omitempty"`
	AuthorURI  string            `json:"author,omitempty"`
	Icon       ImageMetadata     `json:"icon,omitempty"`
}

type ItemPtrCollection

type ItemPtrCollection []*Item

func (ItemPtrCollection) Contains

func (h ItemPtrCollection) Contains(it Item) bool

func (ItemPtrCollection) Sorted

type Links []domainLink
func GetDomainLinks(i Item) Links

type LoadFn

type LoadFn func(vocab.Item, ...client.FilterFn) vocab.IRI

type LogFn

type LogFn func(string, ...interface{})

type Model

type Model interface {
	SetTitle(string)
	Template() string
}

func ContextModel

func ContextModel(ctx context.Context) Model

type Moderatable

type Moderatable interface {
	IsDelete() bool
	IsUpdate() bool
	IsBlock() bool
	IsReport() bool
	IsIgnore() bool
}

type ModerationGroup

type ModerationGroup struct {
	Hash        Hash            `json:"hash"`
	Icon        template.HTML   `json:"-"`
	SubmittedAt time.Time       `json:"-"`
	Object      Renderable      `json:"-"`
	Requests    []*ModerationOp `json:"-"`
	Followup    []*ModerationOp `json:"-"`
}

func (*ModerationGroup) AP

func (m *ModerationGroup) AP() vocab.Item

AP returns the underlying actvitypub item

func (*ModerationGroup) Children

func (m *ModerationGroup) Children() *RenderableList

func (ModerationGroup) Date

func (m ModerationGroup) Date() time.Time

Date

func (*ModerationGroup) Deleted

func (m *ModerationGroup) Deleted() bool

Hash

func (*ModerationGroup) FromActivityPub

func (m *ModerationGroup) FromActivityPub(it vocab.Item) error

func (*ModerationGroup) ID

func (m *ModerationGroup) ID() Hash

func (ModerationGroup) IsBlock

func (m ModerationGroup) IsBlock() bool

IsBlock returns true if current moderation request is a block

func (ModerationGroup) IsDelete

func (m ModerationGroup) IsDelete() bool

IsDelete returns true if current moderation request is a delete

func (ModerationGroup) IsIgnore

func (m ModerationGroup) IsIgnore() bool

IsIgnore returns true if current moderation request is a ignore

func (ModerationGroup) IsReport

func (m ModerationGroup) IsReport() bool

IsReport returns true if current moderation request is a report

func (ModerationGroup) IsUpdate

func (m ModerationGroup) IsUpdate() bool

IsUpdate returns true if current moderation request is an update

func (*ModerationGroup) IsValid

func (m *ModerationGroup) IsValid() bool

IsValid returns if the current follow request group has a hash with length greater than 0

func (*ModerationGroup) Private

func (m *ModerationGroup) Private() bool

Hash

func (*ModerationGroup) Type

func (m *ModerationGroup) Type() RenderType

Type

type ModerationMetadata

type ModerationMetadata struct {
	ID        string        `json:"-"`
	InReplyTo vocab.IRIs    `json:"-"`
	Tags      TagCollection `json:"tags,omitempty"`
	Mentions  TagCollection `json:"mentions,omitempty"`
}

type ModerationOp

type ModerationOp struct {
	Hash        Hash                `json:"hash"`
	Icon        template.HTML       `json:"-"`
	SubmittedAt time.Time           `json:"-"`
	Data        string              `json:"-"`
	MimeType    string              `json:"-"`
	SubmittedBy *Account            `json:"by,omitempty"`
	Object      Renderable          `json:"-"`
	Metadata    *ModerationMetadata `json:"-"`
	Pub         vocab.Item          `json:"-"`
	Flags       FlagBits            `json:"flags,omitempty"`
}

func (*ModerationOp) AP

func (m *ModerationOp) AP() vocab.Item

AP returns the underlying actvitypub item

func (*ModerationOp) Children

func (m *ModerationOp) Children() *RenderableList

func (ModerationOp) Content

func (m ModerationOp) Content() map[string][]byte

Content returns the reason for it

func (ModerationOp) Date

func (m ModerationOp) Date() time.Time

Date

func (*ModerationOp) Deleted

func (m *ModerationOp) Deleted() bool

Deleted

func (*ModerationOp) FromActivityPub

func (m *ModerationOp) FromActivityPub(it vocab.Item) error

func (ModerationOp) ID

func (m ModerationOp) ID() Hash

func (ModerationOp) IsBlock

func (m ModerationOp) IsBlock() bool

IsBlock returns true if current moderation request is a block

func (ModerationOp) IsDelete

func (m ModerationOp) IsDelete() bool

IsBlock returns true if current moderation request is a delete

func (ModerationOp) IsIgnore

func (m ModerationOp) IsIgnore() bool

IsIgnore returns true if current moderation request is a ignore

func (ModerationOp) IsReport

func (m ModerationOp) IsReport() bool

IsReport returns true if current moderation request is a report

func (ModerationOp) IsUpdate

func (m ModerationOp) IsUpdate() bool

IsUpdate returns true if current moderation request is an update

func (*ModerationOp) IsValid

func (m *ModerationOp) IsValid() bool

IsValid returns if the current follow request has a hash with length greater than 0

func (ModerationOp) Mentions

func (m ModerationOp) Mentions() TagCollection

Mentions returns the mentions associated with the current ModerationOp

func (*ModerationOp) Private

func (m *ModerationOp) Private() bool

Private

func (ModerationOp) Tags

func (m ModerationOp) Tags() TagCollection

Tags returns the tags associated with the current ModerationOp

func (ModerationOp) Type

func (m ModerationOp) Type() RenderType

Type

type ModerationRequests

type ModerationRequests []ModerationOp

ModerationRequests

func (ModerationRequests) Contains

func (m ModerationRequests) Contains(mop ModerationOp) bool

type NodeInfoResolver

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

func NodeInfoResolverNew

func NodeInfoResolverNew(r *repository) NodeInfoResolver

func (NodeInfoResolver) IsOpenRegistration

func (n NodeInfoResolver) IsOpenRegistration() (bool, error)

func (NodeInfoResolver) Usage

func (n NodeInfoResolver) Usage() (nodeinfo.Usage, error)

type OAuth

type OAuth struct {
	Provider string
	Code     string
	Token    *oauth2.Token
	State    string
}

type OptionFn

type OptionFn func(*fedbox) error

func SkipTLSCheck

func SkipTLSCheck(skip bool) OptionFn

func WithLogger

func WithLogger(l log.Logger) OptionFn

func WithUA

func WithUA(s string) OptionFn

func WithURL

func WithURL(s string) OptionFn

type Paginator

type Paginator interface {
	SetCursor(*Cursor)
	NextPage() Hash
	PrevPage() Hash
}

type RemoteLoad

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

type RemoteLoads

type RemoteLoads map[vocab.IRI][]RemoteLoad

func ContextLoads

func ContextLoads(ctx context.Context) RemoteLoads

ContextLoads loads the searches we use for generating storage queries from the HTTP request

type RenderType

type RenderType int
const (
	UnknownType RenderType = -1

	CommentType RenderType = iota
	FollowType
	AppreciationType
	ActorType
	ModerationType
)

type Renderable

type Renderable interface {
	ID() Hash
	AP() vocab.Item
	IsValid() bool
	Type() RenderType
	Date() time.Time
	Children() *RenderableList
}

func ByDate

func ByDate(r RenderableList) []Renderable

func ByRecentActivity

func ByRecentActivity(r RenderableList) []Renderable

func ByScore

func ByScore(r RenderableList) []Renderable

func GetRenderableByType

func GetRenderableByType(typ vocab.ActivityVocabularyType) Renderable

func LoadFromActivityPubItem

func LoadFromActivityPubItem(it vocab.Item) (Renderable, error)

type RenderableList

type RenderableList []Renderable

func (*RenderableList) Append

func (r *RenderableList) Append(others ...Renderable)

func (RenderableList) Contains

func (r RenderableList) Contains(ren Renderable) bool

func (RenderableList) Follows

func (r RenderableList) Follows() FollowRequests

func (RenderableList) Items

func (r RenderableList) Items() ItemCollection

func (*RenderableList) Merge

func (r *RenderableList) Merge(other RenderableList)

func (*RenderableList) Valid

func (r *RenderableList) Valid() bool

type SSHKey

type SSHKey struct {
	ID      string `json:"id"`
	Private []byte `json:"prv,omitempty"`
	Public  []byte `json:"pub,omitempty"`
}

type ScoreType

type ScoreType int

type Stats

type Stats struct {
	DomainCount int  `json:"domain_count"`
	UserCount   uint `json:"user_count"`
	StatusCount uint `json:"status_count"`
}

Stats holds data for keeping compatibility with Mastodon instances

type StopLoad

type StopLoad struct{}

func (StopLoad) Error

func (s StopLoad) Error() string

type StopSearchErr

type StopSearchErr string

func (StopSearchErr) Error

func (s StopSearchErr) Error() string

type Tag

type Tag struct {
	Hash        Hash          `json:"hash"`
	Type        string        `json:"-"`
	Name        string        `json:"name,omitempty"`
	URL         string        `json:"url,omitempty"`
	SubmittedAt time.Time     `json:"-"`
	SubmittedBy *Account      `json:"-"`
	UpdatedAt   time.Time     `json:"-"`
	UpdatedBy   *Account      `json:"-"`
	Metadata    *ItemMetadata `json:"-"`
	Pub         vocab.Item    `json:"-"`
}

func (*Tag) FromActivityPub

func (t *Tag) FromActivityPub(it vocab.Item) error

func (Tag) IsLocal

func (t Tag) IsLocal() bool

type TagCollection

type TagCollection []Tag

func LoadModeratorTags

func LoadModeratorTags(repo *repository) (TagCollection, error)

func SaveModeratorTags

func SaveModeratorTags(repo *repository) (TagCollection, error)

func (TagCollection) Contains

func (c TagCollection) Contains(t Tag) bool

func (*TagCollection) FromActivityPub

func (c *TagCollection) FromActivityPub(tag vocab.Item) error

type Vote

type Vote struct {
	SubmittedBy *Account        `json:"-"`
	SubmittedAt time.Time       `json:"-"`
	UpdatedAt   time.Time       `json:"-"`
	Weight      int             `json:"weight"`
	Item        *Item           `json:"on"`
	Flags       FlagBits        `json:"-"`
	Metadata    *VoteMetadata   `json:"-"`
	Pub         *vocab.Activity `json:"-"`
}

func (*Vote) AP

func (v *Vote) AP() vocab.Item

AP returns the underlying actvitypub item

func (*Vote) Children

func (v *Vote) Children() *RenderableList

func (Vote) Date

func (v Vote) Date() time.Time

Date

func (*Vote) FromActivityPub

func (v *Vote) FromActivityPub(it vocab.Item) error

func (Vote) HasMetadata

func (v Vote) HasMetadata() bool

HasMetadata

func (*Vote) ID

func (v *Vote) ID() Hash

func (Vote) IsNay

func (v Vote) IsNay() bool

IsNay returns true if current vote is a Nay

func (*Vote) IsValid

func (v *Vote) IsValid() bool

IsValid

func (Vote) IsYay

func (v Vote) IsYay() bool

IsYay returns true if current vote is a Yay

func (*Vote) Type

func (v *Vote) Type() RenderType

Type

type VoteCollection

type VoteCollection []Vote

func (VoteCollection) Contains

func (v VoteCollection) Contains(vot Vote) bool

func (VoteCollection) First

func (v VoteCollection) First() (*Vote, error)

func (VoteCollection) Score

func (v VoteCollection) Score() int

Score

type VoteMetadata

type VoteMetadata struct {
	IRI         string `json:"-"`
	OriginalIRI string `json:"-"`
}

type WebInfo

type WebInfo struct {
	Title       string   `json:"title"`
	Email       string   `json:"email"`
	Summary     string   `json:"summary"`
	Description string   `json:"description"`
	Thumbnail   string   `json:"thumbnail,omitempty"`
	Languages   []string `json:"languages"`
	URI         string   `json:"uri"`
	Urls        []string `json:"urls,omitempty"`
	Version     string   `json:"version"`
}

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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