activitypub

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2022 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActorCache = make(map[string]Actor)

Functions

func AcceptActivity

func AcceptActivity(header string) bool

func AddInstanceToIndexDB

func AddInstanceToIndexDB(actor string) error

func CreatePem

func CreatePem(actor Actor) error

func CreatePublicKeyFromPrivate

func CreatePublicKeyFromPrivate(actor *Actor, publicKeyPem string) error

func FingerRequest

func FingerRequest(actor string, instance string) (*http.Response, error)

func GetActorAndInstance

func GetActorAndInstance(path string) (string, string)

func GetActorFollowNameFromPath

func GetActorFollowNameFromPath(path string) string

func GetActorPemFileFromDB

func GetActorPemFileFromDB(pemID string) (string, error)

func GetObjectsWithoutPreviewsCallback

func GetObjectsWithoutPreviewsCallback(callback func(id string, href string, mediatype string, name string, size int, published time.Time) error) error

func GetToFromJson

func GetToFromJson(to []byte) ([]string, error)

func HasContextFromJson

func HasContextFromJson(context []byte) (bool, error)

func StorePemToDB

func StorePemToDB(actor Actor) error

Types

type Activity

type Activity struct {
	AtContext
	Type      string     `json:"type,omitempty"`
	Id        string     `json:"id,omitempty"`
	Actor     *Actor     `json:"actor,omitempty"`
	Name      string     `json:"name,omitempty"`
	Summary   string     `json:"summary,omitempty"`
	Auth      string     `json:"auth,omitempty"`
	To        []string   `json:"to,omitempty"`
	Bto       []string   `json:"bto,omitempty"`
	Cc        []string   `json:"cc,omitempty"`
	Published time.Time  `json:"published,omitempty"`
	Object    ObjectBase `json:"object,omitempty"`
}

func GetActivityFromJson

func GetActivityFromJson(ctx *fiber.Ctx) (Activity, error)

func (Activity) AcceptFollow

func (activity Activity) AcceptFollow() Activity

func (Activity) AddFollowersTo

func (activity Activity) AddFollowersTo() (Activity, error)

func (Activity) CheckValid

func (activity Activity) CheckValid() (Collection, bool, error)

func (Activity) GetCollection

func (activity Activity) GetCollection() (Collection, error)

func (Activity) IsLocal

func (activity Activity) IsLocal() (bool, error)

func (Activity) MakeRequestInbox

func (activity Activity) MakeRequestInbox() error

func (Activity) MakeRequestOutbox

func (activity Activity) MakeRequestOutbox() error

func (Activity) Process

func (activity Activity) Process() error

func (Activity) Reject

func (activity Activity) Reject() Activity

func (Activity) Report

func (activity Activity) Report(reason string) (bool, error)

func (Activity) SetActorFollower

func (activity Activity) SetActorFollower() (Activity, error)

func (Activity) SetActorFollowing

func (activity Activity) SetActorFollowing() (Activity, error)

type ActivityRaw

type ActivityRaw struct {
	AtContextRaw
	Type      string          `json:"type,omitempty"`
	Id        string          `json:"id,omitempty"`
	Name      string          `json:"name,omitempty"`
	Summary   string          `json:"summary,omitempty"`
	Auth      string          `json:"auth,omitempty"`
	ToRaw     json.RawMessage `json:"to,omitempty"`
	BtoRaw    json.RawMessage `json:"bto,omitempty"`
	CcRaw     json.RawMessage `json:"cc,omitempty"`
	Published time.Time       `json:"published,omitempty"`
	ActorRaw  json.RawMessage `json:"actor,omitempty"`
	ObjectRaw json.RawMessage `json:"object,omitempty"`
}

type Actor

type Actor struct {
	Type              string       `json:"type,omitempty"`
	Id                string       `json:"id,omitempty"`
	Inbox             string       `json:"inbox,omitempty"`
	Outbox            string       `json:"outbox,omitempty"`
	Following         string       `json:"following,omitempty"`
	Followers         string       `json:"followers,omitempty"`
	Name              string       `json:"name,omitempty"`
	PreferredUsername string       `json:"preferredUsername,omitempty"`
	PublicKey         PublicKeyPem `json:"publicKey,omitempty"`
	Summary           string       `json:"summary,omitempty"`
	AuthRequirement   []string     `json:"authrequirement,omitempty"`
	Restricted        bool         `json:"restricted"`
}

