apmodels

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddImageAttachmentToNote

func AddImageAttachmentToNote(note vocab.ActivityStreamsNote, image, mediaType string)

AddImageAttachmentToNote will add the provided image URL to the provided note object.

func CreateCreateActivity

func CreateCreateActivity(id string, localAccountIRI *url.URL) vocab.ActivityStreamsCreate

CreateCreateActivity will create a new Create Activity model with the provided ID and IRI.

func GetFullUsernameFromExternalEntity

func GetFullUsernameFromExternalEntity(entity ExternalEntity) string

GetFullUsernameFromExternalEntity will return the full username from an internal representation of an ExternalEntity. Returns user@host.tld.

func GetLogoType added in v0.1.1

func GetLogoType() string

GetLogoType will return the rel value for the webfinger response and the default static image is of type png.

func MakeActivityDirect added in v0.0.12

func MakeActivityDirect(activity vocab.ActivityStreamsCreate, toIRI *url.URL) vocab.ActivityStreamsCreate

MakeActivityDirect sets the required properties to make this activity seen as a direct message.

func MakeActivityPublic added in v0.0.12

func MakeActivityPublic(activity vocab.ActivityStreamsCreate) vocab.ActivityStreamsCreate

MakeActivityPublic sets the required properties to make this activity seen as public.

func MakeActorPropertyWithID

func MakeActorPropertyWithID(idIRI *url.URL) vocab.ActivityStreamsActorProperty

MakeActorPropertyWithID will return an actor property filled with the provided IRI.

func MakeCreateActivity

func MakeCreateActivity(activityID *url.URL) vocab.ActivityStreamsCreate

MakeCreateActivity will return a new Create activity with the provided ID.

func MakeHashtag

func MakeHashtag(name string) vocab.TootHashtag

MakeHashtag will create and return a mastodon toot hashtag object with the provided name.

func MakeLocalIRIForAccount

func MakeLocalIRIForAccount(account string) *url.URL

MakeLocalIRIForAccount will return a full IRI for the local server account username.

func MakeLocalIRIForResource

func MakeLocalIRIForResource(resourcePath string) *url.URL

MakeLocalIRIForResource will create an IRI for the local server.

func MakeLocalIRIForStreamURL added in v0.1.1

func MakeLocalIRIForStreamURL() *url.URL

MakeLocalIRIForStreamURL will return a full IRI for the local server stream url.

func MakeLocalIRIforLogo() *url.URL

MakeLocalIRIforLogo will return a full IRI for the local server logo.

func MakeNote

func MakeNote(text string, noteIRI *url.URL, attributedToIRI *url.URL) vocab.ActivityStreamsNote

MakeNote will return a new Note object.

func MakeNoteDirect added in v0.0.12

func MakeNoteDirect(note vocab.ActivityStreamsNote, toIRI *url.URL) vocab.ActivityStreamsNote

MakeNoteDirect sets the required properties to make this note seen as a direct message.

func MakeNotePublic added in v0.0.12

MakeNotePublic ses the required proeprties to make this note seen as public.

func MakeRemoteIRIForResource

func MakeRemoteIRIForResource(resourcePath string, host string) (*url.URL, error)

MakeRemoteIRIForResource will create an IRI for a remote location.

func MakeServiceForAccount

func MakeServiceForAccount(accountName string) vocab.ActivityStreamsService

MakeServiceForAccount will create a new local actor service with the the provided username.

func MakeUpdateActivity

func MakeUpdateActivity(activityID *url.URL) vocab.ActivityStreamsUpdate

MakeUpdateActivity will return a new Update activity with the provided aID.

func Serialize

func Serialize(obj vocab.Type) ([]byte, error)

Serialize will serialize an ActivityPub object to a byte slice.

Types

type ActivityPubActor

type ActivityPubActor struct {
	// RequestObject is the actual follow request object.
	RequestObject vocab.ActivityStreamsFollow
	// W3IDSecurityV1PublicKey is the public key of the actor.
	W3IDSecurityV1PublicKey vocab.W3IDSecurityV1PublicKeyProperty
	// ActorIRI is the IRI of the remote actor.
	ActorIri *url.URL
	// FollowRequestIRI is the unique identifier of the follow request.
	FollowRequestIri *url.URL
	// Inbox is the inbox URL of the remote follower
	Inbox *url.URL
	// Image is the avatar image of the Actor.
	Image *url.URL
	// DisabledAt is the time, if any, this follower was blocked/removed.
	DisabledAt *time.Time
	// Name is the display name of the follower.
	Name string
	// Username is the account username of the remote actor.
	Username string
	// FullUsername is the username@account.tld representation of the user.
	FullUsername string
}

ActivityPubActor represents a single actor in handling ActivityPub activity.

func MakeActorFromExernalAPEntity

func MakeActorFromExernalAPEntity(entity ExternalEntity) (*ActivityPubActor, error)

MakeActorFromExernalAPEntity takes a full ActivityPub entity and returns our internal representation of an actor.

type DeleteRequest

type DeleteRequest struct {
	ActorIri string
}

DeleteRequest represents a request for delete.

type ExternalEntity

type ExternalEntity interface {
	GetJSONLDId() vocab.JSONLDIdProperty
	GetActivityStreamsInbox() vocab.ActivityStreamsInboxProperty
	GetActivityStreamsName() vocab.ActivityStreamsNameProperty
	GetActivityStreamsPreferredUsername() vocab.ActivityStreamsPreferredUsernameProperty
	GetActivityStreamsIcon() vocab.ActivityStreamsIconProperty
	GetW3IDSecurityV1PublicKey() vocab.W3IDSecurityV1PublicKeyProperty
}

ExternalEntity represents an ActivityPub Person, Service or Application.

type InboxRequest

type InboxRequest struct {
	Request         *http.Request
	ForLocalAccount string
	Body            []byte
}

InboxRequest represents an inbound request to the ActivityPub inbox.

type Link struct {
	Rel  string `json:"rel"`
	Type string `json:"type"`
	Href string `json:"href"`
}

Link represents a Webfinger response Link entity.

type PrivacyAudience

type PrivacyAudience = string

PrivacyAudience represents the audience for an activity.

const (
	// PUBLIC is an audience meaning anybody can view the item.
	PUBLIC PrivacyAudience = "https://www.w3.org/ns/activitystreams#Public"
)

type WebfingerProfileRequestResponse added in v0.0.12

type WebfingerProfileRequestResponse struct {
	Self string
}

WebfingerProfileRequestResponse represents a Webfinger profile request response.

func MakeWebFingerRequestResponseFromData added in v0.0.12

func MakeWebFingerRequestResponseFromData(data []map[string]interface{}) WebfingerProfileRequestResponse

MakeWebFingerRequestResponseFromData converts WebFinger data to an easier to use model.

type WebfingerResponse

type WebfingerResponse struct {
	Aliases []string `json:"aliases"`
	Subject string   `json:"subject"`
	Links   []Link   `json:"links"`
}

WebfingerResponse represents a Webfinger response.

func MakeWebfingerResponse

func MakeWebfingerResponse(account string, inbox string, host string) WebfingerResponse

MakeWebfingerResponse will create a new Webfinger response.

Jump to

Keyboard shortcuts

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