Documentation ¶
Index ¶
- Variables
- func C2SAutoCreateActivity(ctx context.Context, src ld.Source, actor, stream *models.Entity, ...) error
- func C2SGenerateIDs(ctx context.Context, src ld.Source, actor, stream *models.Entity, ...) error
- func C2SRequiredActivityProperties(ctx context.Context, src ld.Source, actor, stream *models.Entity, ...) (err error)
- func Copy(from, to ld.Entity, prop *meta.Prop)
- func IsSameOrigin(a, b string) bool
- func RequireActivity(ctx context.Context, src ld.Source, actor, stream *models.Entity, ...) (err error)
- func Run(ctx context.Context, rules []Rule, src ld.Source, actor, stream *models.Entity, ...) error
- func Slugify(input string) (string, error)
- func ValidateQuacksLike(e ld.Entity, t *meta.Type) error
- type Rule
Constants ¶
This section is empty.
Variables ¶
var Rules = []Rule{ C2SAutoCreateActivity, C2SRequiredActivityProperties, C2SGenerateIDs, RequireActivity, }
Functions ¶
func C2SAutoCreateActivity ¶
func C2SAutoCreateActivity(ctx context.Context, src ld.Source, actor, stream *models.Entity, activity *as.Activity) error
This rule ensures that the processed activity is indeed an activity, and wraps it as the as:Object in an as:Create event if it's not.
NOTE: This rule is ran before C2SGenerateIDs, do not depend on things having IDs.
ActivityPub §6: Client To Server Interactions
The body of the POST request MUST contain a single Activity (which MAY contain embedded objects), or a single non-Activity object which will be wrapped in a Create activity by the server.
ActivityPub §6.2.1: Object creation without a Create Activity
For client to server posting, it is possible to submit an object for creation without a surrounding activity. The server MUST accept a valid [ActivityStreams] object that isn't a subtype of Activity in the POST request to the outbox. The server then MUST attach this object as the object of a Create Activity. ... Any to, bto, cc, bcc, and audience properties specified on the object MUST be copied over to the new Create activity by the server.
func C2SGenerateIDs ¶
func C2SGenerateIDs(ctx context.Context, src ld.Source, actor, stream *models.Entity, activity *as.Activity) error
This rule generates local IDs for client-to-server submissions.
ActivityPub §6: Client To Server Interactions
If an Activity is submitted with a value in the id property, servers MUST ignore this and generate a new id for the Activity.
ActivityPub §6.2.1: Object creation without a Create activity
For non-transient objects, the server MUST attach an id to both the wrapping Create and its wrapped Object.
^ I'm choosing to interpret this as having been placed in the wrong section of the spec
(§6.2.1 rather than §6.2: Create Activity), because it makes no sense for it only to apply to objects created without Create activities.
func C2SRequiredActivityProperties ¶
func C2SRequiredActivityProperties(ctx context.Context, src ld.Source, actor, stream *models.Entity, activity *as.Activity) (err error)
Ensure that activities have required attributes for their type as dictated by the spec.
TODO: Should this be enforced for federated activities as well as client-submitted ones?
NOTE: This rule is ran before C2SGenerateIDs, do not depend on things having IDs.
ActivityPub §6.1 Client Addressing:
Clients submitting the following activities to an outbox MUST provide the object property in the activity: Create, Update, Delete, Follow, Add, Remove, Like, Block, Undo. Additionally, clients submitting the following activities to an outbox MUST also provide the target property: Add, Remove.
func IsSameOrigin ¶
Returns whether two IDs are from the same origin.