func CreateNewActor

func CreateNewActor(board string, prefName string, summary string, authReq []string, restricted bool) *Actor

func FingerActor

func FingerActor(path string) (Actor, error)

looks for actor with pattern of board@instance

func GetActor

func GetActor(id string) (Actor, error)

func GetActorByNameFromDB

func GetActorByNameFromDB(name string) (Actor, error)

func GetActorFromDB

func GetActorFromDB(id string) (Actor, error)

func GetActorFromJson

func GetActorFromJson(actor []byte) (Actor, error)

func GetBoards

func GetBoards() ([]Actor, error)

func (Actor) ActivitySign

func (actor Actor) ActivitySign(signature string) (string, error)

func (Actor) AddFollower

func (actor Actor) AddFollower(follower string) error

func (Actor) ArchivePosts

func (actor Actor) ArchivePosts() error

func (Actor) AutoFollow

func (actor Actor) AutoFollow() error

func (Actor) CreateVerification

func (actor Actor) CreateVerification(verify util.Verify) error

func (Actor) DeleteCache

func (actor Actor) DeleteCache() error

func (Actor) DeleteVerification

func (actor Actor) DeleteVerification(verify util.Verify) error

func (Actor) GetAllArchive

func (actor Actor) GetAllArchive(offset int) (Collection, error)

func (Actor) GetAutoSubscribe

func (actor Actor) GetAutoSubscribe() (bool, error)

func (Actor) GetCatalogCollection

func (actor Actor) GetCatalogCollection() (Collection, error)

func (Actor) GetCollection

func (actor Actor) GetCollection() (Collection, error)

func (Actor) GetCollectionPage

func (actor Actor) GetCollectionPage(page int) (Collection, error)

func (Actor) GetCollectionType

func (actor Actor) GetCollectionType(nType string) (Collection, error)

func (Actor) GetCollectionTypeLimit

func (actor Actor) GetCollectionTypeLimit(nType string, limit int) (Collection, error)

func (Actor) GetFollowFromName

func (actor Actor) GetFollowFromName(name string) ([]string, error)

func (Actor) GetFollower

func (actor Actor) GetFollower() ([]ObjectBase, error)

func (Actor) GetFollowersResp

func (actor Actor) GetFollowersResp(ctx *fiber.Ctx) error

func (Actor) GetFollowersTotal

func (actor Actor) GetFollowersTotal() (int, error)

func (Actor) GetFollowing

func (actor Actor) GetFollowing() ([]ObjectBase, error)

func (Actor) GetFollowingResp

func (actor Actor) GetFollowingResp(ctx *fiber.Ctx) error

func (Actor) GetFollowingTotal

func (actor Actor) GetFollowingTotal() (int, error)

func (Actor) GetImgTotal

func (actor Actor) GetImgTotal() (int, error)

func (Actor) GetInfoResp

func (actor Actor) GetInfoResp(ctx *fiber.Ctx) error

func (Actor) GetJanitors

func (actor Actor) GetJanitors() ([]util.Verify, error)

func (Actor) GetOutbox

func (actor Actor) GetOutbox(ctx *fiber.Ctx) error

func (Actor) GetPostTotal

func (actor Actor) GetPostTotal() (int, error)

func (Actor) GetRecentPosts

func (actor Actor) GetRecentPosts() ([]ObjectBase, error)

func (Actor) GetReported

func (actor Actor) GetReported() ([]ObjectBase, error)

func (Actor) GetReportedTotal

func (actor Actor) GetReportedTotal() (int, error)

func (Actor) GetStickies

func (actor Actor) GetStickies() (Collection, error)

func (Actor) HasValidation

func (actor Actor) HasValidation(ctx *fiber.Ctx) bool

func (Actor) IsAlreadyFollower

func (actor Actor) IsAlreadyFollower(follow string) (bool, error)

func (Actor) IsAlreadyFollowing

