Skill站外收录 @skilllib/skill-2117939930272415116
activitypub-federation
掌握 ActivityPub 去中心化社交网络协议的核心机制,涵盖 Actor 身份建模、Activity 行为语义与 Object 内容表达三要素,支持跨服务端的消息分发、权限控制、可见性管理及安全验证,适用于构建或调试联邦式社交平台。
效率工具 AI 技能
Skills.MD
# ActivityPub Federation Protocol
This skill provides understanding of the ActivityPub protocol specification and how federation works.
**For supported features and compatibility:** See [FEDERATION.md](../../../FEDERATION.md) for the complete list of implemented FEPs, supported standards, and federation compatibility details.
**For implementation details:** See [PHP Conventions](../activitypub-php-conventions/SKILL.md) for transformers, handlers, and PHP code patterns.
## Core Concepts
### Three Building Blocks
1. **Actors** - Users/accounts in the system
- Each actor has a unique URI
- Required: `inbox`, `outbox`
- Optional: `followers`, `following`, `liked`
2. **Activities** - Actions taken by actors
- Create, Update, Delete, Follow, Like, Announce, Undo
- Wrap objects to describe how they're shared
3. **Objects** - Content being acted upon
- Notes, Articles, Images, Videos, etc.
- Can be embedded or referenced by URI
### Actor Structure
```json
{
"@context": "https://www.w3.org/ns/activitystreams",
"type": "Person",
"id": "https://example.com/@alice",
"inbox": "https://example.com/@alice/inbox",
"outbox": "https://example.com/@alice/outbox",
"followers": "https://example.com/@alice/followers",
"following": "https://example.com/@alice/following",
"preferredUsername": "alice",
"name": "Alice Example",
"summary": "Bio text here"
}
```
## Collections
### Standard Collections
**Inbox** - Receives incoming activities
- De-duplicate by activity ID
- Filter based on permissions
- Process activities for side effects
**Outbox** - Publishes actor's activities
- Public record of what actor has posted
- Filtered based on viewer permissions
- Used for profile activity displays
**Followers** - Actors following this actor
- Updated when Follow activities are Accepted
- Used for delivery targeting
**Following** - Actors this actor follows
- Tracks subscriptions
- Used for timeline building
### Public Addressing
Special collection: `https://www.w3.org/ns/activitystreams#Public`
- Makes content publicly accessible
- **Do not deliver to this URI** - it's a marker, not a real inbox
- Used in `to`, `cc`, `bto`, `bcc` fields for visibility
## Activity Types
### Create
Wraps newly published content:
```json
{
"type": "Create",
"actor": "https://example.com/@alice",
"object": {
"type": "Note",
"content": "Hello, Fediverse!"
}
}
```
### Follow
Initiates subscription:
```json
{
"type": "Follow",
"actor": "https://example.com/@alice",
"object": "https://other.example/@bob"
}
```
- Recipient should respond with Accept or Reject
- Only add to followers upon Accept
### Like
Indicates appreciation:
```json
{
"type": "Like",
"actor": "https://example.com/@alice",
"object": "https://other.example/@bob/post/123"
}
```
### Announce
Reshares/boosts content:
```json
{
"type": "Announce",
"actor": "https://example.com/@alice",
"object": "https://other.example/@bob/post/123"
}
```
### Update
Modifies existing content:
- Supplied properties replace existing
- `null` values remove fields
- Must include original object ID
### Delete
Removes content:
- May replace with Tombstone for referential integrity
- Should cascade to related activities
### Undo
Reverses previous activities:
```json
{
"type": "Undo",
"actor": "https://example.com/@alice",
"object": {
"type": "Follow",
"id": "https://example.com/@alice/follow/123"
}
}
```
## Server-to-Server Federation
### Activity Delivery Process
1. **Resolve Recipients**
- Check `to`, `bto`, `cc`, `bcc`, `audience` fields
- Dereference collections to find individual actors
- De-duplicate recipient list
- Exclude activity's own actor
2. **Discover Inboxes**
- Fetch actor profiles
- Extract `inbox` property
- Use `sharedInbox` if available for efficiency
3. **Deliver via HTTP POST**
- Content-Type: `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
- Include HTTP Signatures for authentication
- Handle delivery failures gracefully
### Inbox Forwarding
**Ghost Replies Problem:** When Alice replies to Bob's post that Carol follows, Carol might not see the reply if she doesn't follow Alice.
**Solution:** Inbox forwarding
- When receiving activity addressing a local collection
- If activity references local objects
- Forward to collection members
- Ensures conversation participants see replies
### Shared Inbox Optimization
For public posts with many recipients on same server:
- Use `sharedInbox` endpoint instead of individual inboxes
- Reduces number of HTTP requests
- Server distributes internally
## Addressing and Visibility
### To/CC Fields
- `to` - Primary recipients (public in UI)
- `cc` - Secondary recipients (copied/mentioned)
- `bto` - Blind primary (hidden in delivery)
- `bcc` - Blind secondary (hidden in delivery)
**Important:** Remove `bto` and `bcc` before delivery to preserve privacy
### Visibility Patterns
**Public Post:**
```json
{
"to": ["https://www.w3.org/ns/activitystreams#Public"],
"cc": ["https://example.com/@alice/followers"]
}
```
**Followers-Only:**
```json
{
"to": ["https://example.com/@alice/followers"]
}
```
**Direct Message:**
```json
{
"to": ["https://other.example/@bob"],
"cc": []
}
```
## Content Verification
### Security Considerations
1. **Verify Origins**
- Don't trust claimed sources without verification
- Check HTTP Signatures
- Validate actor owns referenced objects
2. **Prevent Spoofing**
- Mallory could claim Alice posted something
- Always verify before processing side effects
3. **Rate Limiting**
- Limit recursive dereferencing
- Protect against denial-of-service
- Implement spam filtering
4. **Content Sanitization**
- Clean HTML before browser rendering
- Validate media types
- Check for malicious payloads
## Protocol Extensions
### Supported Standards
See [FEDERATION.md](../../../FEDERATION.md) for the complete list of implemented standards and FEPs, including:
- WebFinger - Actor discovery.
- HTTP Signatures - Request authentication.
- NodeInfo - Server metadata.
- Various FEPs (Fediverse Enhancement Proposals).
### FEPs (Fediverse Enhancement Proposals)
FEPs extend ActivityPub with additional features. Common FEP categories include:
- Long-form text support.
- Quote posts.
- Activity intents.
- Follower synchronization.
- Actor metadata extensions.
**For supported FEPs in this plugin:** See [FEDERATION.md](../../../FEDERATION.md) for the authoritative list of implemented FEPs.
## Implementation Notes
### WordPress Plugin Specifics
This plugin implements:
- **Actor Types**: User, Blog, Application
- **Transformers**: Convert WordPress content to ActivityPub objects
- **Handlers**: Process incoming activities
For implementation details, see:
- [PHP Conventions](../activitypub-php-conventions/SKILL.md) for code structure
- [Integration Guide](../activitypub-integrations/SKILL.md) for extending
### Testing Federation
```bash
# Test actor endpoint
curl -H "Accept: application/activity+json" \
https://site.com/@username
# Test WebFinger
curl https://site.com/.well-known/webfinger?resource=acct:user@site.com
# Test NodeInfo
curl https://site.com/.well-known/nodeinfo
```
## Common Issues
### Activities Not Received
- Check inbox URL is accessible
- Verify HTTP signature validation
- Ensure content-type headers correct
- Check for firewall/security blocks
### Replies Not Federated
- Verify inbox forwarding enabled
- Check addressing includes relevant actors
- Ensure `inReplyTo` properly set
### Follower Sync Issues
- Check Accept activities sent for Follow
- Verify followers collection updates
- Ensure shared inbox used when available
## Resources
- [ActivityPub Spec](https://www.w3.org/TR/activitypub/)
- [ActivityStreams Vocabulary](https://www.w3.org/TR/activitystreams-vocabulary/)
- [Project FEDERATION.md](../../../FEDERATION.md)
- [FEPs Repository](https://codeberg.org/fediverse/fep)
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「activitypub-federation」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次