func (actor Actor) IsAlreadyFollowing(follow string) (bool, error)

func (Actor) IsLocal

func (actor Actor) IsLocal() (bool, error)

func (Actor) IsValid

func (actor Actor) IsValid() (Actor, bool, error)

func (Actor) MakeFollowActivity

func (actor Actor) MakeFollowActivity(follow string) (Activity, error)

func (Actor) ProcessInboxCreate

func (actor Actor) ProcessInboxCreate(activity Activity) error

func (Actor) ReportedResp

func (actor Actor) ReportedResp(ctx *fiber.Ctx) error

func (Actor) SendToFollowers

func (actor Actor) SendToFollowers(activity Activity) error

func (Actor) SetAutoSubscribe

func (actor Actor) SetAutoSubscribe() error

func (Actor) UnArchiveLast

func (actor Actor) UnArchiveLast() error

func (Actor) Verify

func (actor Actor) Verify(signature string, verify string) error

func (Actor) VerifyHeaderSignature

func (actor Actor) VerifyHeaderSignature(ctx *fiber.Ctx) bool

func (Actor) WantToServePage

func (actor Actor) WantToServePage(page int) (Collection, error)

func (Actor) WriteCache

func (actor Actor) WriteCache() error

type ActorString

type ActorString struct {
	Actor string `json:"actor,omitempty"`
}

type AtContext

type AtContext struct {
	Context string `json:"@context,omitempty"`
}

type AtContextArray

type AtContextArray struct {
	Context []interface{} `json:"@context,omitempty"`
}

type AtContextRaw

type AtContextRaw struct {
	Context json.RawMessage `json:"@context,omitempty"`
}

type AtContextString

type AtContextString struct {
	Context string `json:"@context,omitempty"`
}

type CcArray

type CcArray struct {
	Cc []string `json:"cc,omitempty"`
}

type CcOjectString

type CcOjectString struct {
	Cc string `json:"cc,omitempty"`
}

type Collection

type Collection struct {
	AtContext
	CollectionBase
}

func GetActorCollectionReq

func GetActorCollectionReq(collection string) (Collection, error)

func GetActorsFollowPostFromId

func GetActorsFollowPostFromId(actors []string, id string) (Collection, error)

type CollectionBase

type CollectionBase struct {
	Actor        Actor        `json:"actor,omitempty"`
	Summary      string       `json:"summary,omitempty"`
	Type         string       `json:"type,omitempty"`
	TotalItems   int          `json:"totalItems,omitempty"`
	TotalImgs    int          `json:"totalImgs,omitempty"`
	OrderedItems []ObjectBase `json:"orderedItems,omitempty"`
	Items        []ObjectBase `json:"items,omitempty"`
}

type CryptoCur

type CryptoCur struct {
	Type    string `json:"type,omitempty"`
	Address string `json:"address,omitempty"`
}

type NestedObjectBase

type NestedObjectBase struct {
	AtContext
	Type         string          `json:"type,omitempty"`
	Id           string          `json:"id,omitempty"`
	Name         string          `json:"name,omitempty"`
	Alias        string          `json:"alias,omitempty"`
	AttributedTo string          `json:"attributedTo,omitempty"`
	TripCode     string          `json:"tripcode,omitempty"`
	Actor        string          `json:"actor,omitempty"`
	Audience     string          `json:"audience,omitempty"`
	ContentHTML  template.HTML   `json:"contenthtml,omitempty"`
	Content      string          `json:"content,omitempty"`
	EndTime      string          `json:"endTime,omitempty"`
	Generator    string          `json:"generator,omitempty"`
	Icon         string          `json:"icon,omitempty"`
	Image        string          `json:"image,omitempty"`
	InReplyTo    []ObjectBase    `json:"inReplyTo,omitempty"`
	Location     string          `json:"location,omitempty"`
	Preview      ObjectBase      `json:"preview,omitempty"`
	Published    time.Time       `json:"published,omitempty"`
	Attachment   []ObjectBase    `json:"attachment,omitempty"`
	Replies      *CollectionBase `json:"replies,omitempty"`
	StartTime    string          `json:"startTime,omitempty"`
	Summary      string          `json:"summary,omitempty"`
	Tag          []ObjectBase    `json:"tag,omitempty"`
	Updated      time.Time       `json:"updated,omitempty"`
	Deleted      string          `json:"deleted,omitempty"`
	Url          []ObjectBase    `json:"url,omitempty"`
	Href         string          `json:"href,omitempty"`
	To           []string        `json:"to,omitempty"`
	Bto          []string        `json:"bto,omitempty"`
	Cc           []string        `json:"cc,omitempty"`
	Bcc          string          `json:"Bcc,omitempty"`
	MediaType    string          `json:"mediatype,omitempty"`
	Duration     string          `json:"duration,omitempty"`
	Size         int64           `json:"size,omitempty"`
}

func (NestedObjectBase) GetPreview

func (obj NestedObjectBase) GetPreview() (*NestedObjectBase, error)

func (NestedObjectBase) WritePreview

func (obj NestedObjectBase) WritePreview() error

func (NestedObjectBase) WritePreviewCache

func (obj NestedObjectBase) WritePreviewCache() error

type Object

type Object struct {
	Object *ObjectBase `json:"object,omitempty"`
}

type ObjectArray

type ObjectArray struct {
	Object []ObjectBase `json:"object,omitempty"`
}

type ObjectBase

type ObjectBase struct {
	Type         string            `json:"type,omitempty"`
	Id           string            `json:"id,omitempty"`
	Name         string            `json:"name,omitempty"`
	Option       []string          `json:"option,omitempty"`
	Alias        string            `json:"alias,omitempty"`
	AttributedTo string            `json:"attributedTo,omitempty"`
	TripCode     string            `json:"tripcode,omitempty"`
	Actor        string            `json:"actor,omitempty"`
	Audience     string            `json:"audience,omitempty"`
	ContentHTML  template.HTML     `json:"contenthtml,omitempty"`
	Content      string            `json:"content,omitempty"`
	EndTime      string            `json:"endTime,omitempty"`
	Generator    string            `json:"generator,omitempty"`
	Icon         string            `json:"icon,omitempty"`
	Image        string            `json:"image,omitempty"`
	InReplyTo    []ObjectBase      `json:"inReplyTo,omitempty"`
	Location     string            `json:"location,omitempty"`
	Preview      *NestedObjectBase `json:"preview,omitempty"`
	Published    time.Time         `json:"published,omitempty"`
	Updated      time.Time         `json:"updated,omitempty"`
	Object       *NestedObjectBase `json:"object,omitempty"`
	Attachment   []ObjectBase      `json:"attachment,omitempty"`
	Replies      CollectionBase    `json:"replies,omitempty"`
	StartTime    string            `json:"startTime,omitempty"`
	Summary      string            `json:"summary,omitempty"`
	Tag          []ObjectBase      `json:"tag,omitempty"`
	Wallet       []CryptoCur       `json:"wallet,omitempty"`
	Deleted      string            `json:"deleted,omitempty"`
	Url          []ObjectBase      `json:"url,omitempty"`
	Href         string            `json:"href,omitempty"`
	To           []string          `json:"to,omitempty"`
	Bto          []string          `json:"bto,omitempty"`
	Cc           []string          `json:"cc,omitempty"`
	Bcc          string            `json:"Bcc,omitempty"`
	MediaType    string            `json:"mediatype,omitempty"`
	Duration     string            `json:"duration,omitempty"`
	Size         int64             `json:"size,omitempty"`
	Sensitive    bool              `json:"sensitive,omitempty"`
	Sticky       bool              `json:"sticky,omitempty"`
	Locked       bool              `json:"locked,omitempty"`
}

func CreateAttachmentObject

func CreateAttachmentObject(file multipart.File, header *multipart.FileHeader) ([]ObjectBase, *os.File, error)

func CreateObject

func CreateObject(objType string) ObjectBase

func GetObjectFromJson

func GetObjectFromJson(obj []byte) (ObjectBase, error)

func (ObjectBase) CheckIfOP

func (obj ObjectBase) CheckIfOP() (bool, error)

func (ObjectBase) CreateActivity

func (obj ObjectBase) CreateActivity(activityType string) (Activity, error)

func (ObjectBase) CreatePreview

func (obj ObjectBase) CreatePreview() *NestedObjectBase

func (ObjectBase) Delete

func (obj ObjectBase) Delete() error

TODO break this off into seperate for Cache

func (ObjectBase) DeleteAll

func (obj ObjectBase) DeleteAll() error

func (ObjectBase) DeleteAndRepliesRequest

func (obj ObjectBase) DeleteAndRepliesRequest() error

func (ObjectBase) DeleteAttachment

func (obj ObjectBase) DeleteAttachment() error

TODO break this off into seperate for Cache

func (ObjectBase) DeleteAttachmentFromFile

func (obj ObjectBase) DeleteAttachmentFromFile() error

func (ObjectBase) DeleteInReplyTo

func (obj ObjectBase) DeleteInReplyTo() error

func (ObjectBase) DeletePreview

func (obj ObjectBase) DeletePreview() error

TODO break this off into seperate for Cache

func (ObjectBase) DeletePreviewFromFile

func (obj ObjectBase) DeletePreviewFromFile() error

func (ObjectBase) DeleteRepliedTo

func (obj ObjectBase) DeleteRepliedTo() error

func (ObjectBase) DeleteReported

func (obj ObjectBase) DeleteReported() error

func (ObjectBase) DeleteRequest

func (obj ObjectBase) DeleteRequest() error

func (ObjectBase) GetAttachment

func (obj ObjectBase) GetAttachment() ([]ObjectBase, error)

TODO does attachemnts need to be an array in the activitypub structs?

func (ObjectBase) GetCollectionFromPath

func (obj ObjectBase) GetCollectionFromPath() (Collection, error)

func (ObjectBase) GetCollectionLocal

func (obj ObjectBase) GetCollectionLocal() (Collection, error)

func (ObjectBase) GetFromPath

func (obj ObjectBase) GetFromPath() (ObjectBase, error)

func (ObjectBase) GetInReplyTo

func (obj ObjectBase) GetInReplyTo() ([]ObjectBase, error)

func (ObjectBase) GetOP

func (obj ObjectBase) GetOP() (string, error)

func (ObjectBase) GetReplies

func (obj ObjectBase) GetReplies() (CollectionBase, int, int, error)

func (ObjectBase) GetRepliesCount

func (obj ObjectBase) GetRepliesCount() (int, int, error)

func (ObjectBase) GetRepliesLimit

func (obj ObjectBase) GetRepliesLimit(limit int) (CollectionBase, int, int, error)

func (ObjectBase) GetRepliesReplies

func (obj ObjectBase) GetRepliesReplies() (CollectionBase, int, int, error)

func (ObjectBase) GetType

func (obj ObjectBase) GetType() (string, error)

func (ObjectBase) IsCached

func (obj ObjectBase) IsCached() (bool, error)

func (ObjectBase) IsLocal

func (obj ObjectBase) IsLocal() (bool, error)

func (ObjectBase) IsLocked

func (obj ObjectBase) IsLocked() (bool, error)

func (ObjectBase) IsReplyInThread

func (obj ObjectBase) IsReplyInThread(id string) (bool, error)

func (ObjectBase) IsSticky

func (obj ObjectBase) IsSticky() (bool, error)

func (ObjectBase) MarkLocked

func (obj ObjectBase) MarkLocked(actorID string) error

func (ObjectBase) MarkSensitive

func (obj ObjectBase) MarkSensitive(sensitive bool) error

TODO break this off into seperate for Cache

func (ObjectBase) MarkSticky

func (obj ObjectBase) MarkSticky(actorID string) error

func (ObjectBase) SendEmailNotify

func (obj ObjectBase) SendEmailNotify() error

func (ObjectBase) SetAttachmentRepliesType

func (obj ObjectBase) SetAttachmentRepliesType(_type string) error

func (ObjectBase) SetAttachmentType

func (obj ObjectBase) SetAttachmentType(_type string) error

func (ObjectBase) SetPreviewRepliesType

func (obj ObjectBase) SetPreviewRepliesType(_type string) error

func (ObjectBase) SetPreviewType

func (obj ObjectBase) SetPreviewType(_type string) error

func (ObjectBase) SetRepliesType

func (obj ObjectBase) SetRepliesType(_type string) error

func (ObjectBase) SetType

func (obj ObjectBase) SetType(_type string) error

func (ObjectBase) Tombstone

func (obj ObjectBase) Tombstone() error

func (ObjectBase) TombstoneAttachment

func (obj ObjectBase) TombstoneAttachment() error

func (ObjectBase) TombstoneAttachmentReplies

func (obj ObjectBase) TombstoneAttachmentReplies() error

func (ObjectBase) TombstonePreview

func (obj ObjectBase) TombstonePreview() error

func (ObjectBase) TombstonePreviewReplies

func (obj ObjectBase) TombstonePreviewReplies() error

func (ObjectBase) TombstoneReplies

func (obj ObjectBase) TombstoneReplies() error

func (ObjectBase) UpdatePreview

func (obj ObjectBase) UpdatePreview(preview string) error

func (ObjectBase) UpdateType

func (obj ObjectBase) UpdateType(_type string) error

func (ObjectBase) WantToCache

func (obj ObjectBase) WantToCache(actor Actor) (bool, error)

func (ObjectBase) Write

func (obj ObjectBase) Write() (ObjectBase, error)

func (ObjectBase) WriteAttachment

func (obj ObjectBase) WriteAttachment() error

func (ObjectBase) WriteAttachmentCache

func (obj ObjectBase) WriteAttachmentCache() error

func (ObjectBase) WriteCache

func (obj ObjectBase) WriteCache() (ObjectBase, error)

func (ObjectBase) WriteCacheWithAttachment

func (obj ObjectBase) WriteCacheWithAttachment(attachment ObjectBase) error

func (ObjectBase) WriteReply

func (obj ObjectBase) WriteReply() error

func (ObjectBase) WriteUpdate

func (obj ObjectBase) WriteUpdate(updated time.Time) error

func (ObjectBase) WriteWallet

func (obj ObjectBase) WriteWallet() error

func (ObjectBase) WriteWithAttachment

func (obj ObjectBase) WriteWithAttachment(attachment ObjectBase)

type ObjectBaseSortAsc

type ObjectBaseSortAsc []ObjectBase

func (ObjectBaseSortAsc) Len

func (a ObjectBaseSortAsc) Len() int

func (ObjectBaseSortAsc) Less

func (a ObjectBaseSortAsc) Less(i, j int) bool

func (ObjectBaseSortAsc) Swap

func (a ObjectBaseSortAsc) Swap(i, j int)

type ObjectBaseSortDesc

type ObjectBaseSortDesc []ObjectBase

func (ObjectBaseSortDesc) Len

func (a ObjectBaseSortDesc) Len() int

func (ObjectBaseSortDesc) Less

func (a ObjectBaseSortDesc) Less(i, j int) bool

func (ObjectBaseSortDesc) Swap

func (a ObjectBaseSortDesc) Swap(i, j int)

type ObjectString

type ObjectString struct {
	Object string `json:"object,omitempty"`
}

type PublicKeyPem

type PublicKeyPem struct {
	Id           string `json:"id,omitempty"`
	Owner        string `json:"owner,omitempty"`
	PublicKeyPem string `json:"publicKeyPem,omitempty"`
}

func GetActorPemFromDB

func GetActorPemFromDB(pemID string) (PublicKeyPem, error)

type Signature

type Signature struct {
	KeyId     string
	Headers   []string
	Signature string
	Algorithm string
}

func ParseHeaderSignature

func ParseHeaderSignature(signature string) Signature

type ToArray

type ToArray struct {
	To []string `json:"to,omitempty"`
}

type ToString

type ToString struct {
	To string `json:"to,omitempty"`
}

type Webfinger

type Webfinger struct {
	Subject string          `json:"subject,omitempty"`
	Links   []WebfingerLink `json:"links,omitempty"`
}
type WebfingerLink struct {
	Rel  string `json:"rel,omitempty"`
	Type string `json:"type,omitempty"`
	Href string `json:"href,omitempty"`
}

Jump to

Keyboard shortcuts

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