Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1a74f2b3e9
|
|||
|
97a5e951e1
|
|||
|
9071ac44fe
|
|||
|
6abee8d8bd
|
|||
|
8cf03683dc
|
|||
|
f34d80b7d4
|
|||
|
b6d7e52148
|
|||
|
978b7b32fd
|
|||
|
35a9c9ff4b
|
|||
|
e5cb296367
|
|||
|
cf3a2b6340
|
|||
|
f568baf14d
|
|||
|
703335429a
|
|||
|
188b6821a2
|
|||
|
0ebbe0bd5a
|
|||
|
46a826ff86
|
|||
|
1d99ac6441
|
|||
|
e2efdc4064
|
|||
|
cba1a3884b
|
|||
|
7147ce1efa
|
|||
|
78c1a284a5
|
|||
|
f1f5113b01
|
|||
|
a44552f105
|
|||
|
8c1ad94555
|
|||
|
84f5677260
|
|||
|
aa1ffdbf10
|
|||
|
c24d13461b
|
|||
|
3b60fcb87c
|
|||
|
3605b997b1
|
|||
|
800815c721
|
|||
|
3b13a63e7b
|
|||
|
81d69ce10f
|
@@ -17,6 +17,7 @@
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
||||
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
|
||||
|
||||
<application
|
||||
android:label="Solian"
|
||||
|
||||
@@ -5,8 +5,9 @@ import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import io.flutter.plugins.sharedpreferences.LegacySharedPreferencesPlugin
|
||||
import io.flutter.embedding.android.FlutterFragmentActivity
|
||||
|
||||
class MainActivity : FlutterActivity()
|
||||
class MainActivity : FlutterFragmentActivity()
|
||||
{
|
||||
private val CHANNEL = "dev.solsynth.solian/notifications"
|
||||
|
||||
|
||||
@@ -358,7 +358,7 @@
|
||||
"accountSettingsHelp": "Account Settings Help",
|
||||
"accountSettingsHelpContent": "This page allows you to manage your account security, privacy, and other settings. If you need assistance, please contact support.",
|
||||
"unauthorized": "Unauthorized",
|
||||
"unauthorizedHint": "You're not signed in or session expired, please sign in again.",
|
||||
"unauthorizedHint": "You're not signed in or session expired, please sign in and try again.",
|
||||
"publisherBelongsTo": "Belongs to {}",
|
||||
"postContent": "Content",
|
||||
"postSettings": "Settings",
|
||||
@@ -924,6 +924,7 @@
|
||||
"fileHash": "File Hash",
|
||||
"exifData": "EXIF Data",
|
||||
"postShuffle": "Shuffle Posts",
|
||||
"swipeToExplore": "Swipe to explore",
|
||||
"leveling": "Leveling",
|
||||
"levelingHistory": "Leveling History",
|
||||
"stellarProgram": "Stellar Program",
|
||||
@@ -1581,5 +1582,7 @@
|
||||
"followingEmptyHint": "Start by searching for users or explore other instances",
|
||||
"fediversePost": "Fediverse Post",
|
||||
"fediversePostDescribe": "Post from the Fediverse Network",
|
||||
"settingsShowFediverseContent": "Show Fediverse Content"
|
||||
"settingsShowFediverseContent": "Show Fediverse Content",
|
||||
"universalSearch": "Universal Search",
|
||||
"universalSearchDescription": "Search content across the Solar Network and the fediverse network."
|
||||
}
|
||||
@@ -455,6 +455,7 @@
|
||||
"checkInResultT2": "中平",
|
||||
"checkInResultT3": "吉",
|
||||
"checkInResultT4": "大吉",
|
||||
"checkInResultT5": "特殊",
|
||||
"accountProfileView": "查看个人资料",
|
||||
"unspecified": "未指定",
|
||||
"added": "已添加",
|
||||
|
||||
@@ -455,6 +455,7 @@
|
||||
"checkInResultT2": "Mid",
|
||||
"checkInResultT3": "Good",
|
||||
"checkInResultT4": "Best",
|
||||
"checkInResultT5": "Special",
|
||||
"accountProfileView": "View Profile",
|
||||
"unspecified": "Unspecified",
|
||||
"added": "Added",
|
||||
|
||||
@@ -455,6 +455,7 @@
|
||||
"checkInResultT2": "中平",
|
||||
"checkInResultT3": "吉",
|
||||
"checkInResultT4": "大吉",
|
||||
"checkInResultT5": "特殊",
|
||||
"accountProfileView": "查看個人資料",
|
||||
"unspecified": "未指定",
|
||||
"added": "已添加",
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
# ActivityPub Implementation for Solar Network
|
||||
|
||||
## Overview
|
||||
|
||||
This document outlines the initial implementation of ActivityPub federation for the Solar Network (DysonNetwork), following the plan outlined in `ACTIVITYPUB_PLAN.md`.
|
||||
|
||||
## What Has Been Created
|
||||
|
||||
### 1. Database Models (DysonNetwork.Shared/Models)
|
||||
|
||||
All ActivityPub-related models are shared across projects and located in `DysonNetwork.Shared/Models/`:
|
||||
|
||||
#### FediverseInstance.cs
|
||||
- Tracks ActivityPub instances (servers) in the fediverse
|
||||
- Stores instance metadata, blocking status, and activity tracking
|
||||
- Links to actors and content from that instance
|
||||
|
||||
#### FediverseActor.cs
|
||||
- Represents remote actors (users/accounts) from other instances
|
||||
- Stores actor information including keys, inbox/outbox URLs
|
||||
- Links to instance and manages relationships
|
||||
- Tracks whether the actor is a bot, locked, or discoverable
|
||||
|
||||
#### FediverseContent.cs
|
||||
- Stores content (posts, notes, etc.) received from the fediverse
|
||||
- Supports multiple content types (Note, Article, Image, Video, etc.)
|
||||
- Includes attachments, mentions, tags, and emojis
|
||||
- Links to local posts for unified display
|
||||
|
||||
#### FediverseActivity.cs
|
||||
- Tracks ActivityPub activities (Create, Follow, Like, Announce, etc.)
|
||||
- Stores raw activity data and processing status
|
||||
- Links to actors, content, and local entities
|
||||
- Supports both incoming and outgoing activities
|
||||
|
||||
#### FediverseRelationship.cs
|
||||
- Manages follow relationships between local and remote actors
|
||||
- Tracks relationship state (Pending, Accepted, Rejected)
|
||||
- Supports muting and blocking
|
||||
- Links to local accounts/publishers
|
||||
|
||||
#### FediverseReaction.cs
|
||||
- Stores reactions (likes, emoji) from both local and remote actors
|
||||
- Links to content and actor
|
||||
- Supports federation of reactions
|
||||
|
||||
### 2. Database Migration
|
||||
|
||||
**File**: `DysonNetwork.Sphere/Migrations/20251228120000_AddActivityPubModels.cs`
|
||||
|
||||
This migration creates the following tables:
|
||||
- `fediverse_instances` - Instance tracking
|
||||
- `fediverse_actors` - Remote actor profiles
|
||||
- `fediverse_contents` - Federated content storage
|
||||
- `fediverse_activities` - Activity tracking and processing
|
||||
- `fediverse_relationships` - Follow relationships
|
||||
- `fediverse_reactions` - Reactions from fediverse
|
||||
|
||||
### 3. API Controllers (DysonNetwork.Sphere/ActivityPub)
|
||||
|
||||
#### WebFingerController.cs
|
||||
- **Endpoint**: `GET /.well-known/webfinger?resource=acct:<username>@<domain>`
|
||||
- **Purpose**: Allows other instances to discover actors via WebFinger protocol
|
||||
- **Response**: Returns actor's inbox/outbox URLs and profile page links
|
||||
- Maps local Publishers to ActivityPub actors
|
||||
|
||||
#### ActivityPubController.cs
|
||||
Provides three main endpoints:
|
||||
|
||||
1. **GET /activitypub/actors/{username}**
|
||||
- Returns ActivityPub actor profile in JSON-LD format
|
||||
- Includes actor's keys, inbox, outbox, followers, and following URLs
|
||||
- Maps SnPublisher to ActivityPub Person type
|
||||
|
||||
2. **GET /activitypub/actors/{username}/outbox**
|
||||
- Returns actor's outbox collection
|
||||
- Lists public posts as ActivityPub activities
|
||||
- Supports pagination
|
||||
|
||||
3. **POST /activitypub/actors/{username}/inbox**
|
||||
- Receives incoming ActivityPub activities
|
||||
- Supports Create, Follow, Like, Announce activities
|
||||
- Placeholder for activity processing logic
|
||||
|
||||
## Architecture
|
||||
|
||||
### Data Flow
|
||||
|
||||
```
|
||||
Remote Instance Solar Network (Sphere)
|
||||
│ │
|
||||
│ ───WebFinger─────> │
|
||||
│ │
|
||||
│ <───Actor JSON──── │
|
||||
│ │
|
||||
│ ───Activity─────> │ → Inbox Processing
|
||||
│ │
|
||||
│ <───Activity────── │ ← Outbox Distribution
|
||||
```
|
||||
|
||||
### Model Relationships
|
||||
|
||||
- `SnFediverseInstance` has many `SnFediverseActor`
|
||||
- `SnFediverseInstance` has many `SnFediverseContent`
|
||||
- `SnFediverseActor` has many `SnFediverseContent`
|
||||
- `SnFediverseActor` has many `SnFediverseActivity`
|
||||
- `SnFediverseActor` has many `SnFediverseRelationship` (as follower and following)
|
||||
- `SnFediverseContent` has many `SnFediverseActivity`
|
||||
- `SnFediverseContent` has many `SnFediverseReaction`
|
||||
- `SnFediverseContent` optionally links to `SnPost` (local copy)
|
||||
|
||||
### Local to Fediverse Mapping
|
||||
|
||||
| Solar Network Model | ActivityPub Type |
|
||||
|-------------------|-----------------|
|
||||
| SnPublisher | Person (Actor) |
|
||||
| SnPost | Note / Article |
|
||||
| SnPostReaction | Like / EmojiReact |
|
||||
| Follow | Follow Activity |
|
||||
| SnPublisherSubscription | Follow Relationship |
|
||||
|
||||
## Next Steps
|
||||
|
||||
### Stage 1: Core Infrastructure ✅ (COMPLETED)
|
||||
- ✅ Create database models for ActivityPub entities
|
||||
- ✅ Create database migration
|
||||
- ✅ Implement basic WebFinger endpoint
|
||||
- ✅ Implement basic Actor endpoint
|
||||
- ✅ Implement Inbox/Outbox endpoints
|
||||
|
||||
### Stage 2: Activity Processing ✅ (COMPLETED)
|
||||
- ✅ Implement HTTP Signature verification (ActivityPubSignatureService)
|
||||
- ✅ Process incoming activities:
|
||||
- Follow/Accept/Reject
|
||||
- Create (incoming posts)
|
||||
- Like/Announce
|
||||
- Delete/Update
|
||||
- Undo
|
||||
- ✅ Generate outgoing activities (ActivityPubDeliveryService)
|
||||
- ✅ Queue and retry failed deliveries (basic implementation)
|
||||
|
||||
### Stage 3: Key Management ✅ (COMPLETED)
|
||||
- ✅ Generate RSA key pairs for each Publisher (ActivityPubKeyService)
|
||||
- ✅ Store public/private keys in Publisher.Meta
|
||||
- ✅ Sign outgoing HTTP requests
|
||||
- ✅ Verify incoming HTTP signatures
|
||||
|
||||
### Stage 4: Content Federation (IN PROGRESS)
|
||||
- ✅ Convert between SnPost and ActivityPub Note/Article (basic mapping)
|
||||
- ✅ Handle content attachments and media
|
||||
- ✅ Support content warnings and sensitive content
|
||||
- ✅ Handle replies, boosts, and mentions
|
||||
- ⏳ Add local post reference for federated content
|
||||
- ⏳ Handle media attachments in federated content
|
||||
|
||||
### Stage 5: Relationship Management ✅ (COMPLETED)
|
||||
- ✅ Handle follow/unfollow logic
|
||||
- ✅ Update followers/following collections
|
||||
- ✅ Block/mute functionality (data model ready)
|
||||
- ✅ Relationship state machine (Pending, Accepted, Rejected)
|
||||
|
||||
### Stage 6: Testing & Interop (NEXT)
|
||||
- ⏳ Test with Mastodon instances
|
||||
- ⏳ Test with Pleroma/Akkoma instances
|
||||
- ⏳ Test with Lemmy instances
|
||||
- ⏳ Verify WebFinger and actor discovery
|
||||
- ⏳ Test activity delivery and processing
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Core Services
|
||||
|
||||
#### 1. ActivityPubKeyService
|
||||
- Generates RSA 2048-bit key pairs for ActivityPub
|
||||
- Signs data with private key
|
||||
- Verifies signatures with public key
|
||||
- Key stored in `SnPublisher.Meta["private_key"]` and `["public_key"]`
|
||||
|
||||
#### 2. ActivityPubSignatureService
|
||||
- Verifies incoming HTTP Signature headers
|
||||
- Signs outgoing HTTP requests
|
||||
- Manages key retrieval and storage
|
||||
- Builds signing strings according to ActivityPub spec
|
||||
|
||||
#### 3. ActivityPubActivityProcessor
|
||||
- Processes all incoming activity types
|
||||
- Follow: Creates relationship, sends Accept
|
||||
- Accept: Updates relationship to accepted state
|
||||
- Reject: Updates relationship to rejected state
|
||||
- Create: Stores federated content
|
||||
- Like: Records like reaction
|
||||
- Announce: Increments boost count
|
||||
- Undo: Reverts previous actions
|
||||
- Delete: Soft-deletes federated content
|
||||
- Update: Marks content as edited
|
||||
|
||||
#### 4. ActivityPubDeliveryService
|
||||
- Sends Follow activities to remote instances
|
||||
- Sends Accept activities in response to follows
|
||||
- Sends Create activities (posts) to followers
|
||||
- Sends Like activities to remote instances
|
||||
- Sends Undo activities
|
||||
- Fetches remote actor profiles on-demand
|
||||
|
||||
### Data Flow
|
||||
|
||||
#### Incoming Activity Flow
|
||||
```
|
||||
Remote Server → HTTP Signature Verification → Activity Type → Specific Handler
|
||||
↓
|
||||
Database Update & Response
|
||||
```
|
||||
|
||||
#### Outgoing Activity Flow
|
||||
```
|
||||
Local Action → Create Activity → Sign with Key → Send to Followers' Inboxes
|
||||
↓
|
||||
Track Status & Retry
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Add to `appsettings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"ActivityPub": {
|
||||
"Domain": "your-domain.com",
|
||||
"EnableFederation": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Database Migration
|
||||
|
||||
To apply the migration:
|
||||
|
||||
```bash
|
||||
cd DysonNetwork.Sphere
|
||||
dotnet ef database update
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
### WebFinger
|
||||
```bash
|
||||
curl "https://your-domain.com/.well-known/webfinger?resource=acct:username@your-domain.com"
|
||||
```
|
||||
|
||||
### Actor Profile
|
||||
```bash
|
||||
curl -H "Accept: application/activity+json" https://your-domain.com/activitypub/actors/username
|
||||
```
|
||||
|
||||
### Outbox
|
||||
```bash
|
||||
curl -H "Accept: application/activity+json" https://your-domain.com/activitypub/actors/username/outbox
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- All models follow the existing Solar Network patterns (ModelBase, NodaTime, JSON columns)
|
||||
- Controllers use standard ASP.NET Core patterns with dependency injection
|
||||
- Database uses PostgreSQL with JSONB for flexible metadata storage
|
||||
- Migration follows existing naming conventions
|
||||
- Soft delete is enabled on all models
|
||||
|
||||
## References
|
||||
|
||||
- [ActivityPub W3C Recommendation](https://www.w3.org/TR/activitypub/)
|
||||
- [ActivityStreams 2.0](https://www.w3.org/TR/activitystreams-core/)
|
||||
- [WebFinger RFC 7033](https://tools.ietf.org/html/rfc7033)
|
||||
- [Mastodon Federation Documentation](https://docs.joinmastodon.org/spec/activitypub/)
|
||||
|
||||
## TODOs
|
||||
|
||||
- [ ] Implement HTTP Signature verification middleware
|
||||
- [ ] Create activity processor service
|
||||
- [ ] Implement activity queue and retry logic
|
||||
- [ ] Add key generation for Publishers
|
||||
- [ ] Implement content conversion between formats
|
||||
- [ ] Add inbox background worker
|
||||
- [ ] Add outbox delivery worker
|
||||
- [ ] Implement relationship management logic
|
||||
- [ ] Add moderation tools for federated content
|
||||
- [ ] Add federation metrics and monitoring
|
||||
- [ ] Write comprehensive tests
|
||||
@@ -1,197 +0,0 @@
|
||||
🛠️ ActivityPub 接入 Solar Network 的分步清单
|
||||
|
||||
⸻
|
||||
|
||||
🧱 1. 准备 & 设计阶段
|
||||
|
||||
1.1 理解 ActivityPub 的核心概念
|
||||
• Actor / Object / Activity / Collection
|
||||
• Outbox / Inbox / Followers 列表
|
||||
ActivityPub 是使用 JSON-LD + ActivityStreams 2.0 来描述社交行为的规范。 
|
||||
|
||||
1.2 映射你现有的 Solar Domain 结构
|
||||
|
||||
把你现在 Solar Network 的用户、帖子、关注、点赞等:
|
||||
• 映射为 ActivityPub 的 Actor / Note / Follow / Like 等
|
||||
• 明确本地模型与 ActivityStreams 对应关系
|
||||
|
||||
比如:
|
||||
• Solar User → ActivityPub Actor
|
||||
• Post → ActivityPub Note/Object
|
||||
• Like → ActivityPub Like Activity
|
||||
这一步是关键的领域建模设计。
|
||||
|
||||
⸻
|
||||
|
||||
🚪 2. Actor 发现与必要入口
|
||||
|
||||
2.1 实现 WebFinger
|
||||
|
||||
为每个用户提供 WebFinger endpoint:
|
||||
|
||||
GET /.well-known/webfinger?resource=acct:<username>@<domain>
|
||||
|
||||
用来让远端服务器查出 actor 细节(包括 inbox/outbox URL)。
|
||||
|
||||
2.2 Actor 资源 URL
|
||||
|
||||
确保每个用户有一个全局可访问的 URL,例如:
|
||||
|
||||
https://solar.io/users/alice
|
||||
|
||||
并在其 JSON-LD 中包含:
|
||||
• inbox
|
||||
• outbox
|
||||
• followers
|
||||
• following
|
||||
这些是 ActivityPub 基础通信的入口。 
|
||||
|
||||
⸻
|
||||
|
||||
📮 3. 核心协议实现
|
||||
|
||||
3.1 Inbox / Outbox 接口
|
||||
|
||||
Inbox(接收来自其他实例的 Activity)
|
||||
Outbox(本地用户发布 Activity 的出口)
|
||||
|
||||
Outbox 需要:
|
||||
• 生成 activity JSON(Create、Follow、Like 等)
|
||||
• 存储至本地数据库
|
||||
• 推送到各 follower 的 Inbox
|
||||
|
||||
Inbox 需要:
|
||||
• 接收并 parse Activity
|
||||
• 验证签名
|
||||
• 处理活动(如接受 Follow,记录远程 Post 等)
|
||||
|
||||
注意:
|
||||
• 请求需要验证 HTTP Signatures(远端服务器签名)。 
|
||||
• 必须满足 ActivityPub 规范对字段的要求。
|
||||
|
||||
⸻
|
||||
|
||||
🔐 4. 安全与签名
|
||||
|
||||
4.1 Actor Keys
|
||||
|
||||
每个 Actor 对应一对 RSA / Ed25519 密钥:
|
||||
• 私钥用于签名发送到其它服务器的请求
|
||||
• 公钥发布在 Actor JSON 中供对方验证
|
||||
|
||||
远端服务器发送到你的 Inbox 时,需要:
|
||||
• 使用对方的公钥验证签名
|
||||
|
||||
HTTP Signatures 是服务器间通信安全的一部分,防止伪造请求。 
|
||||
|
||||
⸻
|
||||
|
||||
🌐 5. 实现联邦逻辑
|
||||
|
||||
5.1 关注逻辑
|
||||
|
||||
处理:
|
||||
• Follow Activity
|
||||
• Accept / Reject Activity
|
||||
• 更新本地 followers / following 数据
|
||||
|
||||
实现流程参考:1. 本地用户发起 Follow 2. 推送 Follow 到远端 Inbox 3. 等待远端发送 Accept 或 Reject
|
||||
|
||||
5.2 推送 content(联邦同步)
|
||||
|
||||
当本地用户发布内容时:
|
||||
• 从 Outbox 取出 Create Activity
|
||||
• 发送到所有远端 followers 的 Inbox
|
||||
注意:你可以缓存远端 followers 数据表来减少重复请求。
|
||||
|
||||
⸻
|
||||
|
||||
📡 6. 消息处理与存储
|
||||
|
||||
6.1 本地对象缓存
|
||||
|
||||
对于接收到的远端内容(Post / Note / Like 等):
|
||||
• 需要保存到 Solar 的数据库
|
||||
• 供 UI / API 生成用户时间线
|
||||
这使得 Solar 能把远端联邦内容与本地内容统一展示。
|
||||
|
||||
6.2 处理 Collections
|
||||
|
||||
ActivityPub 定义了 Collection 类型用于:
|
||||
• followers 列表
|
||||
• liked 列表
|
||||
• outbox、inbox
|
||||
|
||||
你需要实现这些集合的获取与分页逻辑。
|
||||
|
||||
⸻
|
||||
|
||||
🔁 7. 与现有 Solar Network API 协调
|
||||
|
||||
你可能已经有本地的帖子、用户 API。那么:
|
||||
• 把这套 API 与 ActivityPub 同步层绑定
|
||||
• 决定哪些内容对外发布
|
||||
• 决定哪些 Activity 类型需要响应
|
||||
|
||||
比如:
|
||||
|
||||
Solar Post Create -> 生成 ActivityPub Create Note -> 发往联邦
|
||||
|
||||
⸻
|
||||
|
||||
📦 8. 测试与兼容性
|
||||
|
||||
8.1 与现存联邦测试
|
||||
|
||||
用已存在的 ActivityPub 实例测试兼容性:
|
||||
• Mastodon
|
||||
• Pleroma
|
||||
• Lemmy 等
|
||||
|
||||
检查:
|
||||
• 对方是否能关注 Solar 用户
|
||||
• Solar 是否能接收远端内容
|
||||
|
||||
ActivityPub 规范(W3C Recommendation)有详细规范流包括:
|
||||
• Server to Server API
|
||||
你最重要的目标是与现存实例互操作。 
|
||||
|
||||
⸻
|
||||
|
||||
🧪 9. UX & 监控支持
|
||||
|
||||
9.1 用户显示远端内容
|
||||
|
||||
从 Inbox 收到内容后:
|
||||
• 如何展示在 Solar UI
|
||||
• 链接远端用户的展示名 / 头像
|
||||
|
||||
9.2 监控 & 审计
|
||||
• 失败的推送
|
||||
• 无法验证签名的请求
|
||||
• 阻止 spam / 恶意 Activity
|
||||
|
||||
⸻
|
||||
|
||||
🏁 10. 逐步推进
|
||||
|
||||
建议按阶段 rollout:
|
||||
|
||||
阶段 目标
|
||||
Stage 1 实现 Actor / WebFinger / Outbox / Inbox 基本框架
|
||||
Stage 2 支持 Follow / Accept / Reject Activity
|
||||
Stage 3 支持 Create / Like / Announce
|
||||
Stage 4 与远端实例互联测试
|
||||
Stage 5 UI & Feed 统一显示本地 + 联邦内容
|
||||
|
||||
⸻
|
||||
|
||||
📌 小结
|
||||
|
||||
核心步骤总结:1. 映射 Solar Network 数据模型到 ActivityPub 2. 实现 WebFinger + Actor JSON-LD 3. 实现 Inbox 和 Outbox endpoints 4. 管理 Actor Keys 与 HTTP Signatures 5. 处理关注/发帖/点赞等 Activity 6. 推送到远端 / 接收远端同步 7. 将远端内容存入 Solar 并展示 8. 测试与现有 Fediverse 实例互通
|
||||
|
||||
这套步骤覆盖了 ActivityPub 协议必须实现的点和实际联邦要处理的逻辑。 
|
||||
|
||||
⸻
|
||||
|
||||
如果你想,我可以进一步展开 Solar Network 对应的具体 API 设计模板(包括 Inbox / Outbox 的 REST 定义与 JSON 输出示例),甚至帮你写 可运行的 Go / .NET 样例代码。你希望从哪一部分开始深入?
|
||||
@@ -1,273 +0,0 @@
|
||||
# ActivityPub Implementation Summary
|
||||
|
||||
## What Has Been Implemented
|
||||
|
||||
### 1. Database Models ✅
|
||||
All models located in `DysonNetwork.Shared/Models/`:
|
||||
|
||||
| Model | Purpose | Key Features |
|
||||
|--------|---------|--------------|
|
||||
| `SnFediverseInstance` | Track fediverse servers | Domain blocking, metadata, activity tracking |
|
||||
| `SnFediverseActor` | Remote user profiles | Keys, inbox/outbox URLs, relationships |
|
||||
| `SnFediverseContent` | Federated posts/notes | Multiple content types, attachments, mentions, tags |
|
||||
| `SnFediverseActivity` | Activity tracking | All activity types, processing status, raw data |
|
||||
| `SnFediverseRelationship` | Follow relationships | State machine, muting/blocking |
|
||||
| `SnFediverseReaction` | Federated reactions | Likes, emoji reactions |
|
||||
|
||||
### 2. Database Migrations ✅
|
||||
- `20251228120000_AddActivityPubModels.cs` - Core ActivityPub tables
|
||||
- `20251228130000_AddPublisherMetaForActivityPubKeys.cs` - Publisher metadata for keys
|
||||
|
||||
### 3. Core Services ✅
|
||||
|
||||
#### ActivityPubKeyService
|
||||
- **Location**: `DysonNetwork.Sphere/ActivityPub/ActivityPubKeyService.cs`
|
||||
- **Responsibilities**:
|
||||
- Generate RSA 2048-bit key pairs
|
||||
- Sign data with private key
|
||||
- Verify signatures with public key
|
||||
- **Key Storage**: Keys stored in `SnPublisher.Meta`
|
||||
|
||||
#### ActivityPubSignatureService
|
||||
- **Location**: `DysonNetwork.Sphere/ActivityPub/ActivityPubSignatureService.cs`
|
||||
- **Responsibilities**:
|
||||
- Verify incoming HTTP Signature headers
|
||||
- Sign outgoing HTTP requests
|
||||
- Build signing strings per ActivityPub spec
|
||||
- Manage key retrieval for actors
|
||||
- **Signature Algorithm**: RSA-SHA256
|
||||
|
||||
#### ActivityPubActivityProcessor
|
||||
- **Location**: `DysonNetwork.Sphere/ActivityPub/ActivityPubActivityProcessor.cs`
|
||||
- **Supported Activities**:
|
||||
- ✅ Follow - Creates relationship, sends Accept
|
||||
- ✅ Accept - Updates relationship to accepted
|
||||
- ✅ Reject - Updates relationship to rejected
|
||||
- ✅ Create - Stores federated content
|
||||
- ✅ Like - Records like reaction
|
||||
- ✅ Announce - Increments boost count
|
||||
- ✅ Undo - Reverts previous actions
|
||||
- ✅ Delete - Soft-deletes federated content
|
||||
- ✅ Update - Marks content as edited
|
||||
|
||||
#### ActivityPubDeliveryService
|
||||
- **Location**: `DysonNetwork.Sphere/ActivityPub/ActivityPubDeliveryService.cs`
|
||||
- **Outgoing Activities**:
|
||||
- ✅ Follow - Send to remote actors
|
||||
- ✅ Accept - Respond to follow requests
|
||||
- ✅ Create - Send new posts to followers
|
||||
- ✅ Like - Send to remote instances
|
||||
- ✅ Undo - Undo previous actions
|
||||
- **Features**:
|
||||
- HTTP signature signing
|
||||
- Remote actor fetching
|
||||
- Follower discovery
|
||||
|
||||
### 4. API Controllers ✅
|
||||
|
||||
#### WebFingerController
|
||||
- **Location**: `DysonNetwork.Sphere/ActivityPub/WebFingerController.cs`
|
||||
- **Endpoints**:
|
||||
- `GET /.well-known/webfinger?resource=acct:<username>@<domain>`
|
||||
- **Purpose**: Allow remote instances to discover local actors
|
||||
|
||||
#### ActivityPubController
|
||||
- **Location**: `DysonNetwork.Sphere/ActivityPub/ActivityPubController.cs`
|
||||
- **Endpoints**:
|
||||
- `GET /activitypub/actors/{username}` - Actor profile in JSON-LD
|
||||
- `GET /activitypub/actors/{username}/outbox` - Public posts
|
||||
- `POST /activitypub/actors/{username}/inbox` - Receive activities
|
||||
- **Features**:
|
||||
- Public key in actor profile
|
||||
- ActivityPub JSON-LD responses
|
||||
- HTTP signature verification on inbox
|
||||
- Activity processing pipeline
|
||||
|
||||
### 5. Model Updates ✅
|
||||
- Added `Meta` field to `SnPublisher` for storing ActivityPub keys
|
||||
- All models follow existing Solar Network patterns
|
||||
|
||||
## How It Works
|
||||
|
||||
### Incoming Activity Flow
|
||||
```
|
||||
1. Remote server sends POST to /inbox
|
||||
2. HTTP Signature is verified
|
||||
3. Activity type is identified
|
||||
4. Specific handler processes activity:
|
||||
- Follow: Create relationship, send Accept
|
||||
- Create: Store content
|
||||
- Like: Record reaction
|
||||
- etc.
|
||||
5. Database is updated
|
||||
6. Response sent
|
||||
```
|
||||
|
||||
### Outgoing Activity Flow
|
||||
```
|
||||
1. Local action occurs (post, like, follow)
|
||||
2. Activity is created in ActivityPub format
|
||||
3. Remote followers are discovered
|
||||
4. HTTP request is signed with publisher's private key
|
||||
5. Activity sent to each follower's inbox
|
||||
6. Status logged
|
||||
```
|
||||
|
||||
### Key Management
|
||||
```
|
||||
1. Publisher creates post/follows
|
||||
2. Check if keys exist in Publisher.Meta
|
||||
3. If not, generate RSA 2048-bit key pair
|
||||
4. Store keys in Publisher.Meta
|
||||
5. Use keys for signing
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Add to `appsettings.json`:
|
||||
```json
|
||||
{
|
||||
"ActivityPub": {
|
||||
"Domain": "your-domain.com",
|
||||
"EnableFederation": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## API Endpoints
|
||||
|
||||
### WebFinger
|
||||
```bash
|
||||
GET /.well-known/webfinger?resource=acct:username@domain.com
|
||||
Accept: application/jrd+json
|
||||
```
|
||||
|
||||
### Actor Profile
|
||||
```bash
|
||||
GET /activitypub/actors/username
|
||||
Accept: application/activity+json
|
||||
```
|
||||
|
||||
### Outbox
|
||||
```bash
|
||||
GET /activitypub/actors/username/outbox
|
||||
Accept: application/activity+json
|
||||
```
|
||||
|
||||
### Inbox
|
||||
```bash
|
||||
POST /activitypub/actors/username/inbox
|
||||
Content-Type: application/activity+json
|
||||
Signature: keyId="...",algorithm="...",headers="...",signature="..."
|
||||
```
|
||||
|
||||
## Database Schema
|
||||
|
||||
### Fediverse Tables
|
||||
- `fediverse_instances` - Server metadata and blocking
|
||||
- `fediverse_actors` - Remote actor profiles
|
||||
- `fediverse_contents` - Federated posts/notes
|
||||
- `fediverse_activities` - Activity tracking
|
||||
- `fediverse_relationships` - Follow relationships
|
||||
- `fediverse_reactions` - Federated reactions
|
||||
|
||||
### Publisher Enhancement
|
||||
- Added `publishers.meta` JSONB column for key storage
|
||||
|
||||
## Next Steps
|
||||
|
||||
### Immediate (Ready for Testing)
|
||||
- Apply database migrations
|
||||
- Test WebFinger with a Mastodon instance
|
||||
- Test follow/unfollow with another instance
|
||||
- Test receiving posts from federated timeline
|
||||
|
||||
### Short Term
|
||||
- Add HTTP Signature verification middleware
|
||||
- Implement activity queue with retry logic
|
||||
- Add background worker for processing queued activities
|
||||
- Add metrics and monitoring
|
||||
- Implement local content display in timelines
|
||||
|
||||
### Long Term
|
||||
- Add Media support for federated content
|
||||
- Implement content filtering
|
||||
- Add moderation tools for federated content
|
||||
- Support more activity types
|
||||
- Implement instance block list management
|
||||
|
||||
## Compatibility
|
||||
|
||||
The implementation follows:
|
||||
- ✅ [ActivityPub W3C Recommendation](https://www.w3.org/TR/activitypub/)
|
||||
- ✅ [ActivityStreams 2.0](https://www.w3.org/TR/activitystreams-core/)
|
||||
- ✅ [WebFinger RFC 7033](https://tools.ietf.org/html/rfc7033)
|
||||
- ✅ [HTTP Signatures](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures)
|
||||
|
||||
## Testing
|
||||
|
||||
### Local Testing
|
||||
```bash
|
||||
# 1. Apply migrations
|
||||
cd DysonNetwork.Sphere
|
||||
dotnet ef database update
|
||||
|
||||
# 2. Test WebFinger
|
||||
curl "http://localhost:5000/.well-known/webfinger?resource=acct:username@localhost"
|
||||
|
||||
# 3. Test Actor
|
||||
curl -H "Accept: application/activity+json" http://localhost:5000/activitypub/actors/username
|
||||
```
|
||||
|
||||
### Federation Testing
|
||||
1. Set up a Mastodon instance (or use a public one)
|
||||
2. Follow a Mastodon user from Solar Network
|
||||
3. Create a post on Solar Network
|
||||
4. Verify it appears on Mastodon timeline
|
||||
|
||||
## Architecture Decisions
|
||||
|
||||
1. **Key Storage**: Using `SnPublisher.Meta` JSONB field for flexibility
|
||||
2. **Content Storage**: Federated content stored separately from local posts
|
||||
3. **Relationship State**: Implemented with explicit states (Pending, Accepted, Rejected)
|
||||
4. **Signature Algorithm**: RSA-SHA256 for compatibility
|
||||
5. **Activity Processing**: Synchronous for now, can be made async with queue
|
||||
6. **Content Types**: Support for Note, Article initially (can expand)
|
||||
|
||||
## Notes
|
||||
|
||||
- All ActivityPub communication uses HTTP Signatures
|
||||
- Private keys never leave the server
|
||||
- Public keys are published in actor profiles
|
||||
- Soft delete is enabled on all federated models
|
||||
- Failed activity deliveries are logged but not retried (future enhancement)
|
||||
- Content is federated only when visibility is Public
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
### New Files
|
||||
- `DysonNetwork.Shared/Models/FediverseInstance.cs`
|
||||
- `DysonNetwork.Shared/Models/FediverseActor.cs`
|
||||
- `DysonNetwork.Shared/Models/FediverseContent.cs`
|
||||
- `DysonNetwork.Shared/Models/FediverseActivity.cs`
|
||||
- `DysonNetwork.Shared/Models/FediverseRelationship.cs`
|
||||
- `DysonNetwork.Shared/Models/FediverseReaction.cs`
|
||||
- `DysonNetwork.Sphere/ActivityPub/WebFingerController.cs`
|
||||
- `DysonNetwork.Sphere/ActivityPub/ActivityPubController.cs`
|
||||
- `DysonNetwork.Sphere/ActivityPub/ActivityPubKeyService.cs`
|
||||
- `DysonNetwork.Sphere/ActivityPub/ActivityPubSignatureService.cs`
|
||||
- `DysonNetwork.Sphere/ActivityPub/ActivityPubActivityProcessor.cs`
|
||||
- `DysonNetwork.Sphere/ActivityPub/ActivityPubDeliveryService.cs`
|
||||
- `DysonNetwork.Sphere/Migrations/20251228120000_AddActivityPubModels.cs`
|
||||
- `DysonNetwork.Sphere/Migrations/20251228130000_AddPublisherMetaForActivityPubKeys.cs`
|
||||
|
||||
### Modified Files
|
||||
- `DysonNetwork.Shared/Models/Publisher.cs` - Added Meta field
|
||||
- `DysonNetwork.Sphere/AppDatabase.cs` - Added DbSets for ActivityPub
|
||||
- `DysonNetwork.Sphere/Startup/ServiceCollectionExtensions.cs` - Registered ActivityPub services
|
||||
|
||||
## References
|
||||
|
||||
- [ActivityPub Implementation Guide](./ACTIVITYPUB_IMPLEMENTATION.md)
|
||||
- [ActivityPub Plan](./ACTIVITYPUB_PLAN.md)
|
||||
- [Solar Network Architecture](./README.md)
|
||||
@@ -1,820 +0,0 @@
|
||||
# ActivityPub Testing Guide for Solar Network
|
||||
|
||||
This guide will help you test the ActivityPub implementation in Solar Network, starting with a self-hosted instance and then moving to a real instance.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- ✅ Solar Network codebase with ActivityPub implementation
|
||||
- ✅ Docker installed (for running Mastodon/Fediverse instances)
|
||||
- ✅ PostgreSQL database running
|
||||
- ✅ `.NET 10` SDK
|
||||
|
||||
## Part 1: Set Up a Self-Hosted Test Instance
|
||||
|
||||
### Option A: Using Mastodon (Recommended for Compatibility)
|
||||
|
||||
#### 1. Create a Docker Compose File
|
||||
|
||||
Create `docker-compose.mastodon-test.yml`:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
db:
|
||||
restart: always
|
||||
image: postgres:14-alpine
|
||||
environment:
|
||||
POSTGRES_USER: mastodon
|
||||
POSTGRES_PASSWORD: mastodon_password
|
||||
POSTGRES_DB: mastodon
|
||||
networks:
|
||||
- mastodon_network
|
||||
healthcheck:
|
||||
test: ["CMD", "pg_isready", "-U", "mastodon"]
|
||||
interval: 5s
|
||||
retries: 5
|
||||
|
||||
redis:
|
||||
restart: always
|
||||
image: redis:7-alpine
|
||||
networks:
|
||||
- mastodon_network
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
retries: 5
|
||||
|
||||
es:
|
||||
restart: always
|
||||
image: docker.elastic.co/elasticsearch:8.10.2
|
||||
environment:
|
||||
- "discovery.type=single-node"
|
||||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
|
||||
- "xpack.security.enabled=false"
|
||||
networks:
|
||||
- mastodon_network
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "curl -silent http://localhost:9200/_cluster/health || exit 1"]
|
||||
interval: 10s
|
||||
retries: 10
|
||||
|
||||
web:
|
||||
restart: always
|
||||
image: tootsuite/mastodon:latest
|
||||
env_file: .env.mastodon
|
||||
command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"
|
||||
ports:
|
||||
- "3001:3000"
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
- es
|
||||
networks:
|
||||
- mastodon_network
|
||||
volumes:
|
||||
- ./mastodon-data/public:/mastodon/public/system
|
||||
|
||||
streaming:
|
||||
restart: always
|
||||
image: tootsuite/mastodon:latest
|
||||
env_file: .env.mastodon
|
||||
command: node ./streaming
|
||||
ports:
|
||||
- "4000:4000"
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
networks:
|
||||
- mastodon_network
|
||||
|
||||
sidekiq:
|
||||
restart: always
|
||||
image: tootsuite/mastodon:latest
|
||||
env_file: .env.mastodon
|
||||
command: bundle exec sidekiq
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
networks:
|
||||
- mastodon_network
|
||||
|
||||
networks:
|
||||
mastodon_network:
|
||||
driver: bridge
|
||||
```
|
||||
|
||||
#### 2. Create Environment File
|
||||
|
||||
Create `.env.mastodon`:
|
||||
|
||||
```bash
|
||||
# Federation
|
||||
LOCAL_DOMAIN=mastodon.local
|
||||
LOCAL_HTTPS=false
|
||||
|
||||
# Database
|
||||
DB_HOST=db
|
||||
DB_PORT=5432
|
||||
DB_USER=mastodon
|
||||
DB_NAME=mastodon
|
||||
DB_PASS=mastodon_password
|
||||
|
||||
# Redis
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
|
||||
# Elasticsearch
|
||||
ES_ENABLED=true
|
||||
ES_HOST=es
|
||||
ES_PORT=9200
|
||||
|
||||
# Secrets (generate these!)
|
||||
SECRET_KEY_BASE=change_me_to_a_random_string_at_least_32_chars
|
||||
OTP_SECRET=change_me_to_another_random_string
|
||||
|
||||
# Defaults
|
||||
SINGLE_USER_MODE=false
|
||||
DEFAULT_LOCALE=en
|
||||
```
|
||||
|
||||
**Generate secrets:**
|
||||
```bash
|
||||
# Run these to generate random secrets
|
||||
openssl rand -base64 32
|
||||
```
|
||||
|
||||
#### 3. Start Mastodon
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.mastodon-test.yml up -d
|
||||
|
||||
# Check logs
|
||||
docker-compose -f docker-compose.mastodon-test.yml logs -f web
|
||||
```
|
||||
|
||||
Wait for the web service to be healthy (may take 2-5 minutes).
|
||||
|
||||
#### 4. Create a Mastodon Account
|
||||
|
||||
```bash
|
||||
# Run this command to create an admin account
|
||||
docker-compose -f docker-compose.mastodon-test.yml exec web \
|
||||
bin/tootctl accounts create \
|
||||
testuser \
|
||||
testuser@mastodon.local \
|
||||
--email=test@example.com \
|
||||
--confirmed \
|
||||
--role=admin \
|
||||
--approve
|
||||
```
|
||||
|
||||
Set password: `TestPassword123!`
|
||||
|
||||
#### 5. Update Your /etc/hosts
|
||||
|
||||
```bash
|
||||
sudo nano /etc/hosts
|
||||
```
|
||||
|
||||
Add:
|
||||
```
|
||||
127.0.0.1 mastodon.local
|
||||
127.0.0.1 solar.local
|
||||
```
|
||||
|
||||
### Option B: Using GoToSocial (Lightweight Alternative)
|
||||
|
||||
Create `docker-compose.gotosocial.yml`:
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
gotosocial:
|
||||
image: superseriousbusiness/gotosocial:latest
|
||||
environment:
|
||||
- GTS_HOST=gotosocial.local
|
||||
- GTS_ACCOUNT_DOMAIN=gotosocial.local
|
||||
- GTS_PROTOCOL=http
|
||||
- GTS_DB_TYPE=sqlite
|
||||
- GTS_DB_ADDRESS=/gotosocial/data/sqlite.db
|
||||
- GTS_STORAGE_LOCAL_BASE_PATH=/gotosocial/data/storage
|
||||
ports:
|
||||
- "3002:8080"
|
||||
volumes:
|
||||
- ./gotosocial-data:/gotosocial/data
|
||||
|
||||
networks:
|
||||
default:
|
||||
```
|
||||
|
||||
Start it:
|
||||
```bash
|
||||
docker-compose -f docker-compose.gotosocial.yml up -d
|
||||
```
|
||||
|
||||
Create account:
|
||||
```bash
|
||||
docker-compose -f docker-compose.gotosocial.yml exec gotosocial \
|
||||
/gotosocial/gotosocial admin account create \
|
||||
--username testuser \
|
||||
--email test@example.com \
|
||||
--password TestPassword123!
|
||||
```
|
||||
|
||||
## Part 2: Configure Solar Network for Federation
|
||||
|
||||
### 1. Update appsettings.json
|
||||
|
||||
Edit `DysonNetwork.Sphere/appsettings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"ActivityPub": {
|
||||
"Domain": "solar.local",
|
||||
"EnableFederation": true
|
||||
},
|
||||
"Kestrel": {
|
||||
"Endpoints": {
|
||||
"Http": {
|
||||
"Url": "http://solar.local:5000"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Update /etc/hosts
|
||||
|
||||
Add both instances:
|
||||
```
|
||||
127.0.0.1 mastodon.local
|
||||
127.0.0.1 solar.local
|
||||
127.0.0.1 gotosocial.local
|
||||
```
|
||||
|
||||
### 3. Apply Database Migrations
|
||||
|
||||
```bash
|
||||
cd DysonNetwork.Sphere
|
||||
dotnet ef database update
|
||||
```
|
||||
|
||||
### 4. Start Solar Network
|
||||
|
||||
```bash
|
||||
dotnet run --project DysonNetwork.Sphere
|
||||
```
|
||||
|
||||
Solar Network should now be running on `http://solar.local:5000`
|
||||
|
||||
## Part 3: Create Test Users
|
||||
|
||||
### In Solar Network
|
||||
|
||||
1. Open http://solar.local:5000 (or your web interface)
|
||||
2. Create a new account/publisher named `solaruser`
|
||||
3. Note down the publisher ID for later
|
||||
|
||||
**Or via API** (if you have an existing account):
|
||||
|
||||
```bash
|
||||
# First, create a publisher in Solar Network
|
||||
curl -X POST http://solar.local:5000/api/publishers \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{
|
||||
"name": "solaruser",
|
||||
"nick": "Solar User",
|
||||
"bio": "Testing ActivityPub federation!",
|
||||
"type": 0
|
||||
}'
|
||||
```
|
||||
|
||||
### In Mastodon
|
||||
|
||||
Open http://mastodon.local:3001 and log in with:
|
||||
- Username: `testuser`
|
||||
- Password: `TestPassword123!`
|
||||
|
||||
## Part 4: Test Federation Scenarios
|
||||
|
||||
### Test 1: WebFinger Discovery
|
||||
|
||||
**Goal**: Verify Solar Network is discoverable
|
||||
|
||||
```bash
|
||||
# Query Solar Network's WebFinger endpoint
|
||||
curl -v "http://solar.local:5000/.well-known/webfinger?resource=acct:solaruser@solar.local"
|
||||
|
||||
# Expected response (200 OK):
|
||||
{
|
||||
"subject": "acct:solaruser@solar.local",
|
||||
"links": [
|
||||
{
|
||||
"rel": "self",
|
||||
"type": "application/activity+json",
|
||||
"href": "https://solar.local:5000/activitypub/actors/solaruser"
|
||||
},
|
||||
{
|
||||
"rel": "http://webfinger.net/rel/profile-page",
|
||||
"type": "text/html",
|
||||
"href": "https://solar.local:5000/users/solaruser"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Test 2: Fetch Actor Profile
|
||||
|
||||
**Goal**: Get ActivityPub actor JSON
|
||||
|
||||
```bash
|
||||
# Fetch Solar Network actor from Mastodon
|
||||
curl -H "Accept: application/activity+json" \
|
||||
http://solar.local:5000/activitypub/actors/solaruser
|
||||
|
||||
# Expected response includes:
|
||||
{
|
||||
"@context": ["https://www.w3.org/ns/activitystreams"],
|
||||
"id": "https://solar.local:5000/activitypub/actors/solaruser",
|
||||
"type": "Person",
|
||||
"preferredUsername": "solaruser",
|
||||
"inbox": "https://solar.local:5000/activitypub/actors/solaruser/inbox",
|
||||
"outbox": "https://solar.local:5000/activitypub/actors/solaruser/outbox",
|
||||
"followers": "https://solar.local:5000/activitypub/actors/solaruser/followers",
|
||||
"publicKey": {
|
||||
"id": "https://solar.local:5000/activitypub/actors/solaruser#main-key",
|
||||
"owner": "https://solar.local:5000/activitypub/actors/solaruser",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\n..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Test 3: Follow from Mastodon to Solar Network
|
||||
|
||||
**Goal**: Mastodon user follows Solar Network user
|
||||
|
||||
1. **In Mastodon**:
|
||||
- Go to http://mastodon.local:3001
|
||||
- In search bar, type: `@solaruser@solar.local`
|
||||
- Click the follow button
|
||||
|
||||
2. **Verify in Solar Network**:
|
||||
```bash
|
||||
# Check database for relationship
|
||||
psql -d dyson_network -c \
|
||||
"SELECT * FROM fediverse_relationships WHERE is_local_actor = true;"
|
||||
```
|
||||
|
||||
3. **Check Solar Network logs**:
|
||||
Should see:
|
||||
```
|
||||
Processing activity type: Follow from actor: ...
|
||||
Processed follow from ... to ...
|
||||
```
|
||||
|
||||
4. **Verify Mastodon receives Accept**:
|
||||
- Check Mastodon logs for Accept activity
|
||||
- Verify follow appears as accepted in Mastodon
|
||||
|
||||
### Test 4: Follow from Solar Network to Mastodon
|
||||
|
||||
**Goal**: Solar Network user follows Mastodon user
|
||||
|
||||
You'll need to call the ActivityPub delivery service:
|
||||
|
||||
```bash
|
||||
# Via API (you'll need to implement this endpoint):
|
||||
curl -X POST http://solar.local:5000/api/activitypub/follow \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{
|
||||
"targetActorUri": "http://mastodon.local:3001/users/testuser"
|
||||
}'
|
||||
```
|
||||
|
||||
**Or test directly with curl** (simulating a Follow activity):
|
||||
|
||||
```bash
|
||||
# Create a Follow activity
|
||||
curl -X POST http://solar.local:5000/activitypub/actors/solaruser/inbox \
|
||||
-H "Content-Type: application/activity+json" \
|
||||
-d '{
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"id": "http://mastodon.local:3001/test-follow-activity",
|
||||
"type": "Follow",
|
||||
"actor": "http://mastodon.local:3001/users/testuser",
|
||||
"object": "https://solar.local:5000/activitypub/actors/solaruser"
|
||||
}'
|
||||
```
|
||||
|
||||
### Test 5: Create a Post in Solar Network
|
||||
|
||||
**Goal**: Post federates to Mastodon
|
||||
|
||||
1. **Create a post via Solar Network API**:
|
||||
```bash
|
||||
curl -X POST http://solar.local:5000/api/posts \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{
|
||||
"content": "Hello fediverse! Testing ActivityPub from Solar Network! 🚀",
|
||||
"visibility": 0,
|
||||
"publisherId": "PUBLISHER_ID"
|
||||
}'
|
||||
```
|
||||
|
||||
2. **Wait a few seconds**
|
||||
|
||||
3. **Check in Mastodon**:
|
||||
- Go to http://mastodon.local:3001
|
||||
- The post should appear in the federated timeline
|
||||
- It should show `@solaruser@solar.local` as the author
|
||||
|
||||
4. **Verify Solar Network logs**:
|
||||
```
|
||||
Successfully sent activity to http://mastodon.local:3001/inbox
|
||||
```
|
||||
|
||||
### Test 6: Like from Mastodon
|
||||
|
||||
**Goal**: Mastodon user likes a Solar Network post
|
||||
|
||||
1. **In Mastodon**:
|
||||
- Find the Solar Network post
|
||||
- Click the favorite/like button
|
||||
|
||||
2. **Verify in Solar Network**:
|
||||
```bash
|
||||
psql -d dyson_network -c \
|
||||
"SELECT * FROM fediverse_reactions;"
|
||||
```
|
||||
|
||||
3. **Check Solar Network logs**:
|
||||
```
|
||||
Processing activity type: Like from actor: ...
|
||||
Processed like from ...
|
||||
```
|
||||
|
||||
### Test 7: Reply from Mastodon
|
||||
|
||||
**Goal**: Reply federates to Solar Network
|
||||
|
||||
1. **In Mastodon**:
|
||||
- Reply to the Solar Network post
|
||||
- Write: "@solaruser Nice to meet you!"
|
||||
|
||||
2. **Verify in Solar Network**:
|
||||
```bash
|
||||
psql -d dyson_network -c \
|
||||
"SELECT * FROM fediverse_contents WHERE in_reply_to IS NOT NULL;"
|
||||
```
|
||||
|
||||
## Part 5: Debugging and Troubleshooting
|
||||
|
||||
### Enable Detailed Logging
|
||||
|
||||
Edit `appsettings.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"DysonNetwork.Sphere.ActivityPub": "Trace"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Check Database State
|
||||
|
||||
```bash
|
||||
# Check actors
|
||||
psql -d dyson_network -c \
|
||||
"SELECT uri, username, display_name FROM fediverse_actors;"
|
||||
|
||||
# Check contents
|
||||
psql -d dyson_network -c \
|
||||
"SELECT uri, type, content FROM fediverse_contents;"
|
||||
|
||||
# Check relationships
|
||||
psql -d dyson_network -c \
|
||||
"SELECT * FROM fediverse_relationships;"
|
||||
|
||||
# Check activities
|
||||
psql -d dyson_network -c \
|
||||
"SELECT type, status, error_message FROM fediverse_activities;"
|
||||
|
||||
# Check failed activities
|
||||
psql -d dyson_network -c \
|
||||
"SELECT * FROM fediverse_activities WHERE status = 3;" # 3 = Failed
|
||||
```
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### Issue: "Failed to verify signature"
|
||||
|
||||
**Cause**: HTTP Signature verification failed
|
||||
|
||||
**Solutions**:
|
||||
1. Check the signature header format
|
||||
2. Verify public key matches actor's keyId
|
||||
3. Ensure Date header is within 5 minutes
|
||||
4. Check host header matches request URL
|
||||
|
||||
#### Issue: "Target actor or inbox not found"
|
||||
|
||||
**Cause**: Remote actor not fetched yet
|
||||
|
||||
**Solutions**:
|
||||
1. Manually fetch the actor first
|
||||
2. Check actor URL is correct
|
||||
3. Verify remote instance is accessible
|
||||
|
||||
#### Issue: "Content already exists"
|
||||
|
||||
**Cause**: Duplicate activity received
|
||||
|
||||
**Solutions**:
|
||||
1. This is normal - deduplication is working
|
||||
2. Check if content appears correctly
|
||||
|
||||
#### Issue: CORS errors when testing from browser
|
||||
|
||||
**Cause**: Browser blocking cross-origin requests
|
||||
|
||||
**Solutions**:
|
||||
1. Use curl for API testing
|
||||
2. Or disable CORS in development
|
||||
3. Test directly from Mastodon interface
|
||||
|
||||
### View HTTP Signatures
|
||||
|
||||
For debugging, you can inspect the signature:
|
||||
|
||||
```bash
|
||||
# From Mastodon to Solar Network
|
||||
curl -v -X POST http://solar.local:5000/activitypub/actors/solaruser/inbox \
|
||||
-H "Content-Type: application/activity+json" \
|
||||
-d '{"type":"Follow",...}'
|
||||
```
|
||||
|
||||
Look for the `Signature` header in the output.
|
||||
|
||||
### Test HTTP Signature Verification Manually
|
||||
|
||||
Create a test script `test-signature.js`:
|
||||
|
||||
```javascript
|
||||
const crypto = require('crypto');
|
||||
|
||||
// Test signature verification
|
||||
const publicKey = `-----BEGIN PUBLIC KEY-----
|
||||
...
|
||||
-----END PUBLIC KEY-----`;
|
||||
|
||||
const signingString = `(request-target): post /activitypub/actors/solaruser/inbox
|
||||
host: solar.local:5000
|
||||
date: ${new Date().toUTCString()}
|
||||
content-length: ...`;
|
||||
|
||||
const signature = '...';
|
||||
|
||||
const verify = crypto.createVerify('SHA256');
|
||||
verify.update(signingString);
|
||||
const isValid = verify.verify(publicKey, signature, 'base64');
|
||||
|
||||
console.log('Signature valid:', isValid);
|
||||
```
|
||||
|
||||
## Part 6: Test with a Real Instance
|
||||
|
||||
### Preparing for Public Federation
|
||||
|
||||
1. **Get a real domain** (e.g., via ngrok or a VPS)
|
||||
|
||||
```bash
|
||||
# Using ngrok for testing
|
||||
ngrok http 5000
|
||||
|
||||
# This gives you: https://random-id.ngrok-free.app
|
||||
```
|
||||
|
||||
2. **Update Solar Network config**:
|
||||
|
||||
```json
|
||||
{
|
||||
"ActivityPub": {
|
||||
"Domain": "your-domain.com",
|
||||
"EnableFederation": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
3. **Update DNS** (if using real domain):
|
||||
- Add A record pointing to your server
|
||||
- Configure HTTPS (required for production federation)
|
||||
|
||||
4. **Test WebFinger with your domain**:
|
||||
|
||||
```bash
|
||||
curl "https://your-domain.com/.well-known/webfinger?resource=acct:username@your-domain.com"
|
||||
```
|
||||
|
||||
### Test with Mastodon.social
|
||||
|
||||
1. **Create a Mastodon.social account**
|
||||
- Go to https://mastodon.social
|
||||
- Sign up for a test account
|
||||
|
||||
2. **Search for your Solar Network user**:
|
||||
- In Mastodon.social search: `@username@your-domain.com`
|
||||
- Click follow
|
||||
|
||||
3. **Create a post in Solar Network**
|
||||
- Should appear in Mastodon.social
|
||||
|
||||
4. **Reply from Mastodon.social**
|
||||
- Should appear in Solar Network
|
||||
|
||||
### Test with Other Instances
|
||||
|
||||
- **Pleroma**: Similar to Mastodon, good for testing
|
||||
- **Lemmy**: For testing community features (later)
|
||||
- **Pixelfed**: For testing media posts
|
||||
- **PeerTube**: For testing video content (later)
|
||||
|
||||
## Part 7: Verification Checklist
|
||||
|
||||
### Self-Hosted Instance Tests
|
||||
|
||||
- [ ] WebFinger returns correct actor links
|
||||
- [ ] Actor profile has all required fields
|
||||
- [ ] Follow from Mastodon to Solar Network works
|
||||
- [ ] Follow from Solar Network to Mastodon works
|
||||
- [ ] Accept activity sent back to Mastodon
|
||||
- [ ] Posts from Solar Network appear in Mastodon timeline
|
||||
- [ ] Posts from Mastodon appear in Solar Network database
|
||||
- [ ] Likes from Mastodon appear in Solar Network
|
||||
- [ ] Replies from Mastodon appear in Solar Network
|
||||
- [ ] Keys are properly generated and stored
|
||||
- [ ] HTTP signatures are correctly verified
|
||||
- [ ] Outbox returns public posts
|
||||
|
||||
### Real Instance Tests
|
||||
|
||||
- [ ] Domain is publicly accessible
|
||||
- [ ] HTTPS is working (or HTTP for local testing)
|
||||
- [ ] WebFinger works with your domain
|
||||
- [ ] Actor is discoverable from other instances
|
||||
- [ ] Posts federate to public instances
|
||||
- [ ] Users can follow across instances
|
||||
- [ ] Timelines show federated content
|
||||
|
||||
## Part 8: Monitoring During Tests
|
||||
|
||||
### Check Solar Network Logs
|
||||
|
||||
```bash
|
||||
# Follow logs in real-time
|
||||
dotnet run --project DysonNetwork.Sphere | grep -i activitypub
|
||||
```
|
||||
|
||||
### Check Mastodon Logs
|
||||
|
||||
```bash
|
||||
docker-compose -f docker-compose.mastodon-test.yml logs -f web | grep -i federation
|
||||
```
|
||||
|
||||
### Monitor Database Activity
|
||||
|
||||
```bash
|
||||
# Watch activity table
|
||||
watch -n 2 'psql -d dyson_network -c "SELECT type, status, created_at FROM fediverse_activities ORDER BY created_at DESC LIMIT 10;"'
|
||||
```
|
||||
|
||||
### Check Network Traffic
|
||||
|
||||
```bash
|
||||
# Monitor HTTP requests
|
||||
tcpdump -i lo port 5000 or port 3001 -A
|
||||
```
|
||||
|
||||
## Part 9: Advanced Testing
|
||||
|
||||
### Test HTTP Signature Fallbacks
|
||||
|
||||
Test with various signature headers:
|
||||
|
||||
```bash
|
||||
# With Date header
|
||||
curl -H "Date: $(date -u +%a,\ %d\ %b\ %Y\ %T\ GMT)" ...
|
||||
|
||||
# With Digest header
|
||||
curl -H "Digest: SHA-256=$(echo -n '{}' | openssl dgst -sha256 -binary | base64)" ...
|
||||
|
||||
# Multiple signed headers
|
||||
curl -H "Signature: keyId=\"...\",algorithm=\"rsa-sha256\",headers=\"(request-target) host date digest\",signature=\"...\"" ...
|
||||
```
|
||||
|
||||
### Test Rate Limiting
|
||||
|
||||
Send multiple requests quickly:
|
||||
|
||||
```bash
|
||||
for i in {1..10}; do
|
||||
curl -X POST http://solar.local:5000/activitypub/actors/solaruser/inbox \
|
||||
-H "Content-Type: application/activity+json" \
|
||||
-d '{"type":"Create",...}'
|
||||
done
|
||||
```
|
||||
|
||||
### Test Large Posts
|
||||
|
||||
Send post with attachments:
|
||||
|
||||
```bash
|
||||
curl -X POST http://solar.local:5000/api/posts \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"content": "A post with an image",
|
||||
"attachments": [{"id": "file-id"}],
|
||||
"visibility": 0
|
||||
}'
|
||||
```
|
||||
|
||||
## Part 10: Cleanup
|
||||
|
||||
### Stop Test Instances
|
||||
|
||||
```bash
|
||||
# Stop Mastodon
|
||||
docker-compose -f docker-compose.mastodon-test.yml down
|
||||
|
||||
# Stop GoToSocial
|
||||
docker-compose -f docker-compose.gotosocial.yml down
|
||||
|
||||
# Remove data volumes
|
||||
docker-compose -f docker-compose.mastodon-test.yml down -v
|
||||
```
|
||||
|
||||
### Reset Solar Network Database
|
||||
|
||||
```bash
|
||||
# Warning: This deletes all data!
|
||||
cd DysonNetwork.Sphere
|
||||
dotnet ef database drop
|
||||
dotnet ef database update
|
||||
```
|
||||
|
||||
### Remove /etc/hosts Entries
|
||||
|
||||
```bash
|
||||
sudo nano /etc/hosts
|
||||
|
||||
# Remove these lines:
|
||||
# 127.0.0.1 mastodon.local
|
||||
# 127.0.0.1 solar.local
|
||||
# 127.0.0.1 gotosocial.local
|
||||
```
|
||||
|
||||
## Next Steps After Testing
|
||||
|
||||
1. **Fix any issues found during testing**
|
||||
2. **Add retry logic for failed deliveries**
|
||||
3. **Implement activity queue for async processing**
|
||||
4. **Add monitoring and metrics**
|
||||
5. **Test with more instances (Pleroma, Pixelfed, etc.)**
|
||||
6. **Add support for more activity types**
|
||||
7. **Improve error handling and logging**
|
||||
8. **Add admin interface for managing federation**
|
||||
|
||||
## Useful Tools
|
||||
|
||||
### ActivityPub Testing Tools
|
||||
- [ActivityPub Playground](https://swicth.github.io/activity-pub-playground/)
|
||||
- [FediTest](https://feditest.com/)
|
||||
- [FediVerse.net](https://fedi.net/)
|
||||
|
||||
### HTTP Testing
|
||||
- [curl](https://curl.se/)
|
||||
- [httpie](https://httpie.io/)
|
||||
- [Postman](https://www.postman.com/)
|
||||
|
||||
### JSON Inspection
|
||||
- [jq](https://stedolan.github.io/jq/)
|
||||
- [jsonpath.com](https://jsonpath.com/)
|
||||
|
||||
### Network Debugging
|
||||
- [Wireshark](https://www.wireshark.org/)
|
||||
- [tcpdump](https://www.tcpdump.org/)
|
||||
|
||||
## References
|
||||
|
||||
- [ActivityPub W3C Spec](https://www.w3.org/TR/activitypub/)
|
||||
- [HTTP Signatures Draft](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures)
|
||||
- [WebFinger RFC 7033](https://tools.ietf.org/html/rfc7033)
|
||||
- [Mastodon Federation Documentation](https://docs.joinmastodon.org/admin/federation/)
|
||||
@@ -1,506 +0,0 @@
|
||||
# ActivityPub Testing Helper API
|
||||
|
||||
This document describes helper endpoints for testing ActivityPub federation.
|
||||
|
||||
## Purpose
|
||||
|
||||
These endpoints allow you to manually trigger ActivityPub activities for testing purposes without implementing the full UI federation integration yet.
|
||||
|
||||
## Helper Endpoints
|
||||
|
||||
### 1. Send Follow Activity
|
||||
|
||||
**Endpoint**: `POST /api/activitypub/test/follow`
|
||||
|
||||
**Description**: Sends a Follow activity to a remote actor
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"targetActorUri": "http://mastodon.local:3001/users/testuser"
|
||||
}
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"activityId": "http://solar.local:5000/activitypub/activities/...",
|
||||
"targetActor": "http://mastodon.local:3001/users/testuser"
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Send Like Activity
|
||||
|
||||
**Endpoint**: `POST /api/activitypub/test/like`
|
||||
|
||||
**Description**: Sends a Like activity for a post (can be local or remote)
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"postId": "POST_ID",
|
||||
"targetActorUri": "http://mastodon.local:3001/users/testuser"
|
||||
}
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"activityId": "http://solar.local:5000/activitypub/activities/..."
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Send Announce (Boost) Activity
|
||||
|
||||
**Endpoint**: `POST /api/activitypub/test/announce`
|
||||
|
||||
**Description**: Boosts a post to followers
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"postId": "POST_ID"
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Send Undo Activity
|
||||
|
||||
**Endpoint**: `POST /api/activitypub/test/undo`
|
||||
|
||||
**Description**: Undoes a previous activity
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"activityType": "Like", // or "Follow", "Announce"
|
||||
"objectUri": "http://solar.local:5000/activitypub/objects/POST_ID"
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Get Federation Status
|
||||
|
||||
**Endpoint**: `GET /api/activitypub/test/status`
|
||||
|
||||
**Description**: Returns current federation statistics
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"actors": {
|
||||
"total": 5,
|
||||
"local": 1,
|
||||
"remote": 4
|
||||
},
|
||||
"contents": {
|
||||
"total": 25,
|
||||
"byType": {
|
||||
"Note": 20,
|
||||
"Article": 5
|
||||
}
|
||||
},
|
||||
"relationships": {
|
||||
"total": 8,
|
||||
"accepted": 6,
|
||||
"pending": 1,
|
||||
"rejected": 1
|
||||
},
|
||||
"activities": {
|
||||
"total": 45,
|
||||
"byStatus": {
|
||||
"Completed": 40,
|
||||
"Pending": 3,
|
||||
"Failed": 2
|
||||
},
|
||||
"byType": {
|
||||
"Create": 20,
|
||||
"Follow": 8,
|
||||
"Accept": 6,
|
||||
"Like": 5,
|
||||
"Announce": 3,
|
||||
"Undo": 2,
|
||||
"Delete": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 6. Get Recent Activities
|
||||
|
||||
**Endpoint**: `GET /api/activitypub/test/activities`
|
||||
|
||||
**Query Parameters**:
|
||||
- `limit`: Number of activities to return (default: 20)
|
||||
- `type`: Filter by activity type (optional)
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"activities": [
|
||||
{
|
||||
"id": "ACTIVITY_ID",
|
||||
"type": "Follow",
|
||||
"status": "Completed",
|
||||
"actorUri": "http://mastodon.local:3001/users/testuser",
|
||||
"objectUri": "http://solar.local:5000/activitypub/actors/solaruser",
|
||||
"createdAt": "2024-01-15T10:30:00Z",
|
||||
"errorMessage": null
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 7. Get Actor Keys
|
||||
|
||||
**Endpoint**: `GET /api/activitypub/test/actors/{username}/keys`
|
||||
|
||||
**Description**: Returns the public/private key pair for a publisher
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"username": "solaruser",
|
||||
"hasKeys": true,
|
||||
"actorUri": "http://solar.local:5000/activitypub/actors/solaruser",
|
||||
"publicKeyId": "http://solar.local:5000/activitypub/actors/solaruser#main-key",
|
||||
"publicKey": "-----BEGIN PUBLIC KEY-----\n...",
|
||||
"privateKeyStored": true
|
||||
}
|
||||
```
|
||||
|
||||
### 8. Test HTTP Signature
|
||||
|
||||
**Endpoint**: `POST /api/activitypub/test/sign`
|
||||
|
||||
**Description**: Test if a signature string is valid for a given public key
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"publicKey": "-----BEGIN PUBLIC KEY-----\n...",
|
||||
"signingString": "(request-target): post /inbox\nhost: example.com\ndate: ...",
|
||||
"signature": "..."
|
||||
}
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"valid": true,
|
||||
"message": "Signature is valid"
|
||||
}
|
||||
```
|
||||
|
||||
## Controller Implementation
|
||||
|
||||
Create `DysonNetwork.Sphere/ActivityPub/ActivityPubTestController.cs`:
|
||||
|
||||
```csharp
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DysonNetwork.Sphere.ActivityPub;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/activitypub/test")]
|
||||
[Authorize] // Require auth for testing
|
||||
public class ActivityPubTestController(
|
||||
AppDatabase db,
|
||||
ActivityPubDeliveryService deliveryService,
|
||||
ActivityPubKeyService keyService,
|
||||
ActivityPubSignatureService signatureService,
|
||||
IConfiguration configuration,
|
||||
ILogger<ActivityPubTestController> logger
|
||||
) : ControllerBase
|
||||
{
|
||||
[HttpPost("follow")]
|
||||
public async Task<ActionResult> TestFollow([FromBody] TestFollowRequest request)
|
||||
{
|
||||
var currentUser = GetCurrentUser();
|
||||
var publisher = await GetPublisherForUser(currentUser.Id);
|
||||
|
||||
if (publisher == null)
|
||||
return BadRequest("Publisher not found");
|
||||
|
||||
var success = await deliveryService.SendFollowActivityAsync(
|
||||
publisher.Id,
|
||||
request.TargetActorUri
|
||||
);
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
success,
|
||||
targetActorUri = request.TargetActorUri,
|
||||
publisherId = publisher.Id
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost("like")]
|
||||
public async Task<ActionResult> TestLike([FromBody] TestLikeRequest request)
|
||||
{
|
||||
var currentUser = GetCurrentUser();
|
||||
var publisher = await GetPublisherForUser(currentUser.Id);
|
||||
|
||||
var success = await deliveryService.SendLikeActivityAsync(
|
||||
request.PostId,
|
||||
currentUser.Id,
|
||||
request.TargetActorUri
|
||||
);
|
||||
|
||||
return Ok(new { success, postId = request.PostId });
|
||||
}
|
||||
|
||||
[HttpPost("announce")]
|
||||
public async Task<ActionResult> TestAnnounce([FromBody] TestAnnounceRequest request)
|
||||
{
|
||||
var post = await db.Posts.FindAsync(request.PostId);
|
||||
if (post == null)
|
||||
return NotFound();
|
||||
|
||||
var success = await deliveryService.SendCreateActivityAsync(post);
|
||||
|
||||
return Ok(new { success, postId = request.PostId });
|
||||
}
|
||||
|
||||
[HttpPost("undo")]
|
||||
public async Task<ActionResult> TestUndo([FromBody] TestUndoRequest request)
|
||||
{
|
||||
var currentUser = GetCurrentUser();
|
||||
var publisher = await GetPublisherForUser(currentUser.Id);
|
||||
|
||||
if (publisher == null)
|
||||
return BadRequest("Publisher not found");
|
||||
|
||||
var success = await deliveryService.SendUndoActivityAsync(
|
||||
request.ActivityType,
|
||||
request.ObjectUri,
|
||||
publisher.Id
|
||||
);
|
||||
|
||||
return Ok(new { success, activityType = request.ActivityType });
|
||||
}
|
||||
|
||||
[HttpGet("status")]
|
||||
public async Task<ActionResult> GetStatus()
|
||||
{
|
||||
var totalActors = await db.FediverseActors.CountAsync();
|
||||
var localActors = await db.FediverseActors
|
||||
.CountAsync(a => a.Uri.Contains("solar.local"));
|
||||
|
||||
var totalContents = await db.FediverseContents.CountAsync();
|
||||
|
||||
var relationships = await db.FediverseRelationships
|
||||
.GroupBy(r => r.State)
|
||||
.Select(g => new { State = g.Key, Count = g.Count() })
|
||||
.ToListAsync();
|
||||
|
||||
var activitiesByStatus = await db.FediverseActivities
|
||||
.GroupBy(a => a.Status)
|
||||
.Select(g => new { Status = g.Key, Count = g.Count() })
|
||||
.ToListAsync();
|
||||
|
||||
var activitiesByType = await db.FediverseActivities
|
||||
.GroupBy(a => a.Type)
|
||||
.Select(g => new { Type = g.Key, Count = g.Count() })
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
actors = new
|
||||
{
|
||||
total = totalActors,
|
||||
local = localActors,
|
||||
remote = totalActors - localActors
|
||||
},
|
||||
contents = new
|
||||
{
|
||||
total = totalContents
|
||||
},
|
||||
relationships = relationships.ToDictionary(r => r.State.ToString(), r => r.Count),
|
||||
activities = new
|
||||
{
|
||||
byStatus = activitiesByStatus.ToDictionary(a => a.Status.ToString(), a => a.Count),
|
||||
byType = activitiesByType.ToDictionary(a => a.Type.ToString(), a => a.Count)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
[HttpGet("activities")]
|
||||
public async Task<ActionResult> GetActivities([FromQuery] int limit = 20, [FromQuery] string? type = null)
|
||||
{
|
||||
var query = db.FediverseActivities
|
||||
.OrderByDescending(a => a.CreatedAt);
|
||||
|
||||
if (!string.IsNullOrEmpty(type))
|
||||
{
|
||||
query = query.Where(a => a.Type.ToString() == type);
|
||||
}
|
||||
|
||||
var activities = await query
|
||||
.Take(limit)
|
||||
.Select(a => new
|
||||
{
|
||||
a.Id,
|
||||
a.Type,
|
||||
a.Status,
|
||||
ActorUri = a.Actor.Uri,
|
||||
ObjectUri = a.ObjectUri,
|
||||
a.CreatedAt,
|
||||
a.ErrorMessage
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
return Ok(new { activities });
|
||||
}
|
||||
|
||||
[HttpGet("actors/{username}/keys")]
|
||||
public async Task<ActionResult> GetActorKeys(string username)
|
||||
{
|
||||
var publisher = await db.Publishers
|
||||
.FirstOrDefaultAsync(p => p.Name == username);
|
||||
|
||||
if (publisher == null)
|
||||
return NotFound();
|
||||
|
||||
var actorUrl = $"http://solar.local:5000/activitypub/actors/{username}";
|
||||
|
||||
var (privateKey, publicKey) = keyService.GenerateKeyPair();
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
username,
|
||||
hasKeys = publisher.Meta != null,
|
||||
actorUri,
|
||||
publicKeyId = $"{actorUrl}#main-key",
|
||||
publicKey = publicKey,
|
||||
privateKeyStored = publisher.Meta != null
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost("sign")]
|
||||
public ActionResult TestSignature([FromBody] TestSignatureRequest request)
|
||||
{
|
||||
var isValid = keyService.Verify(
|
||||
request.PublicKey,
|
||||
request.SigningString,
|
||||
request.Signature
|
||||
);
|
||||
|
||||
return Ok(new
|
||||
{
|
||||
valid = isValid,
|
||||
message = isValid ? "Signature is valid" : "Signature is invalid"
|
||||
});
|
||||
}
|
||||
|
||||
private async Task<SnPublisher?> GetPublisherForUser(Guid accountId)
|
||||
{
|
||||
return await db.Publishers
|
||||
.Include(p => p.Members)
|
||||
.Where(p => p.Members.Any(m => m.AccountId == accountId))
|
||||
.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
private Guid GetCurrentUser()
|
||||
{
|
||||
// Implement based on your auth system
|
||||
return Guid.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestFollowRequest
|
||||
{
|
||||
public string TargetActorUri { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class TestLikeRequest
|
||||
{
|
||||
public Guid PostId { get; set; }
|
||||
public string TargetActorUri { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class TestAnnounceRequest
|
||||
{
|
||||
public Guid PostId { get; set; }
|
||||
}
|
||||
|
||||
public class TestUndoRequest
|
||||
{
|
||||
public string ActivityType { get; set; } = string.Empty;
|
||||
public string ObjectUri { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class TestSignatureRequest
|
||||
{
|
||||
public string PublicKey { get; set; } = string.Empty;
|
||||
public string SigningString { get; set; } = string.Empty;
|
||||
public string Signature { get; set; } = string.Empty;
|
||||
}
|
||||
```
|
||||
|
||||
## Testing with Helper Endpoints
|
||||
|
||||
### 1. Test Follow
|
||||
```bash
|
||||
curl -X POST http://solar.local:5000/api/activitypub/test/follow \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{
|
||||
"targetActorUri": "http://mastodon.local:3001/users/testuser"
|
||||
}'
|
||||
```
|
||||
|
||||
### 2. Test Like
|
||||
```bash
|
||||
curl -X POST http://solar.local:5000/api/activitypub/test/like \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-d '{
|
||||
"postId": "YOUR_POST_ID",
|
||||
"targetActorUri": "http://mastodon.local:5000/activitypub/actors/mastodonuser"
|
||||
}'
|
||||
```
|
||||
|
||||
### 3. Check Status
|
||||
```bash
|
||||
curl http://solar.local:5000/api/activitypub/test/status \
|
||||
-H "Authorization: Bearer YOUR_TOKEN"
|
||||
```
|
||||
|
||||
### 4. Get Recent Activities
|
||||
```bash
|
||||
curl "http://solar.local:5000/api/activitypub/test/activities?limit=10" \
|
||||
-H "Authorization: Bearer YOUR_TOKEN"
|
||||
```
|
||||
|
||||
## Integration with Main Flow
|
||||
|
||||
These helper endpoints can be used to:
|
||||
|
||||
1. **Quickly test federation** without full UI integration
|
||||
2. **Debug specific activity types** in isolation
|
||||
3. **Verify HTTP signatures** are correct
|
||||
4. **Test error handling** for various scenarios
|
||||
5. **Monitor federation status** during development
|
||||
|
||||
## Security Notes
|
||||
|
||||
- All test endpoints require authentication
|
||||
- Use only in development/staging environments
|
||||
- Remove or disable in production
|
||||
- Rate limiting recommended if exposing to public
|
||||
|
||||
## Cleanup
|
||||
|
||||
After testing, you can:
|
||||
|
||||
1. Remove the test controller (optional)
|
||||
2. Disable test endpoints
|
||||
3. Clear test activities from database
|
||||
4. Reset test relationships
|
||||
|
||||
```sql
|
||||
-- Clear test data
|
||||
DELETE FROM fediverse_activities WHERE created_at < NOW() - INTERVAL '1 day';
|
||||
```
|
||||
@@ -1,448 +0,0 @@
|
||||
# ActivityPub Testing - Complete Guide
|
||||
|
||||
This is the complete guide for testing ActivityPub federation in Solar Network.
|
||||
|
||||
## 📁 File Overview
|
||||
|
||||
| File | Purpose | When to Use |
|
||||
|------|---------|--------------|
|
||||
| `setup-activitypub-test.sh` | One-command setup of test environment | First time setup |
|
||||
| `test-activitypub.sh` | Quick validation of basic functionality | After setup, before detailed tests |
|
||||
| `ACTIVITYPUB_TESTING_QUICKSTART.md` | Quick start reference | Getting started quickly |
|
||||
| `ACTIVITYPUB_TESTING_GUIDE.md` | Comprehensive testing scenarios | Full testing workflow |
|
||||
| `ACTIVITYPUB_TESTING_QUICKREF.md` | Command and query reference | Daily testing |
|
||||
| `ACTIVITYPUB_TESTING_HELPER_API.md` | Helper API for testing | Programmatic testing |
|
||||
| `ACTIVITYPUB_TEST_RESULTS_TEMPLATE.md` | Track test results | During testing |
|
||||
| `ACTIVITYPUB_IMPLEMENTATION.md` | Implementation details | Understanding the code |
|
||||
| `ACTIVITYPUB_SUMMARY.md` | Feature summary | Reviewing what's implemented |
|
||||
|
||||
## 🚀 Quick Start (5 Minutes)
|
||||
|
||||
### 1. Setup Test Environment
|
||||
|
||||
```bash
|
||||
./setup-activitypub-test.sh
|
||||
```
|
||||
|
||||
This will:
|
||||
- ✅ Configure `/etc/hosts`
|
||||
- ✅ Start Mastodon via Docker
|
||||
- ✅ Create test Mastodon account
|
||||
- ✅ Apply database migrations
|
||||
|
||||
### 2. Validate Setup
|
||||
|
||||
```bash
|
||||
./test-activitypub.sh
|
||||
```
|
||||
|
||||
This checks:
|
||||
- ✅ WebFinger endpoint
|
||||
- ✅ Actor profile
|
||||
- ✅ Public keys
|
||||
- ✅ Database tables
|
||||
|
||||
### 3. Start Solar Network
|
||||
|
||||
```bash
|
||||
cd DysonNetwork.Sphere
|
||||
dotnet run
|
||||
```
|
||||
|
||||
### 4. Test Federation
|
||||
|
||||
1. Open http://mastodon.local:3001
|
||||
2. Search for `@solaruser@solar.local`
|
||||
3. Click Follow
|
||||
4. Create a post in Solar Network
|
||||
5. Verify it appears in Mastodon
|
||||
|
||||
## 📖 Recommended Reading Order
|
||||
|
||||
### For First-Time Testing
|
||||
|
||||
1. **Start Here**: `ACTIVITYPUB_TESTING_QUICKSTART.md`
|
||||
- Overview of the setup
|
||||
- Quick command reference
|
||||
- Common commands
|
||||
|
||||
2. **Then**: `ACTIVITYPUB_TESTING_GUIDE.md`
|
||||
- Detailed test scenarios
|
||||
- Step-by-step instructions
|
||||
- Troubleshooting
|
||||
|
||||
3. **Reference**: `ACTIVITYPUB_TESTING_QUICKREF.md`
|
||||
- Command snippets
|
||||
- Database queries
|
||||
- Response codes
|
||||
|
||||
### During Testing
|
||||
|
||||
1. **Track Progress**: `ACTIVITYPUB_TEST_RESULTS_TEMPLATE.md`
|
||||
- Checklists for each test
|
||||
- Results tracking
|
||||
- Issue logging
|
||||
|
||||
2. **Helper API**: `ACTIVITYPUB_TESTING_HELPER_API.md`
|
||||
- Manual testing endpoints
|
||||
- Debugging tools
|
||||
- Status monitoring
|
||||
|
||||
### For Understanding
|
||||
|
||||
1. **Implementation**: `ACTIVITYPUB_IMPLEMENTATION.md`
|
||||
- Architecture details
|
||||
- Service descriptions
|
||||
- Data flow diagrams
|
||||
|
||||
2. **Features**: `ACTIVITYPUB_SUMMARY.md`
|
||||
- What's implemented
|
||||
- Model relationships
|
||||
- API endpoints
|
||||
|
||||
## 🔍 Test Scenarios Summary
|
||||
|
||||
### Basic Functionality (All instances must pass)
|
||||
|
||||
- [ ] WebFinger discovery works
|
||||
- [ ] Actor profile is valid JSON-LD
|
||||
- [ ] Public key is present
|
||||
- [ ] Outbox returns public posts
|
||||
- [ ] Inbox accepts activities
|
||||
|
||||
### Federation - Follow
|
||||
|
||||
- [ ] Remote user can follow local user
|
||||
- [ ] Local user can follow remote user
|
||||
- [ ] Accept activity is sent/received
|
||||
- [ ] Relationship state is correct
|
||||
- [ ] Unfollow works correctly
|
||||
|
||||
### Federation - Content
|
||||
|
||||
- [ ] Local posts federate to remote instances
|
||||
- [ ] Remote posts appear in local database
|
||||
- [ ] Post content is preserved
|
||||
- [ ] Timestamps are correct
|
||||
- [ ] Attachments are handled
|
||||
- [ ] Content warnings are respected
|
||||
|
||||
### Federation - Interactions
|
||||
|
||||
- [ ] Likes federate correctly
|
||||
- [ ] Likes appear in both instances
|
||||
- [ ] Replies federate correctly
|
||||
- [ ] Reply threading works
|
||||
- [ ] Boosts/Announces work
|
||||
- [ ] Undo activities work
|
||||
|
||||
### Security
|
||||
|
||||
- [ ] HTTP signatures are verified
|
||||
- [ ] Invalid signatures are rejected
|
||||
- [ ] Keys are properly stored
|
||||
- [ ] Private keys never exposed
|
||||
|
||||
## 🐛 Common Issues & Solutions
|
||||
|
||||
### Issue: "Failed to verify signature"
|
||||
|
||||
**Causes**:
|
||||
1. Signature header format is wrong
|
||||
2. Public key doesn't match keyId
|
||||
3. Date header is too old (>5 minutes)
|
||||
4. Request body doesn't match digest
|
||||
|
||||
**Solutions**:
|
||||
1. Check signature format: `keyId="...",algorithm="...",headers="...",signature="..."`
|
||||
2. Verify keyId in actor profile
|
||||
3. Ensure Date header is recent
|
||||
4. Check body is exactly what was signed
|
||||
|
||||
### Issue: "Target actor or inbox not found"
|
||||
|
||||
**Causes**:
|
||||
1. Actor hasn't been fetched yet
|
||||
2. Actor URL is incorrect
|
||||
3. Remote instance is inaccessible
|
||||
|
||||
**Solutions**:
|
||||
1. Manually fetch actor first
|
||||
2. Verify actor URL is correct
|
||||
3. Test accessibility with curl
|
||||
|
||||
### Issue: Activities not arriving
|
||||
|
||||
**Causes**:
|
||||
1. Network connectivity issue
|
||||
2. Remote instance is down
|
||||
3. Activity wasn't queued properly
|
||||
|
||||
**Solutions**:
|
||||
1. Check network connectivity
|
||||
2. Verify remote instance is running
|
||||
3. Check fediverse_activities table for status
|
||||
|
||||
## 📊 Monitoring During Tests
|
||||
|
||||
### Check Logs
|
||||
|
||||
```bash
|
||||
# Solar Network ActivityPub logs
|
||||
dotnet run --project DysonNetwork.Sphere 2>&1 | grep -i activitypub
|
||||
|
||||
# Mastodon federation logs
|
||||
docker compose -f docker-compose.mastodon-test.yml logs -f web | grep -i federation
|
||||
```
|
||||
|
||||
### Monitor Database
|
||||
|
||||
```bash
|
||||
# Watch activity table
|
||||
watch -n 2 'psql -d dyson_network -c \
|
||||
"SELECT type, status, created_at FROM fediverse_activities ORDER BY created_at DESC LIMIT 5;"'
|
||||
```
|
||||
|
||||
### Test Network
|
||||
|
||||
```bash
|
||||
# Test connectivity between instances
|
||||
curl -v http://mastodon.local:3001
|
||||
curl -v http://solar.local:5000
|
||||
|
||||
# Test with traceroute (if available)
|
||||
traceroute mastodon.local
|
||||
traceroute solar.local
|
||||
```
|
||||
|
||||
## 🎯 Success Criteria
|
||||
|
||||
### Minimal Viable Federation
|
||||
|
||||
To consider ActivityPub implementation "working", all of these must pass:
|
||||
|
||||
- ✅ WebFinger returns actor links
|
||||
- ✅ Actor profile has all required fields
|
||||
- ✅ Follow relationships work bidirectionally
|
||||
- ✅ Public posts federate to followers
|
||||
- ✅ Incoming posts are stored correctly
|
||||
- ✅ HTTP signatures are verified
|
||||
- ✅ Basic interaction types work (Like, Reply)
|
||||
|
||||
### Full Production Ready
|
||||
|
||||
For production, also need:
|
||||
|
||||
- ✅ Activity queue with retry logic
|
||||
- ✅ Rate limiting on outgoing deliveries
|
||||
- ✅ Monitoring and alerting
|
||||
- ✅ Admin interface for federation management
|
||||
- ✅ Content filtering and moderation
|
||||
- ✅ Instance blocking capabilities
|
||||
- ✅ Performance optimization for high volume
|
||||
|
||||
## 🔐 Security Checklist
|
||||
|
||||
During testing, verify:
|
||||
|
||||
- [ ] Private keys are never logged
|
||||
- [ ] Private keys are never returned in API responses
|
||||
- [ ] Only public keys are in actor profiles
|
||||
- [ ] All incoming activities are signature-verified
|
||||
- [ ] Invalid signatures are rejected with 401
|
||||
- [ ] TLS is used in production
|
||||
- [ ] Host header is verified against request URL
|
||||
|
||||
## 📈 Performance Metrics
|
||||
|
||||
Track these during testing:
|
||||
|
||||
| Metric | Target | Actual |
|
||||
|--------|--------|--------|
|
||||
| WebFinger response time | <500ms | ___ ms |
|
||||
| Actor fetch time | <1s | ___ ms |
|
||||
| Signature verification time | <100ms | ___ ms |
|
||||
| Activity processing time | <500ms | ___ ms |
|
||||
| Outgoing delivery success rate | >95% | ___% |
|
||||
| Outgoing delivery time | <5s | ___ ms |
|
||||
|
||||
## 🧪 Testing Checklist
|
||||
|
||||
### Self-Hosted Instance Tests
|
||||
|
||||
**Setup**:
|
||||
- [ ] Setup script completed
|
||||
- [ ] Mast containers running
|
||||
- [ ] Solar Network running
|
||||
- [ ] /etc/hosts configured
|
||||
- [ ] Database migrations applied
|
||||
|
||||
**Basic Federation**:
|
||||
- [ ] WebFinger works
|
||||
- [ ] Actor profile valid
|
||||
- [ ] Public key present
|
||||
- [ ] Outbox accessible
|
||||
|
||||
**Follow Flow**:
|
||||
- [ ] Mastodon → Solar follow works
|
||||
- [ ] Solar → Mastodon follow works
|
||||
- [ ] Accept activity sent
|
||||
- [ ] Relationship state correct
|
||||
|
||||
**Content Flow**:
|
||||
- [ ] Solar posts appear in Mastodon
|
||||
- [ ] Mastodon posts appear in Solar
|
||||
- [ ] Content preserved correctly
|
||||
- [ ] Timestamps correct
|
||||
|
||||
**Interactions**:
|
||||
- [ ] Likes work both ways
|
||||
- [ ] Replies work both ways
|
||||
- [ ] Boosts work both ways
|
||||
- [ ] Undo works
|
||||
|
||||
**Security**:
|
||||
- [ ] HTTP signatures verified
|
||||
- [ ] Invalid signatures rejected
|
||||
- [ ] Keys properly managed
|
||||
|
||||
### Real Instance Tests
|
||||
|
||||
**Discovery**:
|
||||
- [ ] Domain publicly accessible
|
||||
- [ ] WebFinger works from public internet
|
||||
- [ ] Actor discoverable from public instances
|
||||
|
||||
**Federation**:
|
||||
- [ ] Posts federate to public instances
|
||||
- [ ] Follows work with public instances
|
||||
- [ ] Interactions work with public instances
|
||||
|
||||
## 📝 Testing Notes
|
||||
|
||||
### What Worked Well
|
||||
1. _____________________
|
||||
2. _____________________
|
||||
3. _____________________
|
||||
|
||||
### What Needs Improvement
|
||||
1. _____________________
|
||||
2. _____________________
|
||||
3. _____________________
|
||||
|
||||
### Bugs Found
|
||||
| # | Description | Severity | Status |
|
||||
|---|-------------|----------|--------|
|
||||
| 1 | _____________________ | Low/Medium/High | ☐ Open/☐ Fixed |
|
||||
| 2 | _____________________ | Low/Medium/High | ☐ Open/☐ Fixed |
|
||||
| 3 | _____________________ | Low/Medium/High | ☐ Open/☐ Fixed |
|
||||
|
||||
## 🎓 Learning Resources
|
||||
|
||||
### ActivityPub Specification
|
||||
- [W3C ActivityPub Recommendation](https://www.w3.org/TR/activitypub/)
|
||||
- [ActivityStreams 2.0](https://www.w3.org/TR/activitystreams-core/)
|
||||
- [HTTP Signatures Draft](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures)
|
||||
|
||||
### Implementation Guides
|
||||
- [Mastodon Federation Guide](https://docs.joinmastodon.org/admin/federation/)
|
||||
- [ActivityPub Testing Best Practices](https://blog.joinmastodon.org/2018/06/27/how-to-implement-a-basic-activitypub-server/)
|
||||
- [Federation Testing Checklist](https://docs.joinmastodon.org/spec/activitypub/)
|
||||
|
||||
### Tools
|
||||
- [ActivityPub Playground](https://swicth.github.io/activity-pub-playground/)
|
||||
- [FediTest](https://feditest.com/)
|
||||
- [JSONPath Online Evaluator](https://jsonpath.com/)
|
||||
|
||||
## 🔄 Next Steps After Testing
|
||||
|
||||
### Phase 1: Fix Issues
|
||||
- Address all bugs found during testing
|
||||
- Improve error messages
|
||||
- Add better logging
|
||||
|
||||
### Phase 2: Enhance Features
|
||||
- Implement activity queue
|
||||
- Add retry logic
|
||||
- Add rate limiting
|
||||
- Implement instance blocking
|
||||
|
||||
### Phase 3: Production Readiness
|
||||
- Add monitoring and metrics
|
||||
- Add admin interface
|
||||
- Add content filtering
|
||||
- Implement moderation tools
|
||||
|
||||
### Phase 4: Additional Features
|
||||
- Support more activity types
|
||||
- Support media attachments
|
||||
- Support polls
|
||||
- Support custom emojis
|
||||
|
||||
## 📞 Getting Help
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. **Check logs**: See the logs section above
|
||||
2. **Review troubleshooting**: See `ACTIVITYPUB_TESTING_GUIDE.md` Part 5
|
||||
3. **Check database queries**: Use queries from `ACTIVITYPUB_TESTING_QUICKREF.md`
|
||||
4. **Validate signatures**: Use helper API in `ACTIVITYPUB_TESTING_HELPER_API.md`
|
||||
|
||||
## ✨ Quick Test Commands
|
||||
|
||||
### All-in-One Test Sequence
|
||||
|
||||
```bash
|
||||
# 1. Setup
|
||||
./setup-activitypub-test.sh
|
||||
|
||||
# 2. Validate
|
||||
./test-activitypub.sh
|
||||
|
||||
# 3. Test WebFinger
|
||||
curl "http://solar.local:5000/.well-known/webfinger?resource=acct:solaruser@solar.local"
|
||||
|
||||
# 4. Test Actor
|
||||
curl -H "Accept: application/activity+json" \
|
||||
http://solar.local:5000/activitypub/actors/solaruser
|
||||
|
||||
# 5. Test Follow (from Mastodon UI)
|
||||
# Open http://mastodon.local:3001 and follow @solaruser@solar.local
|
||||
|
||||
# 6. Check database
|
||||
psql -d dyson_network -c "SELECT * FROM fediverse_relationships;"
|
||||
|
||||
# 7. Test Post (create in Solar Network UI)
|
||||
# Should appear in http://mastodon.local:3001
|
||||
|
||||
# 8. Verify content
|
||||
psql -d dyson_network -c "SELECT * FROM fediverse_contents;"
|
||||
|
||||
# 9. Test Like (like from Mastodon UI)
|
||||
# Should appear in fediverse_reactions table
|
||||
|
||||
# 10. Check activities
|
||||
psql -d dyson_network -c "SELECT type, status FROM fediverse_activities;"
|
||||
```
|
||||
|
||||
## 🎉 Conclusion
|
||||
|
||||
You now have everything needed to test ActivityPub federation for Solar Network:
|
||||
|
||||
- ✅ Self-hosted test environment (Mastodon)
|
||||
- ✅ Setup automation (setup script)
|
||||
- ✅ Quick validation (test script)
|
||||
- ✅ Comprehensive testing guide
|
||||
- ✅ Helper API for programmatic testing
|
||||
- ✅ Quick reference for daily use
|
||||
- ✅ Results template for tracking progress
|
||||
|
||||
**Recommended workflow**:
|
||||
1. Run `setup-activitypub-test.sh`
|
||||
2. Run `test-activitypub.sh` for validation
|
||||
3. Follow scenarios in `ACTIVITYPUB_TESTING_GUIDE.md`
|
||||
4. Use `ACTIVITYPUB_TESTING_HELPER_API.md` for specific tests
|
||||
5. Track results in `ACTIVITYPUB_TEST_RESULTS_TEMPLATE.md`
|
||||
6. Reference `ACTIVITYPUB_TESTING_QUICKREF.md` for commands
|
||||
|
||||
Good luck with your federation testing! 🚀
|
||||
@@ -1,356 +0,0 @@
|
||||
# ActivityPub Testing Quick Reference
|
||||
|
||||
## Quick Test Commands
|
||||
|
||||
### 1. Test WebFinger
|
||||
```bash
|
||||
curl "http://solar.local:5000/.well-known/webfinger?resource=acct:username@solar.local"
|
||||
```
|
||||
|
||||
### 2. Fetch Actor Profile
|
||||
```bash
|
||||
curl -H "Accept: application/activity+json" \
|
||||
http://solar.local:5000/activitypub/actors/username
|
||||
```
|
||||
|
||||
### 3. Get Outbox
|
||||
```bash
|
||||
curl -H "Accept: application/activity+json" \
|
||||
http://solar.local:5000/activitypub/actors/username/outbox
|
||||
```
|
||||
|
||||
### 4. Send Test Follow (from remote)
|
||||
```bash
|
||||
curl -X POST http://solar.local:5000/activitypub/actors/username/inbox \
|
||||
-H "Content-Type: application/activity+json" \
|
||||
-d '{
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"id": "https://mastodon.local:3001/follow-123",
|
||||
"type": "Follow",
|
||||
"actor": "https://mastodon.local:3001/users/remoteuser",
|
||||
"object": "https://solar.local:5000/activitypub/actors/username"
|
||||
}'
|
||||
```
|
||||
|
||||
### 5. Send Test Create (post)
|
||||
```bash
|
||||
curl -X POST http://solar.local:5000/activitypub/actors/username/inbox \
|
||||
-H "Content-Type: application/activity+json" \
|
||||
-d '{
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"id": "https://mastodon.local:3001/post-123",
|
||||
"type": "Create",
|
||||
"actor": "https://mastodon.local:3001/users/remoteuser",
|
||||
"object": {
|
||||
"id": "https://mastodon.local:3001/objects/post-123",
|
||||
"type": "Note",
|
||||
"content": "Hello from Mastodon! @username@solar.local",
|
||||
"attributedTo": "https://mastodon.local:3001/users/remoteuser",
|
||||
"to": ["https://www.w3.org/ns/activitystreams#Public"]
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### 6. Send Test Like
|
||||
```bash
|
||||
curl -X POST http://solar.local:5000/activitypub/actors/username/inbox \
|
||||
-H "Content-Type: application/activity+json" \
|
||||
-d '{
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"id": "https://mastodon.local:3001/like-123",
|
||||
"type": "Like",
|
||||
"actor": "https://mastodon.local:3001/users/remoteuser",
|
||||
"object": "https://solar.local:5000/activitypub/objects/post-id"
|
||||
}'
|
||||
```
|
||||
|
||||
## Database Queries
|
||||
|
||||
### Check Actors
|
||||
```sql
|
||||
SELECT id, uri, username, display_name, instance_id
|
||||
FROM fediverse_actors;
|
||||
```
|
||||
|
||||
### Check Contents
|
||||
```sql
|
||||
SELECT id, uri, type, content, actor_id, created_at
|
||||
FROM fediverse_contents
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 20;
|
||||
```
|
||||
|
||||
### Check Relationships
|
||||
```sql
|
||||
SELECT r.id, a1.uri as actor, a2.uri as target, r.state, r.is_following
|
||||
FROM fediverse_relationships r
|
||||
JOIN fediverse_actors a1 ON r.actor_id = a1.id
|
||||
JOIN fediverse_actors a2 ON r.target_actor_id = a2.id;
|
||||
```
|
||||
|
||||
### Check Activities
|
||||
```sql
|
||||
SELECT type, status, error_message, created_at
|
||||
FROM fediverse_activities
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 20;
|
||||
```
|
||||
|
||||
### Check Reactions
|
||||
```sql
|
||||
SELECT r.type, c.uri as content_uri, a.uri as actor_uri
|
||||
FROM fediverse_reactions r
|
||||
JOIN fediverse_contents c ON r.content_id = c.id
|
||||
JOIN fediverse_actors a ON r.actor_id = a.id;
|
||||
```
|
||||
|
||||
## Check Keys in Publisher
|
||||
```sql
|
||||
SELECT id, name, meta
|
||||
FROM publishers
|
||||
WHERE meta IS NOT NULL;
|
||||
```
|
||||
|
||||
## Docker Commands
|
||||
|
||||
### Start Mastodon
|
||||
```bash
|
||||
docker-compose -f docker-compose.mastodon-test.yml up -d
|
||||
```
|
||||
|
||||
### View Mastodon Logs
|
||||
```bash
|
||||
docker-compose -f docker-compose.mastodon-test.yml logs -f web
|
||||
```
|
||||
|
||||
### Stop Mastodon
|
||||
```bash
|
||||
docker-compose -f docker-compose.mastodon-test.yml down
|
||||
```
|
||||
|
||||
### Start GoToSocial
|
||||
```bash
|
||||
docker-compose -f docker-compose.gotosocial.yml up -d
|
||||
```
|
||||
|
||||
## Solar Network Commands
|
||||
|
||||
### Run Migrations
|
||||
```bash
|
||||
cd DysonNetwork.Sphere
|
||||
dotnet ef database update
|
||||
```
|
||||
|
||||
### Run with Debug Logging
|
||||
```bash
|
||||
dotnet run --project DysonNetwork.Sphere -- --logging:LogLevel:DysonNetwork.Sphere.ActivityPub=Trace
|
||||
```
|
||||
|
||||
## Common Response Codes
|
||||
|
||||
| Code | Meaning |
|
||||
|------|---------|
|
||||
| 200 | Success |
|
||||
| 202 | Accepted (activity queued) |
|
||||
| 401 | Unauthorized (invalid signature) |
|
||||
| 404 | Not found (user/post doesn't exist) |
|
||||
| 400 | Bad request (invalid activity) |
|
||||
|
||||
## Activity Status Codes
|
||||
|
||||
| Status | Code | Meaning |
|
||||
|--------|------|---------|
|
||||
| Pending | 0 | Activity waiting to be processed |
|
||||
| Processing | 1 | Activity being processed |
|
||||
| Completed | 2 | Activity successfully processed |
|
||||
| Failed | 3 | Activity processing failed |
|
||||
|
||||
## Relationship States
|
||||
|
||||
| State | Code | Meaning |
|
||||
|--------|------|---------|
|
||||
| Pending | 0 | Follow request sent, waiting for Accept |
|
||||
| Accepted | 1 | Follow accepted, relationship active |
|
||||
| Rejected | 2 | Follow rejected |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Failed to verify signature"
|
||||
|
||||
**Check**: Signature header format
|
||||
```bash
|
||||
# Should be:
|
||||
Signature: keyId="...",algorithm="rsa-sha256",headers="...",signature="..."
|
||||
```
|
||||
|
||||
**Check**: Public key in actor profile
|
||||
```bash
|
||||
curl -H "Accept: application/activity+json" \
|
||||
http://solar.local:5000/activitypub/actors/username | jq '.publicKey'
|
||||
```
|
||||
|
||||
### "Actor not found"
|
||||
|
||||
**Check**: Actor exists in database
|
||||
```bash
|
||||
psql -d dyson_network -c \
|
||||
"SELECT * FROM fediverse_actors WHERE uri = '...';"
|
||||
```
|
||||
|
||||
**Check**: Actor URL is accessible
|
||||
```bash
|
||||
curl -v http://remote-instance.com/users/username
|
||||
```
|
||||
|
||||
### "Content already exists"
|
||||
|
||||
This is normal behavior - the system is deduplicating.
|
||||
|
||||
### "Target publisher not found"
|
||||
|
||||
**Check**: Publisher exists
|
||||
```bash
|
||||
psql -d dyson_network -c \
|
||||
"SELECT * FROM publishers WHERE name = '...';"
|
||||
```
|
||||
|
||||
## Quick Test Sequence
|
||||
|
||||
### Full Federation Test
|
||||
|
||||
```bash
|
||||
# 1. Start both instances
|
||||
docker-compose -f docker-compose.mastodon-test.yml up -d
|
||||
dotnet run --project DysonNetwork.Sphere
|
||||
|
||||
# 2. Test WebFinger
|
||||
curl "http://solar.local:5000/.well-known/webfinger?resource=acct:solaruser@solar.local"
|
||||
|
||||
# 3. Get Actor
|
||||
curl -H "Accept: application/activity+json" \
|
||||
http://solar.local:5000/activitypub/actors/solaruser
|
||||
|
||||
# 4. Send Follow from Mastodon
|
||||
# (Do this in Mastodon UI or use curl above)
|
||||
|
||||
# 5. Check database
|
||||
psql -d dyson_network -c "SELECT * FROM fediverse_relationships;"
|
||||
|
||||
# 6. Send Create (post) from Mastodon
|
||||
# (Use curl command above)
|
||||
|
||||
# 7. Check content
|
||||
psql -d dyson_network -c "SELECT * FROM fediverse_contents;"
|
||||
|
||||
# 8. Send Like from Mastodon
|
||||
# (Use curl command above)
|
||||
|
||||
# 9. Check reactions
|
||||
psql -d dyson_network -c "SELECT * FROM fediverse_reactions;"
|
||||
|
||||
# 10. Check activities
|
||||
psql -d dyson_network -c "SELECT type, status FROM fediverse_activities;"
|
||||
```
|
||||
|
||||
## Test URLs
|
||||
|
||||
| Instance | Web | API | ActivityPub |
|
||||
|----------|-----|-----|-----------|
|
||||
| Solar Network | http://solar.local:5000 | http://solar.local:5000/api | http://solar.local:5000/activitypub |
|
||||
| Mastodon | http://mastodon.local:3001 | http://mastodon.local:3001/api/v1 | http://mastodon.local:3001/inbox |
|
||||
|
||||
## Environment Variables
|
||||
|
||||
### Solar Network
|
||||
```bash
|
||||
export SOLAR_DOMAIN="solar.local"
|
||||
export SOLAR_URL="http://solar.local:5000"
|
||||
```
|
||||
|
||||
### Mastodon
|
||||
```bash
|
||||
export MASTODON_DOMAIN="mastodon.local"
|
||||
export MASTODON_URL="http://mastodon.local:3001"
|
||||
```
|
||||
|
||||
## Useful jq Commands
|
||||
|
||||
### Extract Actor ID
|
||||
```bash
|
||||
curl ... | jq '.id'
|
||||
```
|
||||
|
||||
### Extract Inbox URL
|
||||
```bash
|
||||
curl ... | jq '.inbox'
|
||||
```
|
||||
|
||||
### Extract Public Key
|
||||
```bash
|
||||
curl ... | jq '.publicKey.publicKeyPem'
|
||||
```
|
||||
|
||||
### Pretty Print Activity
|
||||
```bash
|
||||
curl ... | jq '.'
|
||||
```
|
||||
|
||||
### Extract Activity Type
|
||||
```bash
|
||||
curl ... | jq '.type'
|
||||
```
|
||||
|
||||
## Network Setup
|
||||
|
||||
### /etc/hosts
|
||||
```
|
||||
127.0.0.1 solar.local
|
||||
127.0.0.1 mastodon.local
|
||||
127.0.0.1 gotosocial.local
|
||||
```
|
||||
|
||||
### Ports Used
|
||||
- Solar Network: 5000
|
||||
- Mastodon: 3001 (web), 4000 (streaming)
|
||||
- GoToSocial: 3002
|
||||
- PostgreSQL: 5432
|
||||
- Redis: 6379
|
||||
- Elasticsearch: 9200
|
||||
|
||||
## File Locations
|
||||
|
||||
### Docker Compose Files
|
||||
- `docker-compose.mastodon-test.yml`
|
||||
- `docker-compose.gotosocial.yml`
|
||||
|
||||
### Environment Files
|
||||
- `.env.mastodon`
|
||||
|
||||
### Data Volumes
|
||||
- `./mastodon-data/`
|
||||
- `./gotosocial-data/`
|
||||
|
||||
## Clean Up Commands
|
||||
|
||||
```bash
|
||||
# Reset database
|
||||
psql -d dyson_network <<EOF
|
||||
TRUNCATE fediverse_activities CASCADE;
|
||||
TRUNCATE fediverse_relationships CASCADE;
|
||||
TRUNCATE fediverse_reactions CASCADE;
|
||||
TRUNCATE fediverse_contents CASCADE;
|
||||
TRUNCATE fediverse_actors CASCADE;
|
||||
TRUNCATE fediverse_instances CASCADE;
|
||||
UPDATE publishers SET meta = NULL WHERE meta IS NOT NULL;
|
||||
EOF
|
||||
|
||||
# Reset everything
|
||||
docker-compose -f docker-compose.mastodon-test.yml down -v
|
||||
docker-compose -f docker-compose.gotosocial.yml down -v
|
||||
psql -d dyson_network <<EOF
|
||||
DROP SCHEMA public CASCADE;
|
||||
CREATE SCHEMA public;
|
||||
EOF
|
||||
dotnet ef database drop
|
||||
dotnet ef database update
|
||||
```
|
||||
@@ -1,289 +0,0 @@
|
||||
# ActivityPub Testing - Quick Start
|
||||
|
||||
This directory contains everything you need to test ActivityPub federation for Solar Network.
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Run the Setup Script
|
||||
|
||||
```bash
|
||||
./setup-activitypub-test.sh
|
||||
```
|
||||
|
||||
This will:
|
||||
- ✅ Check prerequisites (Docker, PostgreSQL)
|
||||
- ✅ Update `/etc/hosts` with test domains
|
||||
- ✅ Generate Mastodon environment file
|
||||
- ✅ Create Docker Compose file
|
||||
- ✅ Start Mastodon containers
|
||||
- ✅ Create test Mastodon account
|
||||
- ✅ Apply Solar Network migrations
|
||||
|
||||
### 2. Start Solar Network
|
||||
|
||||
```bash
|
||||
cd DysonNetwork.Sphere
|
||||
dotnet run
|
||||
```
|
||||
|
||||
### 3. Test Federation
|
||||
|
||||
Follow the scenarios in [ACTIVITYPUB_TESTING_GUIDE.md](ACTIVITYPUB_TESTING_GUIDE.md)
|
||||
|
||||
## Test Instances
|
||||
|
||||
| Service | URL | Notes |
|
||||
|---------|-----|-------|
|
||||
| Solar Network | http://solar.local:5000 | Your implementation |
|
||||
| Mastodon | http://mastodon.local:3001 | Test instance |
|
||||
| Mastodon Streaming | http://mastodon.local:4000 | WebSocket |
|
||||
|
||||
## Test Accounts
|
||||
|
||||
### Solar Network
|
||||
- Create via UI or API
|
||||
- Username: `solaruser` (or your choice)
|
||||
|
||||
### Mastodon
|
||||
- Username: `testuser@mastodon.local`
|
||||
- Password: `TestPassword123!`
|
||||
- Role: Admin
|
||||
|
||||
## Quick Test Commands
|
||||
|
||||
### Test WebFinger
|
||||
```bash
|
||||
curl "http://solar.local:5000/.well-known/webfinger?resource=acct:solaruser@solar.local"
|
||||
```
|
||||
|
||||
### Test Actor
|
||||
```bash
|
||||
curl -H "Accept: application/activity+json" \
|
||||
http://solar.local:5000/activitypub/actors/solaruser
|
||||
```
|
||||
|
||||
### Test Outbox
|
||||
```bash
|
||||
curl -H "Accept: application/activity+json" \
|
||||
http://solar.local:5000/activitypub/actors/solaruser/outbox
|
||||
```
|
||||
|
||||
### Test Follow (from Mastodon)
|
||||
1. Open http://mastodon.local:3001
|
||||
2. Log in as `testuser@mastodon.local`
|
||||
3. Search for `@solaruser@solar.local`
|
||||
4. Click Follow
|
||||
|
||||
### Test Follow (from Solar Network to Mastodon)
|
||||
```bash
|
||||
# Send Follow activity to Solar Network
|
||||
curl -X POST http://solar.local:5000/activitypub/actors/solaruser/inbox \
|
||||
-H "Content-Type: application/activity+json" \
|
||||
-d '{
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"id": "http://solar.local:5000/follow-1",
|
||||
"type": "Follow",
|
||||
"actor": "https://solar.local:5000/activitypub/actors/solaruser",
|
||||
"object": "http://mastodon.local:3001/users/testuser"
|
||||
}'
|
||||
```
|
||||
|
||||
## Documentation Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `ACTIVITYPUB_TESTING_GUIDE.md` | Comprehensive testing guide |
|
||||
| `ACTIVITYPUB_TESTING_QUICKREF.md` | Quick command reference |
|
||||
| `ACTIVITYPUB_IMPLEMENTATION.md` | Implementation details |
|
||||
| `ACTIVITYPUB_SUMMARY.md` | Feature summary |
|
||||
| `ACTIVITYPUB_PLAN.md` | Original implementation plan |
|
||||
|
||||
## Database Checks
|
||||
|
||||
### Connect to Database
|
||||
```bash
|
||||
psql -d dyson_network
|
||||
```
|
||||
|
||||
### View Actors
|
||||
```sql
|
||||
SELECT uri, username, display_name, created_at
|
||||
FROM fediverse_actors;
|
||||
```
|
||||
|
||||
### View Contents
|
||||
```sql
|
||||
SELECT uri, type, content, actor_id, created_at
|
||||
FROM fediverse_contents
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10;
|
||||
```
|
||||
|
||||
### View Relationships
|
||||
```sql
|
||||
SELECT state, is_following, is_followed_by, created_at
|
||||
FROM fediverse_relationships;
|
||||
```
|
||||
|
||||
### View Activities
|
||||
```sql
|
||||
SELECT type, status, error_message, created_at
|
||||
FROM fediverse_activities
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10;
|
||||
```
|
||||
|
||||
## Logs
|
||||
|
||||
### Solar Network Logs
|
||||
```bash
|
||||
# Live logs
|
||||
dotnet run --project DysonNetwork.Sphere
|
||||
|
||||
# Follow ActivityPub activity
|
||||
dotnet run --project DysonNetwork.Sphere 2>&1 | grep -i activitypub
|
||||
|
||||
# Debug logging
|
||||
dotnet run --project DysonNetwork.Sphere --logging:LogLevel:DysonNetwork.Sphere.ActivityPub=Trace
|
||||
```
|
||||
|
||||
### Mastodon Logs
|
||||
```bash
|
||||
# All services
|
||||
docker compose -f docker-compose.mastodon-test.yml logs -f
|
||||
|
||||
# Web service only
|
||||
docker compose -f docker-compose.mastodon-test.yml logs -f web
|
||||
|
||||
# Filter for federation
|
||||
docker compose -f docker-compose.mastodon-test.yml logs -f web | grep -i federation
|
||||
```
|
||||
|
||||
## Stopping Everything
|
||||
|
||||
```bash
|
||||
# Stop Mastodon
|
||||
docker compose -f docker-compose.mastodon-test.yml down
|
||||
|
||||
# Stop with volume cleanup
|
||||
docker compose -f docker-compose.mastodon-test.yml down -v
|
||||
|
||||
# Restore /etc/hosts
|
||||
sudo mv /etc/hosts.backup /etc/hosts
|
||||
|
||||
# Remove test databases (optional)
|
||||
psql -d dyson_network <<EOF
|
||||
TRUNCATE fediverse_activities CASCADE;
|
||||
TRUNCATE fediverse_relationships CASCADE;
|
||||
TRUNCATE fediverse_reactions CASCADE;
|
||||
TRUNCATE fediverse_contents CASCADE;
|
||||
TRUNCATE fediverse_actors CASCADE;
|
||||
TRUNCATE fediverse_instances CASCADE;
|
||||
UPDATE publishers SET meta = NULL WHERE meta IS NOT NULL;
|
||||
EOF
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Mastodon won't start
|
||||
|
||||
```bash
|
||||
# Check logs
|
||||
docker compose -f docker-compose.mastodon-test.yml logs -f web
|
||||
|
||||
# Restart
|
||||
docker compose -f docker-compose.mastodon-test.yml restart
|
||||
|
||||
# Recreate
|
||||
docker compose -f docker-compose.mastodon-test.yml down
|
||||
docker compose -f docker-compose.mastodon-test.yml up -d
|
||||
```
|
||||
|
||||
### Can't connect to Solar Network
|
||||
|
||||
```bash
|
||||
# Check if running
|
||||
curl http://solar.local:5000
|
||||
|
||||
# Check logs
|
||||
dotnet run --project DysonNetwork.Sphere 2>&1 | grep -i error
|
||||
|
||||
# Restart
|
||||
# Ctrl+C in terminal and run again
|
||||
```
|
||||
|
||||
### Activities not arriving
|
||||
|
||||
```bash
|
||||
# Check database
|
||||
psql -d dyson_network -c "SELECT * FROM fediverse_activities WHERE status = 3;"
|
||||
|
||||
# Check signature verification logs
|
||||
dotnet run --project DysonNetwork.Sphere 2>&1 | grep -i "signature"
|
||||
|
||||
# Verify actor keys
|
||||
curl -H "Accept: application/activity+json" \
|
||||
http://solar.local:5000/activitypub/actors/solaruser | jq '.publicKey'
|
||||
```
|
||||
|
||||
## Testing Checklist
|
||||
|
||||
- [ ] Setup script completed successfully
|
||||
- [ ] Mastodon is running and accessible
|
||||
- [ ] Solar Network is running and accessible
|
||||
- [ ] WebFinger returns correct data
|
||||
- [ ] Actor profile includes public key
|
||||
- [ ] Follow from Mastodon to Solar Network works
|
||||
- [ ] Follow from Solar Network to Mastodon works
|
||||
- [ ] Posts from Solar Network appear in Mastodon
|
||||
- [ ] Posts from Mastodon appear in Solar Network database
|
||||
- [ ] Likes federate correctly
|
||||
- [ ] Replies federate correctly
|
||||
- [ ] HTTP signatures are verified
|
||||
- [ ] No errors in logs
|
||||
- [ ] Database contains expected data
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. **Test with a real instance**:
|
||||
- Get a public domain or use ngrok
|
||||
- Update `ActivityPub:Domain` in appsettings.json
|
||||
- Test with mastodon.social or other public instances
|
||||
|
||||
2. **Add more features**:
|
||||
- Activity queue for async processing
|
||||
- Retry logic for failed deliveries
|
||||
- Metrics and monitoring
|
||||
- Admin interface for federation management
|
||||
|
||||
3. **Test with more instances**:
|
||||
- Pleroma
|
||||
- Pixelfed
|
||||
- Lemmy
|
||||
- PeerTube
|
||||
|
||||
## Getting Help
|
||||
|
||||
If something doesn't work:
|
||||
|
||||
1. Check the logs (see Logs section above)
|
||||
2. Review the troubleshooting section in [ACTIVITYPUB_TESTING_GUIDE.md](ACTIVITYPUB_TESTING_GUIDE.md)
|
||||
3. Verify all prerequisites are installed
|
||||
4. Check network connectivity between instances
|
||||
5. Review the [ACTIVITYPUB_IMPLEMENTATION.md](ACTIVITYPUB_IMPLEMENTATION.md) for architecture details
|
||||
|
||||
## Useful URLs
|
||||
|
||||
### Test Instances
|
||||
- Mastodon: http://mastodon.local:3001
|
||||
- Solar Network: http://solar.local:5000
|
||||
|
||||
### Documentation
|
||||
- ActivityPub W3C Spec: https://www.w3.org/TR/activitypub/
|
||||
- Mastodon Federation Docs: https://docs.joinmastodon.org/admin/federation/
|
||||
- ActivityPub Playground: https://swicth.github.io/activity-pub-playground/
|
||||
|
||||
### Tools
|
||||
- jq: JSON processor (https://stedolan.github.io/jq/)
|
||||
- httpie: HTTP client (https://httpie.io/)
|
||||
- Docker Compose: (https://docs.docker.com/compose/)
|
||||
@@ -1,275 +0,0 @@
|
||||
# ActivityPub Testing Guide
|
||||
|
||||
Complete guide for testing ActivityPub federation in Solar Network.
|
||||
|
||||
## 📚 Documentation Files
|
||||
|
||||
| File | Description | Size |
|
||||
|------|-------------|-------|
|
||||
| `ACTIVITYPUB_TESTING_INDEX.md` | **START HERE** - Master guide with overview | 12K |
|
||||
| `ACTIVITYPUB_TESTING_QUICKSTART.md` | Quick reference for common tasks | 7K |
|
||||
| `ACTIVITYPUB_TESTING_GUIDE.md` | Comprehensive testing scenarios (10 parts) | 19K |
|
||||
| `ACTIVITYPUB_TESTING_QUICKREF.md` | Command and query reference | 8K |
|
||||
| `ACTIVITYPUB_TESTING_HELPER_API.md` | Helper API for programmatic testing | 12K |
|
||||
| `ACTIVITYPUB_TESTING_RESULTS_TEMPLATE.md` | Template to track test results | 10K |
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### Option A: One-Command Setup (Recommended)
|
||||
|
||||
```bash
|
||||
# 1. Run setup script
|
||||
./setup-activitypub-test.sh
|
||||
|
||||
# 2. Run validation
|
||||
./test-activitypub.sh
|
||||
|
||||
# 3. Start Solar Network
|
||||
cd DysonNetwork.Sphere
|
||||
dotnet run
|
||||
```
|
||||
|
||||
### Option B: Manual Setup
|
||||
|
||||
1. **Read**: `ACTIVITYPUB_TESTING_QUICKSTART.md`
|
||||
2. **Configure**: Copy `.env.testing.example` to `.env` and adjust
|
||||
3. **Follow**: Step-by-step in `ACTIVITYPUB_TESTING_GUIDE.md`
|
||||
|
||||
## 🎯 What You Can Test
|
||||
|
||||
### With Self-Hosted Instance
|
||||
- ✅ WebFinger discovery
|
||||
- ✅ Actor profile retrieval
|
||||
- ✅ Follow relationships (bidirectional)
|
||||
- ✅ Post federation (Solar → Mastodon)
|
||||
- ✅ Content reception (Mastodon → Solar)
|
||||
- ✅ Like interactions
|
||||
- ✅ Reply threading
|
||||
- ✅ HTTP signature verification
|
||||
- ✅ Content deletion
|
||||
|
||||
### With Real Instance
|
||||
- ✅ Public domain setup (via ngrok or VPS)
|
||||
- ✅ Federation with public instances (mastodon.social, etc.)
|
||||
- ✅ Real-world compatibility testing
|
||||
- ✅ Performance under real load
|
||||
|
||||
## 📋 Testing Workflow
|
||||
|
||||
### Day 1: Basic Functionality
|
||||
- Setup test environment
|
||||
- Test WebFinger and Actor endpoints
|
||||
- Verify HTTP signatures
|
||||
- Test basic follow/unfollow
|
||||
|
||||
### Day 2: Content Federation
|
||||
- Test post creation and delivery
|
||||
- Test content reception
|
||||
- Test media attachments
|
||||
- Test content warnings
|
||||
|
||||
### Day 3: Interactions
|
||||
- Test likes (both directions)
|
||||
- Test replies and threading
|
||||
- Test boosts/announces
|
||||
- Test undo activities
|
||||
|
||||
### Day 4: Real Instance
|
||||
- Set up public domain
|
||||
- Test with mastodon.social
|
||||
- Test with other instances
|
||||
- Verify cross-instance compatibility
|
||||
|
||||
### Day 5: Edge Cases
|
||||
- Test error handling
|
||||
- Test failed deliveries
|
||||
- Test invalid signatures
|
||||
- Test malformed activities
|
||||
|
||||
## 🛠️ Setup Scripts
|
||||
|
||||
| Script | Purpose |
|
||||
|--------|---------|
|
||||
| `setup-activitypub-test.sh` | One-command setup of Mastodon + Solar Network |
|
||||
| `test-activitypub.sh` | Quick validation of core functionality |
|
||||
|
||||
Both scripts are executable (`chmod +x`).
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Required Tools
|
||||
- ✅ Docker (for Mastodon)
|
||||
- ✅ .NET 10 SDK (for Solar Network)
|
||||
- ✅ PostgreSQL client (psql)
|
||||
- ✅ curl (for API testing)
|
||||
|
||||
### Quick Setup
|
||||
```bash
|
||||
# 1. Install dependencies (Ubuntu/Debian)
|
||||
sudo apt-get install docker.io docker-compose postgresql-client curl jq
|
||||
|
||||
# 2. Run setup
|
||||
./setup-activitypub-test.sh
|
||||
|
||||
# 3. Validate
|
||||
./test-activitypub.sh
|
||||
```
|
||||
|
||||
## 📊 Progress Tracking
|
||||
|
||||
Use the template to track your testing progress:
|
||||
|
||||
```bash
|
||||
# Copy the template
|
||||
cp ACTIVITYPUB_TESTING_RESULTS_TEMPLATE.md my-test-results.md
|
||||
|
||||
# Edit as you test
|
||||
nano my-test-results.md
|
||||
```
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
### Quick Fixes
|
||||
|
||||
**Mastodon won't start**:
|
||||
```bash
|
||||
# Check logs
|
||||
docker compose -f docker-compose.mastodon-test.yml logs -f
|
||||
|
||||
# Restart containers
|
||||
docker compose -f docker-compose.mastodon-test.yml restart
|
||||
```
|
||||
|
||||
**Can't reach Solar Network**:
|
||||
```bash
|
||||
# Check if running
|
||||
curl http://solar.local:5000
|
||||
|
||||
# Check /etc/hosts
|
||||
cat /etc/hosts | grep solar.local
|
||||
```
|
||||
|
||||
**Activities not arriving**:
|
||||
```bash
|
||||
# Check database
|
||||
psql -d dyson_network -c "SELECT * FROM fediverse_activities;"
|
||||
|
||||
# Check logs
|
||||
dotnet run --project DysonNetwork.Sphere | grep -i activitypub
|
||||
```
|
||||
|
||||
For detailed troubleshooting, see `ACTIVITYPUB_TESTING_GUIDE.md` Part 5.
|
||||
|
||||
## 📖 Learning Path
|
||||
|
||||
### For Developers
|
||||
1. Read `ACTIVITYPUB_IMPLEMENTATION.md` to understand the architecture
|
||||
2. Read `ACTIVITYPUB_SUMMARY.md` to see what's implemented
|
||||
3. Follow test scenarios in `ACTIVITYPUB_TESTING_GUIDE.md`
|
||||
4. Use helper API in `ACTIVITYPUB_TESTING_HELPER_API.md` for testing
|
||||
|
||||
### For Testers
|
||||
1. Start with `ACTIVITYPUB_TESTING_QUICKSTART.md`
|
||||
2. Use command reference in `ACTIVITYPUB_TESTING_QUICKREF.md`
|
||||
3. Track results with `ACTIVITYPUB_TESTING_RESULTS_TEMPLATE.md`
|
||||
4. Report issues with details from logs
|
||||
|
||||
## 🎓 Success Criteria
|
||||
|
||||
### Minimum Viable
|
||||
- WebFinger works
|
||||
- Actor profile valid
|
||||
- Follow relationships work
|
||||
- Posts federate correctly
|
||||
- HTTP signatures verified
|
||||
|
||||
### Production Ready
|
||||
- Activity queue with retry
|
||||
- Rate limiting
|
||||
- Monitoring/alerting
|
||||
- Admin interface
|
||||
- Instance blocking
|
||||
- Content moderation
|
||||
|
||||
## 🚨 Common Pitfalls
|
||||
|
||||
### Don't Forget
|
||||
- ✅ Update `/etc/hosts` with both instances
|
||||
- ✅ Run migrations before testing
|
||||
- ✅ Check both instances are accessible
|
||||
- ✅ Verify PostgreSQL is running
|
||||
- ✅ Check logs when something fails
|
||||
|
||||
### Watch Out For
|
||||
- ❌ Using `localhost` instead of `solar.local`
|
||||
- ❌ Forgetting to restart after config changes
|
||||
- ❌ Not waiting for Mastodon to start (2-5 minutes)
|
||||
- ❌ Ignoring CORS errors in browser testing
|
||||
- ❌ Testing with deleted/invisible posts
|
||||
|
||||
## 📚 Additional Resources
|
||||
|
||||
### Official Specs
|
||||
- [ActivityPub W3C](https://www.w3.org/TR/activitypub/)
|
||||
- [ActivityStreams](https://www.w3.org/TR/activitystreams-core/)
|
||||
- [HTTP Signatures](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures)
|
||||
|
||||
### Community Guides
|
||||
- [Mastodon Federation](https://docs.joinmastodon.org/admin/federation/)
|
||||
- [Federation Testing](https://docs.joinmastodon.org/spec/activitypub/)
|
||||
|
||||
### Tools
|
||||
- [ActivityPub Playground](https://swicth.github.io/activity-pub-playground/)
|
||||
- [FediTest](https://feditest.com/)
|
||||
|
||||
## 🆘 Support
|
||||
|
||||
If you encounter issues:
|
||||
|
||||
1. Check logs (both Solar Network and Mastodon)
|
||||
2. Review troubleshooting section in the guide
|
||||
3. Validate against success criteria
|
||||
4. Check database state with queries
|
||||
5. Review implementation docs
|
||||
|
||||
## ✨ Next Steps
|
||||
|
||||
After testing with self-hosted instance:
|
||||
|
||||
1. Get a public domain or use ngrok
|
||||
2. Update `ActivityPub:Domain` in appsettings.json
|
||||
3. Test with public Mastodon instances
|
||||
4. Add more ActivityPub features (queue, retry, etc.)
|
||||
5. Implement admin interface
|
||||
6. Add monitoring and metrics
|
||||
|
||||
## 📞 File Reference
|
||||
|
||||
All files are in the root of the DysonNetwork project:
|
||||
|
||||
```
|
||||
DysonNetwork/
|
||||
├── ACTIVITYPUB_TESTING_INDEX.md # Start here!
|
||||
├── ACTIVITYPUB_TESTING_QUICKSTART.md # Quick reference
|
||||
├── ACTIVITYPUB_TESTING_GUIDE.md # Full guide
|
||||
├── ACTIVITYPUB_TESTING_QUICKREF.md # Commands
|
||||
├── ACTIVITYPUB_TESTING_HELPER_API.md # Test API
|
||||
├── ACTIVITYPUB_TESTING_RESULTS_TEMPLATE.md
|
||||
├── setup-activitypub-test.sh # Setup script
|
||||
├── test-activitypub.sh # Test script
|
||||
└── .env.testing.example # Config template
|
||||
```
|
||||
|
||||
**Documentation files** (for reference):
|
||||
```
|
||||
DysonNetwork/
|
||||
├── ACTIVITYPUB_IMPLEMENTATION.md # How it's implemented
|
||||
├── ACTIVITYPUB_SUMMARY.md # Feature summary
|
||||
└── ACTIVITYPUB_PLAN.md # Original plan
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**Start here**: `ACTIVITYPUB_TESTING_INDEX.md`
|
||||
|
||||
**Good luck with your testing!** 🚀
|
||||
@@ -1,282 +0,0 @@
|
||||
# ActivityPub Testing Results Template
|
||||
|
||||
Use this template to track your testing progress.
|
||||
|
||||
## Test Environment
|
||||
|
||||
**Date**: ________________
|
||||
|
||||
**Test Configuration**:
|
||||
- Solar Network URL: `http://solar.local:5000`
|
||||
- Mastodon URL: `http://mastodon.local:3001`
|
||||
- Database: `dyson_network`
|
||||
|
||||
**Solar Network User**:
|
||||
- Username: `_______________`
|
||||
- Publisher ID: `_______________`
|
||||
|
||||
**Mastodon User**:
|
||||
- Username: `testuser@mastodon.local`
|
||||
- Password: `TestPassword123!`
|
||||
|
||||
---
|
||||
|
||||
## Test Results
|
||||
|
||||
### ✅ Part 1: Infrastructure Setup
|
||||
|
||||
| Test | Status | Notes |
|
||||
|------|--------|-------|
|
||||
| Setup script ran successfully | ☐ ☑ | |
|
||||
| /etc/hosts updated | ☐ ☑ | |
|
||||
| Docker containers started | ☐ ☑ | |
|
||||
| Mastodon web accessible | ☐ ☑ | |
|
||||
| Mastodon admin account created | ☐ ☑ | |
|
||||
| Database migrations applied | ☐ ☑ | |
|
||||
| Solar Network started | ☐ ☑ | |
|
||||
|
||||
### ✅ Part 2: WebFinger & Actor Discovery
|
||||
|
||||
| Test | Status | Expected | Actual |
|
||||
|------|--------|---------|--------|
|
||||
| WebFinger for Solar Network user | ☐ ☑ | Returns subject + links | _______________ |
|
||||
| Actor profile JSON is valid | ☐ ☑ | Has id, type, inbox, outbox | _______________ |
|
||||
| Public key present in actor | ☐ ☑ | publicKey.publicKeyPem exists | _______________ |
|
||||
| Outbox returns public posts | ☐ ☑ | OrderedCollection with items | _______________ |
|
||||
| Outbox totalItems count | ☐ ☑ | Matches public posts | _______________ |
|
||||
|
||||
### ✅ Part 3: Follow Relationships
|
||||
|
||||
| Test | Status | Expected Result | Actual Result |
|
||||
|------|--------|----------------|---------------|
|
||||
| Mastodon follows Solar Network user | ☐ ☑ | Relationship created in DB | _______________ |
|
||||
| Accept sent to Mastodon | ☐ ☑ | Mastodon receives Accept | _______________ |
|
||||
| Solar Network follows Mastodon user | ☐ ☑ | Relationship created | _______________ |
|
||||
| Follow appears in Mastodon UI | ☐ ☑ | Mastodon shows "Following" | _______________ |
|
||||
| Follow appears in Solar Network DB | ☐ ☑ | is_following = true | _______________ |
|
||||
| Follow state is Accepted | ☐ ☑ | state = 1 (Accepted) | _______________ |
|
||||
| Unfollow works correctly | ☐ ☑ | Relationship deleted/updated | _______________ |
|
||||
|
||||
### ✅ Part 4: Content Federation (Create)
|
||||
|
||||
| Test | Status | Expected Result | Actual Result |
|
||||
|------|--------|----------------|---------------|
|
||||
| Post created in Solar Network | ☐ ☑ | Post in sn_posts table | _______________ |
|
||||
| Activity sent to Mastodon | ☐ ☑ | Logged as successful | _______________ |
|
||||
| Post appears in Mastodon timeline | ☐ ☑ | Visible in federated timeline | _______________ |
|
||||
| Post content matches | ☐ ☑ | Same text/HTML | _______________ |
|
||||
| Post author is correct | ☐ ☑ | Shows Solar Network user | _______________ |
|
||||
| Post timestamp is correct | ☐ ☑ | Same published time | _______________ |
|
||||
| Multiple posts federate | ☐ ☑ | All posts appear | _______________ |
|
||||
|
||||
### ✅ Part 5: Content Reception (Incoming Create)
|
||||
|
||||
| Test | Status | Expected Result | Actual Result |
|
||||
|------|--------|----------------|---------------|
|
||||
| Create activity received | ☐ ☑ | Activity logged in DB | _______________ |
|
||||
| Content stored in fediverse_contents | ☐ ☑ | Record with correct type | _______________ |
|
||||
| Content not duplicated | ☐ ☑ | Only one entry per URI | _______________ |
|
||||
| Actor created/retrieved | ☐ ☑ | Actor in fediverse_actors | _______________ |
|
||||
| Instance created/retrieved | ☐ ☑ | Instance in fediverse_instances | _______________ |
|
||||
| Content HTML preserved | ☐ ☑ | contentHtml field populated | _______________ |
|
||||
|
||||
### ✅ Part 6: Reaction Federation (Like)
|
||||
|
||||
| Test | Status | Expected Result | Actual Result |
|
||||
|------|--------|----------------|---------------|
|
||||
| Like from Mastodon to Solar post | ☐ ☑ | Like activity received | _______________ |
|
||||
| Reaction stored in fediverse_reactions | ☐ ☑ | Record with type = 0 (Like) | _______________ |
|
||||
| Like count incremented | ☐ ☑ | like_count increased | _______________ |
|
||||
| Like appears in UI | ☐ ☑ | Visible on Solar Network | _______________ |
|
||||
| Like appears in Mastodon | ☐ ☑ | Visible on Mastodon | _______________ |
|
||||
| Unlike works correctly | ☐ ☑ | Like removed | _______________ |
|
||||
|
||||
### ✅ Part 7: Reply Federation
|
||||
|
||||
| Test | Status | Expected Result | Actual Result |
|
||||
|------|--------|----------------|---------------|
|
||||
| Reply from Mastodon to Solar post | ☐ ☑ | Create activity with inReplyTo | _______________ |
|
||||
| Reply stored with parent reference | ☐ ☑ | in_reply_to field set | _______________ |
|
||||
| Reply appears in Solar Network | ☐ ☑ | Visible as comment | _______________ |
|
||||
| Reply shows parent context | ☐ ☑ | Links to original post | _______________ |
|
||||
|
||||
### ✅ Part 8: Content Deletion
|
||||
|
||||
| Test | Status | Expected Result | Actual Result |
|
||||
|------|--------|----------------|---------------|
|
||||
| Delete from Mastodon | ☐ ☑ | Delete activity received | _______________ |
|
||||
| Content soft-deleted | ☐ ☑ | deleted_at timestamp set | _______________ |
|
||||
| Content no longer visible | ☐ ☑ | Hidden from timelines | _______________ |
|
||||
|
||||
### ✅ Part 9: HTTP Signature Verification
|
||||
|
||||
| Test | Status | Expected Result | Actual Result |
|
||||
|------|--------|----------------|---------------|
|
||||
| Valid signature accepted | ☐ ☑ | Activity processed | _______________ |
|
||||
| Invalid signature rejected | ☐ ☑ | 401 Unauthorized | _______________ |
|
||||
| Missing signature rejected | ☐ ☑ | 401 Unauthorized | _______________ |
|
||||
| Signature format correct | ☐ ☑ | keyId, algorithm, headers, signature | _______________ |
|
||||
| Signing string correct | ☐ ☑ | Matches HTTP-Signatures draft | _______________ |
|
||||
|
||||
### ✅ Part 10: Error Handling
|
||||
|
||||
| Test | Status | Expected Result | Actual Result |
|
||||
|------|--------|----------------|---------------|
|
||||
| Invalid activity type rejected | ☐ ☑ | 400 Bad Request | _______________ |
|
||||
| Malformed JSON rejected | ☐ ☑ | 400 Bad Request | _______________ |
|
||||
| Non-existent actor rejected | ☐ ☑ | 404 Not Found | _______________ |
|
||||
| Errors logged correctly | ☐ ☑ | error_message populated | _______________ |
|
||||
| Activity status = Failed | ☐ ☑ | status = 3 | _______________ |
|
||||
|
||||
---
|
||||
|
||||
## Database State After Tests
|
||||
|
||||
### Actors Table
|
||||
```sql
|
||||
SELECT COUNT(*) as total_actors,
|
||||
SUM(CASE WHEN is_local_actor THEN 1 ELSE 0 END) as local,
|
||||
SUM(CASE WHEN NOT is_local_actor THEN 1 ELSE 0 END) as remote
|
||||
FROM fediverse_relationships;
|
||||
```
|
||||
- Total Actors: _______________
|
||||
- Local Actors: _______________
|
||||
- Remote Actors: _______________
|
||||
|
||||
### Contents Table
|
||||
```sql
|
||||
SELECT COUNT(*) as total_contents,
|
||||
AVG(LENGTH(content)) as avg_content_length
|
||||
FROM fediverse_contents WHERE deleted_at IS NULL;
|
||||
```
|
||||
- Total Contents: _______________
|
||||
- Avg Content Length: _______________
|
||||
|
||||
### Activities Table
|
||||
```sql
|
||||
SELECT type, status, COUNT(*)
|
||||
FROM fediverse_activities
|
||||
GROUP BY type, status
|
||||
ORDER BY type, status;
|
||||
```
|
||||
- Activities by Type/Status:
|
||||
- Create: Pending ___, Completed ____, Failed ___
|
||||
- Follow: Pending ___, Completed ____, Failed ___
|
||||
- Like: Pending ___, Completed ____, Failed ___
|
||||
- Accept: Pending ___, Completed ____, Failed ___
|
||||
|
||||
### Relationships Table
|
||||
```sql
|
||||
SELECT state, COUNT(*) as count
|
||||
FROM fediverse_relationships
|
||||
GROUP BY state;
|
||||
```
|
||||
- Pending: _______________
|
||||
- Accepted: _______________
|
||||
- Rejected: _______________
|
||||
|
||||
---
|
||||
|
||||
## Logs Analysis
|
||||
|
||||
### Solar Network Errors Found:
|
||||
1. _______________
|
||||
2. _______________
|
||||
3. _______________
|
||||
|
||||
### Mastodon Errors Found:
|
||||
1. _______________
|
||||
2. _______________
|
||||
3. _______________
|
||||
|
||||
### Warnings Found:
|
||||
1. _______________
|
||||
2. _______________
|
||||
3. _______________
|
||||
|
||||
---
|
||||
|
||||
## Issues & Bugs Found
|
||||
|
||||
| # | Severity | Description | Status |
|
||||
|---|----------|-------------|--------|
|
||||
| 1 | ☐ Low/Medium/High/Critical | _____________________ | ☐ Open/☐ Fixed |
|
||||
| 2 | ☐ Low/Medium/High/Critical | _____________________ | ☐ Open/☐ Fixed |
|
||||
| 3 | ☐ Low/Medium/High/Critical | _____________________ | ☐ Open/☐ Fixed |
|
||||
| 4 | ☐ Low/Medium/High/Critical | _____________________ | ☐ Open/☐ Fixed |
|
||||
|
||||
---
|
||||
|
||||
## Performance Notes
|
||||
|
||||
| Metric | Value | Notes |
|
||||
|--------|-------|-------|
|
||||
| Average activity processing time | __________ ms | |
|
||||
| Average HTTP signature verification time | __________ ms | |
|
||||
| Outgoing delivery success rate | __________% | |
|
||||
| Average WebFinger response time | __________ ms | |
|
||||
| Database query performance | __________ | |
|
||||
|
||||
---
|
||||
|
||||
## Compatibility Notes
|
||||
|
||||
| Instance | Version | Works | Notes |
|
||||
|----------|---------|--------|-------|
|
||||
| Mastodon (self-hosted) | latest | ☐ ☑ | |
|
||||
| Mastodon.social | ~4.0 | ☐ ☑ | |
|
||||
| Pleroma | ~2.5 | ☐ ☑ | |
|
||||
| GoToSocial | ~0.15 | ☐ ☑ | |
|
||||
|
||||
---
|
||||
|
||||
## Recommendations
|
||||
|
||||
### What Worked Well:
|
||||
1. _____________________
|
||||
2. _____________________
|
||||
3. _____________________
|
||||
|
||||
### What Needs Improvement:
|
||||
1. _____________________
|
||||
2. _____________________
|
||||
3. _____________________
|
||||
|
||||
### Features to Add:
|
||||
1. _____________________
|
||||
2. _____________________
|
||||
3. _____________________
|
||||
|
||||
---
|
||||
|
||||
## Next Testing Phase
|
||||
|
||||
- [ ] Test with public Mastodon instance
|
||||
- [ ] Test with Pleroma instance
|
||||
- [ ] Test media attachment federation
|
||||
- [ ] Test with high-volume posts
|
||||
- [ ] Test concurrent activity processing
|
||||
- [ ] Test with different visibility levels
|
||||
- [ ] Test with long posts (>500 chars)
|
||||
- [ ] Test with special characters/emojis
|
||||
|
||||
---
|
||||
|
||||
## Sign-off
|
||||
|
||||
**Tested By**: _____________________
|
||||
|
||||
**Test Date**: _____________________
|
||||
|
||||
**Overall Result**: ☐ Pass / ☐ Fail
|
||||
|
||||
**Ready for Production**: ☐ Yes / ☐ No
|
||||
|
||||
**Notes**: ___________________________________________________________________________
|
||||
|
||||
__________________________________________________________________________
|
||||
|
||||
__________________________________________________________________________
|
||||
|
||||
__________________________________________________________________________
|
||||
|
||||
@@ -1,425 +0,0 @@
|
||||
# Follow Feature - User Guide
|
||||
|
||||
## Quick Start: How to Follow Fediverse Users
|
||||
|
||||
### Method 1: Via Search (Recommended)
|
||||
|
||||
1. Go to the search bar in Solar Network
|
||||
2. Type the user's full address: `@username@domain.com`
|
||||
- Example: `@alice@mastodon.social`
|
||||
- Example: `@bob@pleroma.site`
|
||||
3. Click on their profile in search results
|
||||
4. Click the "Follow" button
|
||||
5. Wait for acceptance (usually immediate)
|
||||
6. ✅ Done! Their posts will now appear in your timeline
|
||||
|
||||
### Method 2: Via Profile URL
|
||||
|
||||
1. If you know their profile URL, visit it directly:
|
||||
- Example: `https://mastodon.social/@alice`
|
||||
2. Look for the "Follow" button on their profile
|
||||
3. Click it to follow
|
||||
4. ✅ You're now following them!
|
||||
|
||||
## What Happens When You Follow Someone
|
||||
|
||||
### The Technical Flow
|
||||
```
|
||||
You click "Follow"
|
||||
↓
|
||||
Solar Network creates Follow Activity
|
||||
↓
|
||||
Follow Activity is signed with your private key
|
||||
↓
|
||||
Solar Network sends Follow to their instance's inbox
|
||||
↓
|
||||
Their instance verifies your signature
|
||||
↓
|
||||
Their instance processes the Follow
|
||||
↓
|
||||
Their instance sends Accept Activity back
|
||||
↓
|
||||
Solar Network receives and processes Accept
|
||||
↓
|
||||
Relationship is stored in database
|
||||
↓
|
||||
Their public posts federate to Solar Network
|
||||
```
|
||||
|
||||
### What You'll See
|
||||
|
||||
- ✅ **"Following..."** (while waiting for acceptance)
|
||||
- ✅ **"Following" ✓** (when accepted)
|
||||
- ✅ **Their posts** in your home timeline
|
||||
- ✅ **Their likes, replies, boosts** on your posts
|
||||
|
||||
## Different Types of Accounts
|
||||
|
||||
### Regular Users
|
||||
- Full ActivityPub support
|
||||
- Follows work both ways
|
||||
- Content federates normally
|
||||
- Example: `@alice@mastodon.social`
|
||||
|
||||
### Locked Accounts
|
||||
- User must manually approve followers
|
||||
- You'll see "Pending" after clicking follow
|
||||
- User receives notification to approve/deny
|
||||
- Example: `@private@pleroma.site`
|
||||
|
||||
### Bot/Service Accounts
|
||||
- Automated content accounts
|
||||
- Often auto-accept follows
|
||||
- Example: `@newsbot@botsin.space`
|
||||
|
||||
### Organizational Accounts
|
||||
- Group or team accounts
|
||||
- Example: `@team@company.social`
|
||||
|
||||
## Managing Your Follows
|
||||
|
||||
### View Who You're Following
|
||||
|
||||
**Go to**: Following page or `GET /api/activitypub/following`
|
||||
|
||||
You'll see:
|
||||
- Username
|
||||
- Display name
|
||||
- Profile picture
|
||||
- When you followed them
|
||||
- Their instance (e.g., "Mastodon")
|
||||
|
||||
### Unfollowing Someone
|
||||
|
||||
**Method 1: Via UI**
|
||||
1. Go to their profile
|
||||
2. Click "Following" button (shows as active)
|
||||
3. Click to unfollow
|
||||
|
||||
**Method 2: Via API**
|
||||
```bash
|
||||
curl -X POST http://solar.local:5000/api/activitypub/unfollow \
|
||||
-H "Authorization: Bearer YOUR_TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"targetActorUri": "https://mastodon.social/users/alice"
|
||||
}'
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Unfollowed successfully"
|
||||
}
|
||||
```
|
||||
|
||||
### View Your Followers
|
||||
|
||||
**Go to**: Followers page or `GET /api/activitypub/followers`
|
||||
|
||||
You'll see:
|
||||
- Users following you
|
||||
- Their instance
|
||||
- When they started following
|
||||
- Whether they're local or from another instance
|
||||
|
||||
## Searching Fediverse Users
|
||||
|
||||
### How Search Works
|
||||
|
||||
1. **Type in search bar**: `@username@domain.com`
|
||||
2. **Solar Network queries their instance**:
|
||||
- Fetches their actor profile
|
||||
- Checks if they're discoverable
|
||||
3. **Shows results**:
|
||||
- Profile picture
|
||||
- Display name
|
||||
- Bio
|
||||
- Instance name
|
||||
|
||||
### Supported Search Formats
|
||||
|
||||
| Format | Example | Works? |
|
||||
|--------|---------|--------|
|
||||
| Full handle | `@alice@mastodon.social` | ✅ Yes |
|
||||
| Username only | `alice` | ⚠️ May search local users first |
|
||||
| Full URL | `https://mastodon.social/@alice` | ✅ Yes |
|
||||
|
||||
## Privacy Considerations
|
||||
|
||||
### Public Posts
|
||||
- **What**: Posts visible to everyone
|
||||
- **Federation**: ✅ Federates to all followers
|
||||
- **Timeline**: Visible in public federated timelines
|
||||
- **Example**: General updates, thoughts, content you want to share
|
||||
|
||||
### Private Posts
|
||||
- **What**: Posts only visible to followers
|
||||
- **Federation**: ✅ Federates to followers (including remote)
|
||||
- **Timeline**: Only visible to your followers
|
||||
- **Example**: Personal updates, questions
|
||||
|
||||
### Unlisted Posts
|
||||
- **What**: Posts not in public timelines
|
||||
- **Federation**: ✅ Federates but marked unlisted
|
||||
- **Timeline**: Only followers see it
|
||||
- **Example**: Limited audience content
|
||||
|
||||
### Followers-Only Posts
|
||||
- **What**: Posts only to followers, no federated boost
|
||||
- **Federation**: ⚠️ May not federate fully
|
||||
- **Timeline**: Only your followers
|
||||
- **Example**: Very sensitive content
|
||||
|
||||
## Following Etiquette
|
||||
|
||||
### Best Practices
|
||||
|
||||
1. **Check before following**:
|
||||
- Read their bio and recent posts
|
||||
- Make sure they're who you think they are
|
||||
- Check if their content aligns with your interests
|
||||
|
||||
2. **Start with interactions**:
|
||||
- Like a few posts first
|
||||
- Reply thoughtfully
|
||||
- Share interesting content
|
||||
- Then follow if you want to see more
|
||||
|
||||
3. **Respect instance culture**:
|
||||
- Each instance has its own norms
|
||||
- Read their community guidelines
|
||||
- Be mindful of local rules
|
||||
|
||||
4. **Don't spam**:
|
||||
- Don't mass-follow users
|
||||
- Don't send unwanted DMs
|
||||
- Don't repeatedly like old posts
|
||||
|
||||
5. **Use appropriate post visibility**:
|
||||
- Public for general content
|
||||
- Unlisted for updates to followers
|
||||
- Private for sensitive topics
|
||||
|
||||
### Red Flags to Watch
|
||||
|
||||
1. **Suspicious accounts**:
|
||||
- Newly created with generic content
|
||||
- Only posting promotional links
|
||||
- Unusual following patterns
|
||||
|
||||
2. **Instances with poor moderation**:
|
||||
- Lots of spam in public timelines
|
||||
- Harassment goes unaddressed
|
||||
- You may want to block the instance
|
||||
|
||||
3. **Content warnings not respected**:
|
||||
- Users posting unmarked sensitive content
|
||||
- You can report/block these users
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Follow button doesn't work"
|
||||
|
||||
**Possible causes**:
|
||||
1. User doesn't exist
|
||||
2. Instance is down
|
||||
3. Network connectivity issue
|
||||
|
||||
**What to do**:
|
||||
1. Verify the username/domain is correct
|
||||
2. Try searching for them again
|
||||
3. Check your internet connection
|
||||
4. Try again in a few minutes
|
||||
|
||||
### "User doesn't appear in Following list"
|
||||
|
||||
**Possible causes**:
|
||||
1. Follow was rejected (locked account)
|
||||
2. Follow is still pending
|
||||
3. Error in federation
|
||||
|
||||
**What to do**:
|
||||
1. Check if their account is locked
|
||||
2. Wait a few minutes for acceptance
|
||||
3. Check your ActivityPub logs
|
||||
4. Try following again
|
||||
|
||||
### "Can't find a user via search"
|
||||
|
||||
**Possible causes**:
|
||||
1. Username/domain is wrong
|
||||
2. User's instance is blocking your instance
|
||||
3. User's profile is not discoverable
|
||||
|
||||
**What to do**:
|
||||
1. Double-check the spelling
|
||||
2. Try their full URL: `https://instance.com/@username`
|
||||
3. Check if they're from a blocked instance
|
||||
4. Contact them directly for their handle
|
||||
|
||||
## API Reference
|
||||
|
||||
### Follow a Remote User
|
||||
|
||||
**Endpoint**: `POST /api/activitypub/follow`
|
||||
|
||||
**Request**:
|
||||
```json
|
||||
{
|
||||
"targetActorUri": "https://mastodon.social/users/alice"
|
||||
}
|
||||
```
|
||||
|
||||
**Success Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Follow request sent. Waiting for acceptance.",
|
||||
"targetActorUri": "https://mastodon.social/users/alice"
|
||||
}
|
||||
```
|
||||
|
||||
### Get Your Following
|
||||
|
||||
**Endpoint**: `GET /api/activitypub/following?limit=50`
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"users": [
|
||||
{
|
||||
"actorUri": "https://mastodon.social/users/alice",
|
||||
"username": "alice",
|
||||
"displayName": "Alice Smith",
|
||||
"bio": "I love tech!",
|
||||
"avatarUrl": "https://...",
|
||||
"followedAt": "2024-01-15T10:30:00Z",
|
||||
"isLocal": false,
|
||||
"instanceDomain": "mastodon.social"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Get Your Followers
|
||||
|
||||
**Endpoint**: `GET /api/activitypub/followers?limit=50`
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"users": [
|
||||
{
|
||||
"actorUri": "https://pleroma.site/users/bob",
|
||||
"username": "bob",
|
||||
"displayName": "Bob Jones",
|
||||
"bio": "Federated user following me",
|
||||
"avatarUrl": "https://...",
|
||||
"followedAt": "2024-01-10T14:20:00Z",
|
||||
"isLocal": false,
|
||||
"instanceDomain": "pleroma.site"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Search Users
|
||||
|
||||
**Endpoint**: `GET /api/activitypub/search?query=@alice@domain.com&limit=20`
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"users": [
|
||||
{
|
||||
"actorUri": "https://mastodon.social/users/alice",
|
||||
"username": "alice",
|
||||
"displayName": "Alice Smith",
|
||||
"bio": "Tech enthusiast",
|
||||
"avatarUrl": "https://...",
|
||||
"isLocal": false,
|
||||
"instanceDomain": "mastodon.social"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Real Examples
|
||||
|
||||
### Example 1: Following a Mastodon User
|
||||
|
||||
**What you do**:
|
||||
1. Search for `@alice@mastodon.social`
|
||||
2. Click on Alice's profile
|
||||
3. Click "Follow" button
|
||||
4. Wait 1-2 seconds
|
||||
5. ✅ Alice appears in your "Following" list
|
||||
6. ✅ Alice's public posts appear in your timeline
|
||||
|
||||
**What happens technically**:
|
||||
- Solar Network sends Follow to Alice's Mastodon instance
|
||||
- Alice's Mastodon auto-accepts (unless locked)
|
||||
- Mastodon sends Accept back to Solar Network
|
||||
- Relationship stored in both databases
|
||||
- Alice's future posts federate to Solar Network
|
||||
|
||||
### Example 2: Following a Locked Account
|
||||
|
||||
**What you do**:
|
||||
1. Search for `@private@pleroma.site`
|
||||
2. Click "Follow" button
|
||||
3. ✅ See "Following..." (pending)
|
||||
4. Wait for user to approve
|
||||
|
||||
**What happens technically**:
|
||||
- Solar Network sends Follow to private@pleroma.site
|
||||
- Private user receives notification
|
||||
- Private user manually approves the request
|
||||
- Private user's instance sends Accept
|
||||
- ✅ Now following!
|
||||
|
||||
### Example 3: Following a Bot Account
|
||||
|
||||
**What you do**:
|
||||
1. Search for `@news@botsin.space`
|
||||
2. Click "Follow" button
|
||||
3. ✅ Immediately following (bots auto-accept)
|
||||
|
||||
**What happens technically**:
|
||||
- Follow is auto-accepted
|
||||
- News posts appear in your timeline
|
||||
- Regular updates from the bot
|
||||
|
||||
## Key Differences from Traditional Social Media
|
||||
|
||||
| Aspect | Traditional Social | ActivityPub |
|
||||
|---------|------------------|-------------|
|
||||
| Central server | ❌ No | ✅ Yes (per instance) |
|
||||
| Multiple platforms | ❌ No | ✅ Yes (Mastodon, Pleroma, etc.) |
|
||||
| Data ownership | ❌ On their servers | ✅ On your server |
|
||||
| Blocking | ❌ One platform | ✅ Per instance |
|
||||
| Migration | ❌ Difficult | ✅ Use your own domain |
|
||||
| Federation | ❌ No | ✅ Built-in |
|
||||
|
||||
## Getting Help
|
||||
|
||||
If you have issues following users:
|
||||
|
||||
1. **Check the main guide**: See `HOW_TO_FOLLOW_FEDIVERSE_USERS.md`
|
||||
2. **Check your logs**: Look for ActivityPub errors
|
||||
3. **Test the API**: Use curl to test follow endpoints directly
|
||||
4. **Verify the user**: Make sure the user exists on their instance
|
||||
|
||||
## Summary
|
||||
|
||||
Following fediverse users in Solar Network:
|
||||
|
||||
1. **Simple**: Just search and click "Follow"
|
||||
2. **Works both ways**: You can follow them, they can follow you
|
||||
3. **Works across instances**: Mastodon, Pleroma, Lemmy, etc.
|
||||
4. **Federated content**: Their posts appear in your timeline
|
||||
5. **Full interactions**: Like, reply, boost their posts
|
||||
|
||||
It works just like following on any other social platform, but with the added benefit of being able to follow users on completely different services! 🌍
|
||||
@@ -1,406 +0,0 @@
|
||||
# How to Follow (Subscribe to) Fediverse Users in Solar Network
|
||||
|
||||
## Overview
|
||||
|
||||
In ActivityPub terminology, "subscribing" to a user is called **"following"**. This guide explains how users in Solar Network can follow users from other federated services (Mastodon, Pleroma, etc.).
|
||||
|
||||
## User Guide: How to Follow Fediverse Users
|
||||
|
||||
### Method 1: Via Search (Recommended)
|
||||
|
||||
1. **Search for the user**:
|
||||
- Type their full address in the search bar: `@username@domain.com`
|
||||
- Example: `@alice@mastodon.social`
|
||||
- Example: `@bob@pleroma.site`
|
||||
|
||||
2. **View their profile**:
|
||||
- Click on the search result
|
||||
- You'll see their profile, bio, and recent posts
|
||||
|
||||
3. **Click "Follow" button**:
|
||||
- Solar Network sends a Follow activity to their instance
|
||||
- The remote instance will send back an Accept
|
||||
- The user now appears in your "Following" list
|
||||
|
||||
### Method 2: Via Profile URL
|
||||
|
||||
1. **Visit their profile directly**:
|
||||
- If you know their profile URL, visit it directly
|
||||
- Example: `https://mastodon.social/@alice`
|
||||
|
||||
2. **Look for "Follow" button**:
|
||||
- Click it to follow
|
||||
|
||||
3. **Confirm the follow**:
|
||||
- Solar Network will send the follow request
|
||||
- Wait for acceptance (usually immediate)
|
||||
|
||||
## What Happens Behind the Scenes
|
||||
|
||||
### The Follow Flow
|
||||
|
||||
```
|
||||
User clicks "Follow"
|
||||
↓
|
||||
Solar Network creates Follow Activity
|
||||
↓
|
||||
Solar Network signs with publisher's private key
|
||||
↓
|
||||
Solar Network sends to remote user's inbox
|
||||
↓
|
||||
Remote instance verifies signature
|
||||
↓
|
||||
Remote instance processes the Follow
|
||||
↓
|
||||
Remote instance sends Accept Activity back
|
||||
↓
|
||||
Solar Network receives and processes Accept
|
||||
↓
|
||||
Relationship is established!
|
||||
```
|
||||
|
||||
### Timeline Integration
|
||||
|
||||
Once you're following a user:
|
||||
- ✅ Their public posts appear in your "Home" timeline
|
||||
- ✅ Their posts are federated to your followers
|
||||
- ✅ Their likes, replies, and boosts are visible
|
||||
- ✅ You can interact with their content
|
||||
|
||||
## Following Different Types of Accounts
|
||||
|
||||
### Individual Users
|
||||
- **What**: Regular users like you
|
||||
- **Example**: `@alice@mastodon.social`
|
||||
- **Works**: ✅ Full support
|
||||
|
||||
### Organizational/Bot Accounts
|
||||
- **What**: Groups, bots, or organizations
|
||||
- **Example**: `@official@newsbot.site`
|
||||
- **Works**: ✅ Full support
|
||||
|
||||
### Locked Accounts
|
||||
- **What**: Users who manually approve followers
|
||||
- **Example**: `@private@pleroma.site`
|
||||
- **Works**: ✅ Follow request sent, waits for approval
|
||||
|
||||
## Managing Your Follows
|
||||
|
||||
### View Who You're Following
|
||||
|
||||
**API Endpoint**: `GET /api/activitypub/following`
|
||||
|
||||
**Response Example**:
|
||||
```json
|
||||
{
|
||||
"users": [
|
||||
{
|
||||
"actorUri": "https://mastodon.social/users/alice",
|
||||
"username": "alice",
|
||||
"displayName": "Alice Smith",
|
||||
"bio": "I love tech and coffee! ☕",
|
||||
"avatarUrl": "https://cdn.mastodon.social/avatars/...",
|
||||
"followedAt": "2024-01-15T10:30:00Z",
|
||||
"isLocal": false,
|
||||
"instanceDomain": "mastodon.social"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Unfollowing Someone
|
||||
|
||||
**API Endpoint**: `POST /api/activitypub/unfollow`
|
||||
|
||||
**Request Body**:
|
||||
```json
|
||||
{
|
||||
"targetActorUri": "https://mastodon.social/users/alice"
|
||||
}
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Unfollowed successfully"
|
||||
}
|
||||
```
|
||||
|
||||
## Searching Fediverse Users
|
||||
|
||||
**API Endpoint**: `GET /api/activitypub/search?query=@username@domain.com`
|
||||
|
||||
**Response Example**:
|
||||
```json
|
||||
{
|
||||
"users": [
|
||||
{
|
||||
"actorUri": "https://mastodon.social/users/alice",
|
||||
"username": "alice",
|
||||
"displayName": "Alice Smith",
|
||||
"bio": "Software developer | Mastodon user",
|
||||
"avatarUrl": "https://cdn.mastodon.social/avatars/...",
|
||||
"isLocal": false,
|
||||
"instanceDomain": "mastodon.social"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Follow States
|
||||
|
||||
| State | Meaning | What User Sees |
|
||||
|--------|---------|----------------|
|
||||
| Pending | Follow request sent, waiting for response | "Following..." (loading) |
|
||||
| Accepted | Remote user accepted | "Following" ✓ |
|
||||
| Rejected | Remote user declined | "Follow" button available again |
|
||||
| Failed | Error occurred | "Error following" message |
|
||||
|
||||
## Privacy & Visibility
|
||||
|
||||
### Public Posts
|
||||
- ✅ Federate to your followers automatically
|
||||
- ✅ Appear in remote instances' timelines
|
||||
- ✅ Can be boosted/liked by remote users
|
||||
|
||||
### Private Posts
|
||||
- ❌ Do not federate
|
||||
- ❌ Only visible to your local followers
|
||||
- ❌ Not sent to remote instances
|
||||
|
||||
### Unlisted Posts
|
||||
- ⚠️ Federate but not in public timelines
|
||||
- ⚠️ Only visible to followers
|
||||
|
||||
## Best Practices for Users
|
||||
|
||||
### When Following Someone
|
||||
|
||||
1. **Check their profile first**:
|
||||
- Make sure they're who you think they are
|
||||
- Read their bio to understand their content
|
||||
|
||||
2. **Start with a few interactions**:
|
||||
- Like a few posts
|
||||
- Reply to something interesting
|
||||
- Don't overwhelm their timeline
|
||||
|
||||
3. **Respect their instance's rules**:
|
||||
- Each instance has its own guidelines
|
||||
- Read community rules before interacting
|
||||
|
||||
4. **Report spam/harassment**:
|
||||
- Use instance blocking features
|
||||
- Report to instance admins
|
||||
|
||||
### Following Across Instances
|
||||
|
||||
1. **Use their full address**:
|
||||
- `@username@instance.com`
|
||||
- This helps identify which instance they're on
|
||||
|
||||
2. **Be aware of instance culture**:
|
||||
- Each instance has its own norms
|
||||
- Some are more technical, others more casual
|
||||
|
||||
3. **Check if they're from your instance**:
|
||||
- Local users show `isLocal: true`
|
||||
- Usually faster interaction
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "Follow button doesn't work"
|
||||
|
||||
**Possible Causes**:
|
||||
1. User doesn't exist
|
||||
2. Instance is down
|
||||
3. Network issue
|
||||
|
||||
**Solutions**:
|
||||
1. Verify the user's address is correct
|
||||
2. Check if the instance is accessible
|
||||
3. Check your internet connection
|
||||
4. Try again in a few minutes
|
||||
|
||||
### "User doesn't appear in Following list"
|
||||
|
||||
**Possible Causes**:
|
||||
1. Follow was rejected
|
||||
2. Still waiting for acceptance (locked accounts)
|
||||
3. Error in federation
|
||||
|
||||
**Solutions**:
|
||||
1. Check the follow status via API
|
||||
2. Try following again
|
||||
3. Check if their account is locked
|
||||
4. Contact support if issue persists
|
||||
|
||||
### "Can't find a user"
|
||||
|
||||
**Possible Causes**:
|
||||
1. Wrong username or domain
|
||||
2. User doesn't exist
|
||||
3. Instance blocking your instance
|
||||
|
||||
**Solutions**:
|
||||
1. Double-check the address
|
||||
2. Try searching from a different instance
|
||||
3. Contact the user directly for their handle
|
||||
|
||||
## API Reference
|
||||
|
||||
### Follow a Remote User
|
||||
|
||||
**Endpoint**: `POST /api/activitypub/follow`
|
||||
|
||||
**Request**:
|
||||
```json
|
||||
{
|
||||
"targetActorUri": "https://mastodon.social/users/alice"
|
||||
}
|
||||
```
|
||||
|
||||
**Response**: `200 OK`
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Follow request sent. Waiting for acceptance.",
|
||||
"targetActorUri": "https://mastodon.social/users/alice"
|
||||
}
|
||||
```
|
||||
|
||||
### Get Following List
|
||||
|
||||
**Endpoint**: `GET /api/activitypub/following?limit=50`
|
||||
|
||||
**Response**: `200 OK`
|
||||
```json
|
||||
{
|
||||
"users": [
|
||||
{
|
||||
"actorUri": "https://mastodon.social/users/alice",
|
||||
"username": "alice",
|
||||
"displayName": "Alice Smith",
|
||||
"bio": "...",
|
||||
"avatarUrl": "...",
|
||||
"followedAt": "2024-01-15T10:30:00Z",
|
||||
"isLocal": false,
|
||||
"instanceDomain": "mastodon.social"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Get Followers List
|
||||
|
||||
**Endpoint**: `GET /api/activitypub/followers?limit=50`
|
||||
|
||||
**Response**: `200 OK`
|
||||
```json
|
||||
{
|
||||
"users": [
|
||||
{
|
||||
"actorUri": "https://mastodon.social/users/alice",
|
||||
"username": "alice",
|
||||
"displayName": "Alice Smith",
|
||||
"bio": "...",
|
||||
"avatarUrl": "...",
|
||||
"isLocal": false,
|
||||
"instanceDomain": "mastodon.social"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Search Users
|
||||
|
||||
**Endpoint**: `GET /api/activitypub/search?query=alice&limit=20`
|
||||
|
||||
**Response**: `200 OK`
|
||||
```json
|
||||
{
|
||||
"users": [
|
||||
{
|
||||
"actorUri": "https://mastodon.social/users/alice",
|
||||
"username": "alice",
|
||||
"displayName": "Alice Smith",
|
||||
"bio": "...",
|
||||
"avatarUrl": "...",
|
||||
"isLocal": false,
|
||||
"instanceDomain": "mastodon.social"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## What's Different About ActivityPub Following?
|
||||
|
||||
Unlike traditional social media:
|
||||
|
||||
| Feature | Traditional Social | ActivityPub |
|
||||
|---------|------------------|-------------|
|
||||
| Central server | ✅ Yes | ❌ No - federated |
|
||||
| All users on same platform | ✅ Yes | ❌ No - multiple platforms |
|
||||
| Blocked instances | ❌ No | ✅ Yes - instance blocking |
|
||||
| Following across platforms | ❌ No | ✅ Yes - works with Mastodon, Pleroma, etc. |
|
||||
| Your data stays on your server | ❌ Maybe | ✅ Yes - you control your data |
|
||||
|
||||
## User Experience Considerations
|
||||
|
||||
### Making It Easy
|
||||
|
||||
1. **Auto-discovery**:
|
||||
- When users search for `@username`, suggest `@username@domain.com`
|
||||
- Offer to search the fediverse
|
||||
|
||||
2. **Clear UI feedback**:
|
||||
- Show "Follow request sent..."
|
||||
- Show "They accepted!" notification
|
||||
- Show "Follow request rejected" message
|
||||
|
||||
3. **Helpful tooltips**:
|
||||
- Explain what ActivityPub is
|
||||
- Show which instance a user is from
|
||||
- Explain locked accounts
|
||||
|
||||
4. **Profile badges**:
|
||||
- Show instance icon/logo
|
||||
- Show if user is from same instance
|
||||
- Show if user is verified
|
||||
|
||||
## Examples
|
||||
|
||||
### Following a Mastodon User
|
||||
|
||||
**User searches**: `@alice@mastodon.social`
|
||||
|
||||
**What happens**:
|
||||
1. Solar Network fetches Alice's actor profile
|
||||
2. Solar Network stores Alice in `fediverse_actors`
|
||||
3. Solar Network sends Follow to Alice's inbox
|
||||
4. Alice's instance accepts
|
||||
5. Solar Network stores relationship in `fediverse_relationships`
|
||||
6. Alice's posts now appear in user's timeline
|
||||
|
||||
### Following a Local User
|
||||
|
||||
**User searches**: `@bob`
|
||||
|
||||
**What happens**:
|
||||
1. Solar Network finds Bob's publisher
|
||||
2. Relationship created locally (no federation needed)
|
||||
3. Bob's posts appear in user's timeline immediately
|
||||
4. Same as traditional social media following
|
||||
|
||||
## Summary
|
||||
|
||||
Following fediverse users in Solar Network:
|
||||
|
||||
1. **Search by `@username@domain.com`** - Works for any ActivityPub instance
|
||||
2. **Click "Follow"** - Sends federated follow request
|
||||
3. **Wait for acceptance** - Remote user can approve or auto-accept
|
||||
4. **See their posts in your timeline** - Content federates to you
|
||||
5. **Interact normally** - Like, reply, boost, etc.
|
||||
|
||||
All of this is handled automatically by the ActivityPub implementation!
|
||||
@@ -1,298 +0,0 @@
|
||||
# ActivityPub UI Implementation
|
||||
|
||||
## Overview
|
||||
|
||||
Complete UI implementation for ActivityPub features in Solian client, including search, following, and followers screens.
|
||||
|
||||
## Created Files
|
||||
|
||||
### 1. Widgets (`lib/widgets/activitypub/`)
|
||||
|
||||
#### `activitypub.dart`
|
||||
- **Purpose**: Export file for ActivityPub widgets
|
||||
- **Exports**: `ActivityPubUserListItem`
|
||||
|
||||
#### `user_list_item.dart`
|
||||
- **Purpose**: Reusable list item widget for displaying ActivityPub users
|
||||
- **Features**:
|
||||
- Avatar with remote instance indicator (public icon)
|
||||
- Display name with instance badge (e.g., "mastodon.social")
|
||||
- Bio with truncation (max 2 lines)
|
||||
- Followed at timestamp (relative time)
|
||||
- Follow/Unfollow buttons with loading states
|
||||
- Tap callback for navigation to profile
|
||||
|
||||
### 2. Screens (`lib/screens/activitypub/`)
|
||||
|
||||
#### `activitypub.dart`
|
||||
- **Purpose**: Export file for ActivityPub screens
|
||||
- **Exports**: `ActivityPubSearchScreen`, `ActivityPubListScreen`
|
||||
|
||||
#### `search.dart`
|
||||
- **Purpose**: Search and follow ActivityPub users from other instances
|
||||
- **Features**:
|
||||
- Search bar with 500ms debounce
|
||||
- Real-time search results
|
||||
- Instant follow/unfollow actions
|
||||
- Local tracking of followed users
|
||||
- Empty states for no search and no results
|
||||
- Refresh support via pull-to-refresh
|
||||
- User feedback via snack bars
|
||||
- **User Flow**:
|
||||
1. User enters search query (e.g., `@alice@mastodon.social`)
|
||||
2. Results appear after debounce
|
||||
3. User taps "Follow" → Follow request sent
|
||||
4. Success message shown
|
||||
5. Button updates to "Unfollow"
|
||||
|
||||
#### `list.dart`
|
||||
- **Purpose**: Display following/followers lists
|
||||
- **Features**:
|
||||
- Reusable for both Following and Followers
|
||||
- Local state management
|
||||
- Per-user loading states during actions
|
||||
- Empty states with helpful hints
|
||||
- Refresh support
|
||||
- Auto-update lists when actions occur
|
||||
- **Types**:
|
||||
- `ActivityPubListType.following`: Shows users you follow
|
||||
- `ActivityPubListType.followers`: Shows users who follow you
|
||||
- **User Flow**:
|
||||
1. User opens Following/Followers screen
|
||||
2. List loads from API
|
||||
3. User can unfollow (Following tab) or follow (Followers tab)
|
||||
4. List updates automatically
|
||||
5. Success/error messages shown
|
||||
|
||||
## Design Patterns
|
||||
|
||||
### Follows Project Conventions
|
||||
|
||||
1. **Material 3 Design**: All widgets use Material 3 components
|
||||
2. **Styled Widget Package**: Used for `.padding()`, `.textColor()`, etc.
|
||||
3. **Riverpod State Management**: Hooks for local state, providers for global state
|
||||
4. **Error Handling**: `showErrorAlert()` from `alert.dart` for user feedback
|
||||
5. **Success Feedback**: `showSnackBar()` for quick notifications
|
||||
6. **Localization**: All strings use `.tr()` with placeholder args
|
||||
|
||||
### Color Scheme & Theming
|
||||
|
||||
- **Remote Badge**: Uses `Theme.colorScheme.primary` for indicator
|
||||
- **Instance Tag**: Uses `Theme.colorScheme.secondaryContainer`
|
||||
- **Text Colors**: Adaptive based on theme (dark/light)
|
||||
- **States**: Loading indicators with standard `CircularProgressIndicator`
|
||||
|
||||
### Spacing & Layout
|
||||
|
||||
- **List Item Padding**: `EdgeInsets.only(left: 16, right: 12)`
|
||||
- **Avatar Size**: 24px radius (48px diameter)
|
||||
- **Badge Size**: Small (10px font) with 6px horizontal padding
|
||||
- **Button Size**: Minimum 88px width, 36px height
|
||||
|
||||
## Translations Added
|
||||
|
||||
### New Keys in `assets/i18n/en-US.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"searchFediverse": "Search Fediverse",
|
||||
"searchFediverseHint": "Search by address, e.g. {}",
|
||||
"searchFediverseEmpty": "Search for users on other ActivityPub instances",
|
||||
"searchFediverseNoResults": "No users found for this search",
|
||||
"following": "Following",
|
||||
"followers": "Followers",
|
||||
"follow": "Follow",
|
||||
"unfollow": "Unfollow",
|
||||
"followedUser": "Followed @{}",
|
||||
"unfollowedUser": "Unfollowed @{}",
|
||||
"followingEmpty": "You're not following anyone yet",
|
||||
"followersEmpty": "No followers yet",
|
||||
"followingEmptyHint": "Start by searching for users or explore other instances"
|
||||
}
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Using Search Screen
|
||||
|
||||
```dart
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:island/screens/activitypub/activitypub.dart';
|
||||
|
||||
// In navigation or route
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const ActivityPubSearchScreen(),
|
||||
),
|
||||
);
|
||||
|
||||
// Or using go_router
|
||||
context.push('/activitypub/search');
|
||||
```
|
||||
|
||||
### Using List Screen
|
||||
|
||||
```dart
|
||||
// Following
|
||||
ActivityPubListScreen(
|
||||
type: ActivityPubListType.following,
|
||||
);
|
||||
|
||||
// Followers
|
||||
ActivityPubListScreen(
|
||||
type: ActivityPubListType.followers,
|
||||
);
|
||||
```
|
||||
|
||||
### Using User List Item Widget
|
||||
|
||||
```dart
|
||||
ActivityPubUserListItem(
|
||||
user: user,
|
||||
isFollowing: isFollowing,
|
||||
isLoading: isLoading,
|
||||
onFollow: () => handleFollow(user),
|
||||
onUnfollow: () => handleUnfollow(user),
|
||||
onTap: () => navigateToProfile(user),
|
||||
);
|
||||
```
|
||||
|
||||
## Integration Points
|
||||
|
||||
### Navigation Integration
|
||||
|
||||
To add ActivityPub screens to navigation:
|
||||
|
||||
1. **Option A**: Add to existing tab/navigation structure
|
||||
2. **Option B**: Add as standalone routes in `go_router`
|
||||
3. **Option C**: Add to profile menu overflow menu
|
||||
|
||||
### Service Integration
|
||||
|
||||
All screens use `activityPubServiceProvider`:
|
||||
|
||||
```dart
|
||||
import 'package:island/services/activitypub_service.dart';
|
||||
|
||||
final service = ref.read(activityPubServiceProvider);
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
|
||||
All errors are caught and displayed using:
|
||||
|
||||
```dart
|
||||
try {
|
||||
// API call
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
}
|
||||
```
|
||||
|
||||
## Testing Checklist
|
||||
|
||||
- [ ] Search for existing Mastodon user
|
||||
- [ ] Search for Pleroma user
|
||||
- [ ] Follow a user
|
||||
- [ ] Unfollow a user
|
||||
- [ ] View following list
|
||||
- [ ] View followers list
|
||||
- [ ] Test empty states
|
||||
- [ ] Test loading states
|
||||
- [ ] Test error handling
|
||||
- [ ] Test dark mode
|
||||
- [ ] Test RTL languages (if supported)
|
||||
|
||||
## Technical Details
|
||||
|
||||
### Dependencies
|
||||
|
||||
**Already in project**:
|
||||
- ✅ `cached_network_image` - For avatar images
|
||||
- ✅ `easy_localization` - For translations
|
||||
- ✅ `hooks_riverpod` - For state management
|
||||
- ✅ `flutter_hooks` - For hooks (useState, useEffect, etc.)
|
||||
- ✅ `material_symbols_icons` - For icons
|
||||
- ✅ `relative_time` - For timestamp formatting
|
||||
- ✅ `island/services/activitypub_service.dart` - API service (created earlier)
|
||||
- ✅ `island/widgets/alert.dart` - Error/success dialogs
|
||||
- ✅ `island/models/activitypub.dart` - Data models (created earlier)
|
||||
|
||||
### Performance Considerations
|
||||
|
||||
1. **Debounced Search**: 500ms delay prevents excessive API calls
|
||||
2. **Local State Tracking**: `followingUris` Set prevents duplicate API calls
|
||||
3. **Conditional Rebuilds**: Widget only rebuilds when necessary
|
||||
4. **Image Caching**: Uses `CachedNetworkImageProvider` for avatars
|
||||
|
||||
### Accessibility
|
||||
|
||||
1. **Semantic Labels**: All ListTile widgets have proper content
|
||||
2. **Touch Targets**: Minimum 44px touch targets for buttons
|
||||
3. **Color Contrast**: Follows Material 3 color guidelines
|
||||
4. **Loading Indicators**: Visual feedback during async operations
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
### Potential Additions
|
||||
|
||||
1. **Profile Integration**: Show ActivityPub profile details
|
||||
2. **Post Timeline**: Show federated posts from followed users
|
||||
3. **Instance Blocking**: Block entire ActivityPub instances
|
||||
4. **Advanced Search**: Filter by instance, user type, etc.
|
||||
5. **Batch Actions**: Follow/unfollow multiple users at once
|
||||
6. **Suggested Users**: Show recommended users to follow
|
||||
7. **Recent Activity**: Show recent interactions
|
||||
8. **Notifications**: Follow/unfollow notifications
|
||||
|
||||
### Localization
|
||||
|
||||
Need to add same keys to other language files:
|
||||
- `es-ES.json`
|
||||
- `ja-JP.json`
|
||||
- `ko-KR.json`
|
||||
- etc.
|
||||
|
||||
## Browser Testing
|
||||
|
||||
Test with real ActivityPub instances:
|
||||
- mastodon.social
|
||||
- pixelfed.social
|
||||
- lemmy.world
|
||||
- pleroma.site
|
||||
- fosstodon.org
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
1. **Search returns no results**
|
||||
- Check if user exists on remote instance
|
||||
- Verify instance is accessible
|
||||
- Try full URL instead of handle
|
||||
|
||||
2. **Follow button not working**
|
||||
- Check if user is already following
|
||||
- Verify server is online
|
||||
- Check API logs
|
||||
|
||||
3. **Avatar not loading**
|
||||
- Check remote avatar URL
|
||||
- Verify network connection
|
||||
- Check image cache
|
||||
|
||||
## Summary
|
||||
|
||||
✅ **Fully functional ActivityPub UI** with:
|
||||
- Search screen for discovering fediverse users
|
||||
- Following/Followers list screens
|
||||
- Reusable user list item component
|
||||
- Proper error handling and user feedback
|
||||
- Material 3 design
|
||||
- Responsive layout
|
||||
- Local state management
|
||||
- Debounced search
|
||||
- Empty states and loading indicators
|
||||
|
||||
**Ready for integration into main app navigation!** 🎉
|
||||
@@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 54;
|
||||
objectVersion = 77;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@@ -11,6 +11,9 @@
|
||||
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
5D8143680678FCD1D1827271 /* Pods_Solian_Watch_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9C046CF867AE03DC170F861 /* Pods_Solian_Watch_App.framework */; };
|
||||
7301DB032F08D99C008390F3 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7301DB022F08D99C008390F3 /* WidgetKit.framework */; };
|
||||
7301DB052F08D99C008390F3 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7301DB042F08D99C008390F3 /* SwiftUI.framework */; };
|
||||
7301DB102F08D99D008390F3 /* SolianWidgetExtensionExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 7301DB012F08D99C008390F3 /* SolianWidgetExtensionExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
7310A7DF2EB10963002C0FD3 /* Solian Watch App.app in Embed Watch Content */ = {isa = PBXBuildFile; fileRef = 7310A7D42EB10962002C0FD3 /* Solian Watch App.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
73ACDFAD2E3D0E6100B63535 /* ReplayKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73ACDFAC2E3D0E6100B63535 /* ReplayKit.framework */; };
|
||||
73ACDFC32E3D0E6100B63535 /* SolianBroadcastExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 73ACDFAB2E3D0E6100B63535 /* SolianBroadcastExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
@@ -36,6 +39,13 @@
|
||||
remoteGlobalIDString = 97C146ED1CF9000F007C117D;
|
||||
remoteInfo = Runner;
|
||||
};
|
||||
7301DB0E2F08D99D008390F3 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 97C146E61CF9000F007C117D /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 7301DB002F08D99C008390F3;
|
||||
remoteInfo = SolianWidgetExtensionExtension;
|
||||
};
|
||||
73ACDFC12E3D0E6100B63535 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 97C146E61CF9000F007C117D /* Project object */;
|
||||
@@ -77,6 +87,7 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 13;
|
||||
files = (
|
||||
7301DB102F08D99D008390F3 /* SolianWidgetExtensionExtension.appex in Embed Foundation Extensions */,
|
||||
73ACDFC32E3D0E6100B63535 /* SolianBroadcastExtension.appex in Embed Foundation Extensions */,
|
||||
73C305D82E0BE878009035B9 /* SolianShareExtension.appex in Embed Foundation Extensions */,
|
||||
73CDD6812DEC00480059D95D /* SolianNotificationService.appex in Embed Foundation Extensions */,
|
||||
@@ -117,6 +128,10 @@
|
||||
39FE4CC6223F0D3C0E1FFD04 /* Pods_SolianNotificationService.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SolianNotificationService.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3A1C47BD29CC6AC2587D4DBE /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
7301DB012F08D99C008390F3 /* SolianWidgetExtensionExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SolianWidgetExtensionExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
7301DB022F08D99C008390F3 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; };
|
||||
7301DB042F08D99C008390F3 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; };
|
||||
7301DB162F08D9A5008390F3 /* SolianWidgetExtensionExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SolianWidgetExtensionExtension.entitlements; sourceTree = "<group>"; };
|
||||
7310A7D42EB10962002C0FD3 /* Solian Watch App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Solian Watch App.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
737E920B2DB6A9FF00BE9CDB /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
|
||||
73ACDFAB2E3D0E6100B63535 /* SolianBroadcastExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SolianBroadcastExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@@ -151,6 +166,13 @@
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
7301DB142F08D99D008390F3 /* Exceptions for "SolianWidgetExtension" folder in "SolianWidgetExtensionExtension" target */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
Info.plist,
|
||||
);
|
||||
target = 7301DB002F08D99C008390F3 /* SolianWidgetExtensionExtension */;
|
||||
};
|
||||
73ACDFCA2E3D0E6100B63535 /* Exceptions for "SolianBroadcastExtension" folder in "SolianBroadcastExtension" target */ = {
|
||||
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
|
||||
membershipExceptions = (
|
||||
@@ -177,16 +199,23 @@
|
||||
membershipExceptions = (
|
||||
CloudFile.swift,
|
||||
DataExchange.swift,
|
||||
GroupDefaultSync.swift,
|
||||
);
|
||||
target = 73CDD6792DEC00480059D95D /* SolianNotificationService */;
|
||||
};
|
||||
/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
|
||||
|
||||
/* Begin PBXFileSystemSynchronizedRootGroup section */
|
||||
7310A7D52EB10962002C0FD3 /* Solian Watch App */ = {
|
||||
7301DB062F08D99C008390F3 /* SolianWidgetExtension */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
exceptions = (
|
||||
7301DB142F08D99D008390F3 /* Exceptions for "SolianWidgetExtension" folder in "SolianWidgetExtensionExtension" target */,
|
||||
);
|
||||
path = SolianWidgetExtension;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7310A7D52EB10962002C0FD3 /* Solian Watch App */ = {
|
||||
isa = PBXFileSystemSynchronizedRootGroup;
|
||||
path = "Solian Watch App";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
@@ -233,6 +262,15 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
7301DAFE2F08D99C008390F3 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7301DB052F08D99C008390F3 /* SwiftUI.framework in Frameworks */,
|
||||
7301DB032F08D99C008390F3 /* WidgetKit.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
7310A7D12EB10962002C0FD3 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -295,6 +333,8 @@
|
||||
73ACDFAC2E3D0E6100B63535 /* ReplayKit.framework */,
|
||||
73ACDFB82E3D0E6100B63535 /* UIKit.framework */,
|
||||
C9C046CF867AE03DC170F861 /* Pods_Solian_Watch_App.framework */,
|
||||
7301DB022F08D99C008390F3 /* WidgetKit.framework */,
|
||||
7301DB042F08D99C008390F3 /* SwiftUI.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
@@ -341,12 +381,14 @@
|
||||
97C146E51CF9000F007C117D = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
7301DB162F08D9A5008390F3 /* SolianWidgetExtensionExtension.entitlements */,
|
||||
9740EEB11CF90186004384FC /* Flutter */,
|
||||
97C146F01CF9000F007C117D /* Runner */,
|
||||
73CDD67B2DEC00480059D95D /* SolianNotificationService */,
|
||||
73C305CF2E0BE878009035B9 /* SolianShareExtension */,
|
||||
73ACDFAE2E3D0E6100B63535 /* SolianBroadcastExtension */,
|
||||
7310A7D52EB10962002C0FD3 /* Solian Watch App */,
|
||||
7301DB062F08D99C008390F3 /* SolianWidgetExtension */,
|
||||
97C146EF1CF9000F007C117D /* Products */,
|
||||
331C8082294A63A400263BE5 /* RunnerTests */,
|
||||
91E124CE95BCB4DCD890160D /* Pods */,
|
||||
@@ -364,6 +406,7 @@
|
||||
73C305CE2E0BE878009035B9 /* SolianShareExtension.appex */,
|
||||
73ACDFAB2E3D0E6100B63535 /* SolianBroadcastExtension.appex */,
|
||||
7310A7D42EB10962002C0FD3 /* Solian Watch App.app */,
|
||||
7301DB012F08D99C008390F3 /* SolianWidgetExtensionExtension.appex */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -408,6 +451,26 @@
|
||||
productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
7301DB002F08D99C008390F3 /* SolianWidgetExtensionExtension */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 7301DB152F08D99D008390F3 /* Build configuration list for PBXNativeTarget "SolianWidgetExtensionExtension" */;
|
||||
buildPhases = (
|
||||
7301DAFD2F08D99C008390F3 /* Sources */,
|
||||
7301DAFE2F08D99C008390F3 /* Frameworks */,
|
||||
7301DAFF2F08D99C008390F3 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
fileSystemSynchronizedGroups = (
|
||||
7301DB062F08D99C008390F3 /* SolianWidgetExtension */,
|
||||
);
|
||||
name = SolianWidgetExtensionExtension;
|
||||
productName = SolianWidgetExtensionExtension;
|
||||
productReference = 7301DB012F08D99C008390F3 /* SolianWidgetExtensionExtension.appex */;
|
||||
productType = "com.apple.product-type.app-extension";
|
||||
};
|
||||
7310A7D32EB10962002C0FD3 /* Solian Watch App */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 7310A7E32EB10963002C0FD3 /* Build configuration list for PBXNativeTarget "Solian Watch App" */;
|
||||
@@ -515,6 +578,7 @@
|
||||
73CDD6802DEC00480059D95D /* PBXTargetDependency */,
|
||||
73C305D72E0BE878009035B9 /* PBXTargetDependency */,
|
||||
73ACDFC22E3D0E6100B63535 /* PBXTargetDependency */,
|
||||
7301DB0F2F08D99D008390F3 /* PBXTargetDependency */,
|
||||
);
|
||||
fileSystemSynchronizedGroups = (
|
||||
73268D272DEB012A0076E970 /* Services */,
|
||||
@@ -531,7 +595,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
BuildIndependentTargetsInParallel = YES;
|
||||
LastSwiftUpdateCheck = 2600;
|
||||
LastSwiftUpdateCheck = 2620;
|
||||
LastUpgradeCheck = 1510;
|
||||
ORGANIZATIONNAME = "";
|
||||
TargetAttributes = {
|
||||
@@ -539,6 +603,9 @@
|
||||
CreatedOnToolsVersion = 14.0;
|
||||
TestTargetID = 97C146ED1CF9000F007C117D;
|
||||
};
|
||||
7301DB002F08D99C008390F3 = {
|
||||
CreatedOnToolsVersion = 26.2;
|
||||
};
|
||||
7310A7D32EB10962002C0FD3 = {
|
||||
CreatedOnToolsVersion = 26.0.1;
|
||||
};
|
||||
@@ -563,6 +630,11 @@
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
"zh-Hans",
|
||||
es,
|
||||
ja,
|
||||
ko,
|
||||
"zh-Hant",
|
||||
);
|
||||
mainGroup = 97C146E51CF9000F007C117D;
|
||||
preferredProjectObjectVersion = 77;
|
||||
@@ -576,6 +648,7 @@
|
||||
73C305CD2E0BE878009035B9 /* SolianShareExtension */,
|
||||
73ACDFAA2E3D0E6100B63535 /* SolianBroadcastExtension */,
|
||||
7310A7D32EB10962002C0FD3 /* Solian Watch App */,
|
||||
7301DB002F08D99C008390F3 /* SolianWidgetExtensionExtension */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
@@ -588,6 +661,13 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
7301DAFF2F08D99C008390F3 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
7310A7D22EB10962002C0FD3 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -677,10 +757,14 @@
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
|
||||
@@ -738,10 +822,14 @@
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
|
||||
@@ -792,10 +880,14 @@
|
||||
inputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Solian Watch App/Pods-Solian Watch App-frameworks-${CONFIGURATION}-input-files.xcfilelist",
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputFileListPaths = (
|
||||
"${PODS_ROOT}/Target Support Files/Pods-Solian Watch App/Pods-Solian Watch App-frameworks-${CONFIGURATION}-output-files.xcfilelist",
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Solian Watch App/Pods-Solian Watch App-frameworks.sh\"\n";
|
||||
@@ -852,6 +944,13 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
7301DAFD2F08D99C008390F3 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
7310A7D02EB10962002C0FD3 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -898,6 +997,11 @@
|
||||
target = 97C146ED1CF9000F007C117D /* Runner */;
|
||||
targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */;
|
||||
};
|
||||
7301DB0F2F08D99D008390F3 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 7301DB002F08D99C008390F3 /* SolianWidgetExtensionExtension */;
|
||||
targetProxy = 7301DB0E2F08D99D008390F3 /* PBXContainerItemProxy */;
|
||||
};
|
||||
73ACDFC22E3D0E6100B63535 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 73ACDFAA2E3D0E6100B63535 /* SolianBroadcastExtension */;
|
||||
@@ -1080,6 +1184,138 @@
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
7301DB112F08D99D008390F3 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = SolianWidgetExtensionExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = W7HPZ53V6B;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = SolianWidgetExtension/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = SolianWidgetExtension;
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.solsynth.solian.SolianWidgetExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
|
||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
7301DB122F08D99D008390F3 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = SolianWidgetExtensionExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = W7HPZ53V6B;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = SolianWidgetExtension/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = SolianWidgetExtension;
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.solsynth.solian.SolianWidgetExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
7301DB132F08D99D008390F3 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
|
||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||
ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground;
|
||||
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
|
||||
CLANG_ENABLE_OBJC_WEAK = YES;
|
||||
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
|
||||
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
|
||||
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
|
||||
CODE_SIGN_ENTITLEMENTS = SolianWidgetExtensionExtension.entitlements;
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEVELOPMENT_TEAM = W7HPZ53V6B;
|
||||
ENABLE_USER_SCRIPT_SANDBOXING = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu17;
|
||||
GENERATE_INFOPLIST_FILE = YES;
|
||||
INFOPLIST_FILE = SolianWidgetExtension/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = SolianWidgetExtension;
|
||||
INFOPLIST_KEY_NSHumanReadableCopyright = "";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
|
||||
MARKETING_VERSION = 1.0;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = dev.solsynth.solian.SolianWidgetExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_APPROACHABLE_CONCURRENCY = YES;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
name = Profile;
|
||||
};
|
||||
7310A7E02EB10963002C0FD3 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 31EA49B10397BD4145AD765E /* Pods-Solian Watch App.debug.xcconfig */;
|
||||
@@ -1785,6 +2021,16 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
7301DB152F08D99D008390F3 /* Build configuration list for PBXNativeTarget "SolianWidgetExtensionExtension" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
7301DB112F08D99D008390F3 /* Debug */,
|
||||
7301DB122F08D99D008390F3 /* Release */,
|
||||
7301DB132F08D99D008390F3 /* Profile */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
7310A7E32EB10963002C0FD3 /* Build configuration list for PBXNativeTarget "Solian Watch App" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2620"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7310A7D32EB10962002C0FD3"
|
||||
BuildableName = "Solian Watch App.app"
|
||||
BlueprintName = "Solian Watch App"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7310A7D32EB10962002C0FD3"
|
||||
BuildableName = "Solian Watch App.app"
|
||||
BlueprintName = "Solian Watch App"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7310A7D32EB10962002C0FD3"
|
||||
BuildableName = "Solian Watch App.app"
|
||||
BlueprintName = "Solian Watch App"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2620"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "73ACDFAA2E3D0E6100B63535"
|
||||
BuildableName = "SolianBroadcastExtension.appex"
|
||||
BlueprintName = "SolianBroadcastExtension"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
askForAppToLaunch = "Yes"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
askForAppToLaunch = "Yes"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2620"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "73CDD6792DEC00480059D95D"
|
||||
BuildableName = "SolianNotificationService.appex"
|
||||
BlueprintName = "SolianNotificationService"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
askForAppToLaunch = "Yes"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
askForAppToLaunch = "Yes"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2620"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "73C305CD2E0BE878009035B9"
|
||||
BuildableName = "SolianShareExtension.appex"
|
||||
BlueprintName = "SolianShareExtension"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
askForAppToLaunch = "Yes"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
askForAppToLaunch = "Yes"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "2620"
|
||||
wasCreatedForAppExtension = "YES"
|
||||
version = "2.0">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES"
|
||||
buildArchitectures = "Automatic">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7301DB002F08D99C008390F3"
|
||||
BuildableName = "SolianWidgetExtensionExtension.appex"
|
||||
BlueprintName = "SolianWidgetExtensionExtension"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "7310A7D32EB10962002C0FD3"
|
||||
BuildableName = "Solian Watch App.app"
|
||||
BlueprintName = "Solian Watch App"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = ""
|
||||
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
|
||||
launchStyle = "0"
|
||||
askForAppToLaunch = "Yes"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<EnvironmentVariables>
|
||||
<EnvironmentVariable
|
||||
key = "_XCWidgetKind"
|
||||
value = ""
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "_XCWidgetDefaultView"
|
||||
value = "timeline"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "_XCWidgetFamily"
|
||||
value = "systemMedium"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
</EnvironmentVariables>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
askForAppToLaunch = "Yes"
|
||||
launchAutomaticallySubstyle = "2">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "97C146ED1CF9000F007C117D"
|
||||
BuildableName = "Runner.app"
|
||||
BlueprintName = "Runner"
|
||||
ReferencedContainer = "container:Runner.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,4 +1,5 @@
|
||||
import Flutter
|
||||
import WidgetKit
|
||||
import UIKit
|
||||
import WatchConnectivity
|
||||
|
||||
@@ -11,6 +12,9 @@ import WatchConnectivity
|
||||
_ application: UIApplication,
|
||||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
||||
) -> Bool {
|
||||
syncDefaultsToGroup()
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
|
||||
UNUserNotificationCenter.current().delegate = notifyDelegate
|
||||
|
||||
let replyableMessageCategory = UNNotificationCategory(
|
||||
@@ -29,6 +33,9 @@ import WatchConnectivity
|
||||
|
||||
GeneratedPluginRegistrant.register(with: self)
|
||||
|
||||
// Setup widget sync method channel
|
||||
setupWidgetSyncChannel()
|
||||
|
||||
// Always initialize and retain a strong reference
|
||||
if WCSession.isSupported() {
|
||||
AppDelegate.sharedWatchConnectivityService = WatchConnectivityService.shared
|
||||
@@ -38,6 +45,30 @@ import WatchConnectivity
|
||||
|
||||
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||
}
|
||||
|
||||
private func setupWidgetSyncChannel() {
|
||||
let controller = window?.rootViewController as? FlutterViewController
|
||||
let channel = FlutterMethodChannel(name: "dev.solsynth.solian/widget", binaryMessenger: controller!.binaryMessenger)
|
||||
|
||||
channel.setMethodCallHandler { [weak self] (call, result) in
|
||||
if call.method == "syncToWidget" {
|
||||
syncDefaultsToGroup()
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
result(true)
|
||||
} else {
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func applicationDidEnterBackground(_ application: UIApplication) {
|
||||
syncDefaultsToGroup()
|
||||
WidgetCenter.shared.reloadAllTimelines()
|
||||
}
|
||||
|
||||
override func applicationWillTerminate(_ application: UIApplication) {
|
||||
syncDefaultsToGroup()
|
||||
}
|
||||
}
|
||||
|
||||
final class WatchConnectivityService: NSObject, WCSessionDelegate {
|
||||
|
||||
41
ios/Runner/Services/GroupDefaultSync.swift
Normal file
41
ios/Runner/Services/GroupDefaultSync.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// GroupDefaultSync.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by LittleSheep on 2026/1/3.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
private let flutterKeyPrefix = "flutter."
|
||||
|
||||
private let flutterKeysToSync: [String] = [
|
||||
"dyn_user_tk",
|
||||
"app_server_url"
|
||||
]
|
||||
|
||||
func syncDefaultsToGroup() {
|
||||
print("[iOS] syncDefaultsToGroup() called")
|
||||
|
||||
let standard = UserDefaults.standard
|
||||
let shared = UserDefaults(suiteName: "group.solsynth.solian")
|
||||
|
||||
guard let shared else {
|
||||
print("[iOS] App Group UserDefaults not available")
|
||||
return
|
||||
}
|
||||
|
||||
for key in flutterKeysToSync {
|
||||
let prefixedKey = key.starts(with: flutterKeyPrefix) ? key : flutterKeyPrefix + key
|
||||
|
||||
if let value = standard.object(forKey: prefixedKey) {
|
||||
print("[iOS] Syncing key to App Group: \(prefixedKey)")
|
||||
shared.set(value, forKey: prefixedKey)
|
||||
} else {
|
||||
print("[iOS] Key \(prefixedKey) was not found in the app data, skipping...")
|
||||
}
|
||||
}
|
||||
|
||||
shared.synchronize()
|
||||
print("[iOS] Sync completed")
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "icon.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "dark"
|
||||
}
|
||||
],
|
||||
"filename" : "icon-dark.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
},
|
||||
{
|
||||
"appearances" : [
|
||||
{
|
||||
"appearance" : "luminosity",
|
||||
"value" : "tinted"
|
||||
}
|
||||
],
|
||||
"filename" : "icon 1.png",
|
||||
"idiom" : "universal",
|
||||
"platform" : "ios",
|
||||
"size" : "1024x1024"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
21
ios/SolianWidgetExtension/Assets.xcassets/CloudyLamb.imageset/Contents.json
vendored
Normal file
21
ios/SolianWidgetExtension/Assets.xcassets/CloudyLamb.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "icon.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
ios/SolianWidgetExtension/Assets.xcassets/CloudyLamb.imageset/icon.png
vendored
Normal file
BIN
ios/SolianWidgetExtension/Assets.xcassets/CloudyLamb.imageset/icon.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
21
ios/SolianWidgetExtension/Assets.xcassets/CloudyLambDark.imageset/Contents.json
vendored
Normal file
21
ios/SolianWidgetExtension/Assets.xcassets/CloudyLambDark.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "icon-dark.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
ios/SolianWidgetExtension/Assets.xcassets/CloudyLambDark.imageset/icon-dark.png
vendored
Normal file
BIN
ios/SolianWidgetExtension/Assets.xcassets/CloudyLambDark.imageset/icon-dark.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
6
ios/SolianWidgetExtension/Assets.xcassets/Contents.json
Normal file
6
ios/SolianWidgetExtension/Assets.xcassets/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"colors" : [
|
||||
{
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
11
ios/SolianWidgetExtension/Info.plist
Normal file
11
ios/SolianWidgetExtension/Info.plist
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.widgetkit-extension</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
711
ios/SolianWidgetExtension/SolianCheckInWidget.swift
Normal file
711
ios/SolianWidgetExtension/SolianCheckInWidget.swift
Normal file
@@ -0,0 +1,711 @@
|
||||
//
|
||||
// SolianWidgetExtension.swift
|
||||
// SolianWidgetExtension
|
||||
//
|
||||
// Created by LittleSheep on 2026/1/3.
|
||||
//
|
||||
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
struct CheckInTip: Codable {
|
||||
let isPositive: Bool
|
||||
let title: String
|
||||
let content: String
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case isPositive = "is_positive"
|
||||
case title
|
||||
case content
|
||||
}
|
||||
}
|
||||
|
||||
struct CheckInAccount: Codable {
|
||||
let id: String
|
||||
let nick: String?
|
||||
let profile: CheckInProfile?
|
||||
}
|
||||
|
||||
struct CheckInProfile: Codable {
|
||||
let picture: String?
|
||||
}
|
||||
|
||||
struct CheckInResult: Codable {
|
||||
let id: String
|
||||
let level: Int
|
||||
let rewardPoints: Int
|
||||
let rewardExperience: Int
|
||||
let tips: [CheckInTip]
|
||||
let accountId: String
|
||||
let account: CheckInAccount?
|
||||
let createdAt: String
|
||||
let updatedAt: String
|
||||
let deletedAt: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case level
|
||||
case rewardPoints = "reward_points"
|
||||
case rewardExperience = "reward_experience"
|
||||
case tips
|
||||
case accountId = "account_id"
|
||||
case account
|
||||
case createdAt = "created_at"
|
||||
case updatedAt = "updated_at"
|
||||
case deletedAt = "deleted_at"
|
||||
}
|
||||
|
||||
var createdDate: Date? {
|
||||
ISO8601DateFormatter().date(from: createdAt)
|
||||
}
|
||||
}
|
||||
|
||||
struct NotableDay: Codable {
|
||||
let date: String
|
||||
let localName: String
|
||||
let globalName: String
|
||||
let countryCode: String?
|
||||
let localizableKey: String?
|
||||
let holidays: [Int]?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case date
|
||||
case localName = "local_name"
|
||||
case globalName = "global_name"
|
||||
case countryCode = "country_code"
|
||||
case localizableKey = "localizable_key"
|
||||
case holidays
|
||||
}
|
||||
|
||||
var notableDate: Date? {
|
||||
ISO8601DateFormatter().date(from: date)
|
||||
}
|
||||
|
||||
var isToday: Bool {
|
||||
guard let notableDate = notableDate else { return false }
|
||||
let calendar = Calendar.current
|
||||
return calendar.isDateInToday(notableDate)
|
||||
}
|
||||
}
|
||||
|
||||
class CheckInService {
|
||||
private let networkService = WidgetNetworkService()
|
||||
|
||||
func fetchCheckInResult() async throws -> CheckInResult? {
|
||||
return try await networkService.makeRequest(path: "/pass/accounts/me/check-in")
|
||||
}
|
||||
}
|
||||
|
||||
class NotableDayService {
|
||||
private let networkService = WidgetNetworkService()
|
||||
|
||||
func fetchRecentNotableDay() async throws -> NotableDay? {
|
||||
print("[WidgetKit] [NotableDayService] Fetching recent notable day...")
|
||||
do {
|
||||
let result: [NotableDay]? = try await networkService.makeRequest(path: "/pass/notable/me/recent")
|
||||
print("[WidgetKit] [NotableDayService] Result: \(String(describing: result))")
|
||||
|
||||
guard let result = result else {
|
||||
print("[WidgetKit] [NotableDayService] Result is nil")
|
||||
return nil
|
||||
}
|
||||
|
||||
print("[WidgetKit] [NotableDayService] Result count: \(result.count)")
|
||||
|
||||
guard result.isEmpty == false else {
|
||||
print("[WidgetKit] [NotableDayService] No notable days found")
|
||||
return nil
|
||||
}
|
||||
|
||||
let firstDay = result.first!
|
||||
print("[WidgetKit] [NotableDayService] First notable day: \(firstDay.localName), date: \(firstDay.date)")
|
||||
|
||||
return firstDay
|
||||
} catch let decodingError as DecodingError {
|
||||
print("[WidgetKit] [NotableDayService] Decoding error, trying as single object...")
|
||||
print("[WidgetKit] [NotableDayService] Error: \(decodingError.localizedDescription)")
|
||||
|
||||
switch decodingError {
|
||||
case .typeMismatch(let type, let context):
|
||||
print("[WidgetKit] [NotableDayService] Type mismatch: expected \(type), context: \(context.debugDescription)")
|
||||
case .valueNotFound(let type, let context):
|
||||
print("[WidgetKit] [NotableDayService] Value not found: type \(type), context: \(context.debugDescription)")
|
||||
case .keyNotFound(let key, let context):
|
||||
print("[WidgetKit] [NotableDayService] Key not found: \(key), context: \(context.debugDescription)")
|
||||
case .dataCorrupted(let context):
|
||||
print("[WidgetKit] [NotableDayService] Data corrupted: \(context.debugDescription)")
|
||||
@unknown default:
|
||||
print("[WidgetKit] [NotableDayService] Unknown decoding error")
|
||||
}
|
||||
|
||||
do {
|
||||
let singleResult: NotableDay? = try await networkService.makeRequest(path: "/pass/notable/me/recent")
|
||||
print("[WidgetKit] [NotableDayService] Single object decode succeeded: \(singleResult?.localName ?? "nil")")
|
||||
return singleResult
|
||||
} catch {
|
||||
print("[WidgetKit] [NotableDayService] Single object decode also failed: \(error.localizedDescription)")
|
||||
throw decodingError
|
||||
}
|
||||
} catch {
|
||||
print("[WidgetKit] [NotableDayService] Error fetching notable day: \(error.localizedDescription)")
|
||||
print("[WidgetKit] [NotableDayService] Error type: \(type(of: error))")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CheckInEntry: TimelineEntry {
|
||||
let date: Date
|
||||
let result: CheckInResult?
|
||||
let notableDay: NotableDay?
|
||||
let error: String?
|
||||
let isLoading: Bool
|
||||
|
||||
static func placeholder() -> CheckInEntry {
|
||||
CheckInEntry(date: Date(), result: nil, notableDay: nil, error: nil, isLoading: true)
|
||||
}
|
||||
}
|
||||
|
||||
struct Provider: TimelineProvider {
|
||||
private let apiService = CheckInService()
|
||||
|
||||
func placeholder(in context: Context) -> CheckInEntry {
|
||||
CheckInEntry.placeholder()
|
||||
}
|
||||
|
||||
func getSnapshot(in context: Context, completion: @escaping (CheckInEntry) -> ()) {
|
||||
Task {
|
||||
print("[WidgetKit] [Provider] Getting snapshot...")
|
||||
async let checkInResult = try? await apiService.fetchCheckInResult()
|
||||
async let notableDay = try? await NotableDayService().fetchRecentNotableDay()
|
||||
|
||||
let result = try? await checkInResult
|
||||
let day = try? await notableDay
|
||||
|
||||
print("[WidgetKit] [Provider] Snapshot - CheckIn: \(result != nil ? "Found" : "Not found"), NotableDay: \(day != nil ? "Found" : "Not found")")
|
||||
|
||||
let entry = CheckInEntry(date: Date(), result: result, notableDay: day, error: nil, isLoading: false)
|
||||
completion(entry)
|
||||
}
|
||||
}
|
||||
|
||||
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
|
||||
Task {
|
||||
let currentDate = Date()
|
||||
print("[WidgetKit] [Provider] Getting timeline at \(currentDate)...")
|
||||
|
||||
do {
|
||||
async let checkInResult = try await apiService.fetchCheckInResult()
|
||||
async let notableDay = try await NotableDayService().fetchRecentNotableDay()
|
||||
|
||||
let result = try await checkInResult
|
||||
let day = try await notableDay
|
||||
|
||||
print("[WidgetKit] [Provider] Timeline - CheckIn: \(result != nil ? "Found" : "Not found"), NotableDay: \(day != nil ? "Found" : "Not found")")
|
||||
|
||||
let entry = CheckInEntry(date: currentDate, result: result, notableDay: day, error: nil, isLoading: false)
|
||||
|
||||
let nextUpdateDate: Date
|
||||
if let result = result, let createdDate = result.createdDate {
|
||||
let calendar = Calendar.current
|
||||
if let tomorrow = calendar.date(byAdding: .day, value: 1, to: createdDate) {
|
||||
nextUpdateDate = min(tomorrow, calendar.date(byAdding: .hour, value: 1, to: currentDate)!)
|
||||
} else {
|
||||
nextUpdateDate = calendar.date(byAdding: .hour, value: 1, to: currentDate)!
|
||||
}
|
||||
} else {
|
||||
nextUpdateDate = Calendar.current.date(byAdding: .minute, value: 30, to: currentDate)!
|
||||
}
|
||||
|
||||
print("[WidgetKit] [Provider] Next update at: \(nextUpdateDate)")
|
||||
let timeline = Timeline(entries: [entry], policy: .after(nextUpdateDate))
|
||||
completion(timeline)
|
||||
} catch {
|
||||
print("[WidgetKit] [Provider] Error in getTimeline: \(error.localizedDescription)")
|
||||
let entry = CheckInEntry(date: currentDate, result: nil, notableDay: nil, error: error.localizedDescription, isLoading: false)
|
||||
let nextUpdate = Calendar.current.date(byAdding: .minute, value: 10, to: currentDate)!
|
||||
let timeline = Timeline(entries: [entry], policy: .after(nextUpdate))
|
||||
completion(timeline)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CheckInWidgetEntryView: View {
|
||||
var entry: Provider.Entry
|
||||
@Environment(\.widgetFamily) var family
|
||||
|
||||
var body: some View {
|
||||
if let result = entry.result {
|
||||
CheckedInView(result: result, notableDay: entry.notableDay)
|
||||
} else if entry.isLoading {
|
||||
LoadingView()
|
||||
} else if let error = entry.error {
|
||||
ErrorView(error: error)
|
||||
} else {
|
||||
NotCheckedInView(notableDay: entry.notableDay)
|
||||
}
|
||||
}
|
||||
|
||||
private func getLevelName(for level: Int) -> String {
|
||||
let key = "checkInResultT\(level)"
|
||||
return NSLocalizedString(key, comment: "Check-in result level name")
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func NotableDayView(notableDay: NotableDay) -> some View {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
if !notableDay.isToday {
|
||||
Text(NSLocalizedString("notableDayUpcoming", comment: "Upcoming"))
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
HStack(spacing: isAccessory ? 8 : 6) {
|
||||
Image(systemName: "sparkles")
|
||||
.foregroundColor(.orange)
|
||||
.font(isAccessory ? .caption : .subheadline)
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
if notableDay.isToday {
|
||||
Text(String(format: NSLocalizedString("notableDayToday", comment: "{name} is today!"), notableDay.localName))
|
||||
.font(isAccessory ? .caption : .footnote)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.primary)
|
||||
.lineLimit(2)
|
||||
} else {
|
||||
if let notableDate = notableDay.notableDate {
|
||||
let dateString = isCompact ? formatDateCompact(notableDate) : formatDateRegular(notableDate)
|
||||
Text(String(format: NSLocalizedString("notableDayIs", comment: "{date} is {name}"), dateString, notableDay.localName))
|
||||
.font(isAccessory ? .caption : .footnote)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.primary)
|
||||
.lineLimit(2)
|
||||
} else {
|
||||
Text(notableDay.localName)
|
||||
.font(isAccessory ? .caption : .footnote)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.primary)
|
||||
.lineLimit(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if notableDay.isToday && !isAccessory {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "star.fill")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.orange)
|
||||
Text(NSLocalizedString("today", comment: "Today"))
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var isCompact: Bool {
|
||||
family == .systemSmall || isAccessory
|
||||
}
|
||||
|
||||
private func formatDateCompact(_ date: Date) -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "M/d"
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
|
||||
private func formatDateRegular(_ date: Date) -> String {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "MMM d, yyyy"
|
||||
return formatter.string(from: date)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func CheckedInView(result: CheckInResult, notableDay: NotableDay?) -> some View {
|
||||
Link(destination: URL(string: "solian://dashboard")!) {
|
||||
VStack(alignment: .leading, spacing: isAccessory ? 2 : 8) {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "flame.fill")
|
||||
.foregroundColor(.orange)
|
||||
.font(isAccessory ? .caption : .title3)
|
||||
Text(getLevelName(for: result.level))
|
||||
.font(isAccessory ? .caption2 : .headline)
|
||||
.fontWeight(.bold)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if !result.tips.isEmpty {
|
||||
if isAccessory {
|
||||
let positiveTips = result.tips.filter { $0.isPositive }
|
||||
let negativeTips = result.tips.filter { !$0.isPositive }
|
||||
|
||||
HStack(spacing: 2) {
|
||||
if let positiveTip = positiveTips.first {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "hand.thumbsup.fill")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
Text(positiveTip.title)
|
||||
.font(.caption2)
|
||||
.foregroundColor(.primary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
if let negativeTip = negativeTips.first {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "hand.thumbsdown.fill")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
Text(negativeTip.title)
|
||||
.font(.caption2)
|
||||
.foregroundColor(.primary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
} else if family == .systemSmall {
|
||||
let positiveTips = result.tips.filter { $0.isPositive }
|
||||
let negativeTips = result.tips.filter { !$0.isPositive }
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
if let positiveTip = positiveTips.first {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "hand.thumbsup.fill")
|
||||
.font(.caption)
|
||||
.foregroundColor(.green.opacity(0.8))
|
||||
Text(positiveTip.title)
|
||||
.font(.caption)
|
||||
.foregroundColor(.primary)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
if let negativeTip = negativeTips.first {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "hand.thumbsdown.fill")
|
||||
.font(.caption)
|
||||
.foregroundColor(.red.opacity(0.8))
|
||||
Text(negativeTip.title)
|
||||
.font(.caption)
|
||||
.foregroundColor(.primary)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let positiveTips = result.tips.filter { $0.isPositive }
|
||||
let negativeTips = result.tips.filter { !$0.isPositive }
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
if !positiveTips.isEmpty {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "hand.thumbsup.fill")
|
||||
.font(.caption)
|
||||
.foregroundColor(.green.opacity(0.8))
|
||||
ForEach(Array(positiveTips.prefix(3)), id: \.title) { tip in
|
||||
Text(tip.title)
|
||||
.font(.caption)
|
||||
.foregroundColor(.primary)
|
||||
if tip.title != positiveTips.last?.title {
|
||||
Text("•")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
if !negativeTips.isEmpty {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "hand.thumbsdown.fill")
|
||||
.font(.caption)
|
||||
.foregroundColor(.red.opacity(0.8))
|
||||
ForEach(Array(negativeTips.prefix(3)), id: \.title) { tip in
|
||||
Text(tip.title)
|
||||
.font(.caption)
|
||||
.foregroundColor(.primary)
|
||||
if tip.title != negativeTips.last?.title {
|
||||
Text("•")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if !isAccessory && family != .systemSmall {
|
||||
Text("No fortune today")
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
|
||||
if let notableDay = notableDay {
|
||||
NotableDayView(notableDay: notableDay)
|
||||
}
|
||||
|
||||
if family == .systemLarge {
|
||||
Spacer()
|
||||
WidgetFooter()
|
||||
|
||||
}
|
||||
}
|
||||
.padding(isAccessory ? 0 : (family == .systemSmall ? 6 : 12))
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func WidgetFooter() -> some View {
|
||||
HStack {
|
||||
Text("Solian")
|
||||
.font(.caption2)
|
||||
.fontWeight(.medium)
|
||||
.foregroundColor(.secondary)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
private var isAccessory: Bool {
|
||||
if #available(iOS 16.0, *) {
|
||||
if case .accessoryRectangular = family {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func NotCheckedInView(notableDay: NotableDay?) -> some View {
|
||||
Link(destination: URL(string: "solian://dashboard")!) {
|
||||
VStack(alignment: .leading, spacing: isAccessory ? 2 : 8) {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "flame.fill")
|
||||
.foregroundColor(.secondary)
|
||||
.font(isAccessory ? .caption : .title3)
|
||||
Text(NSLocalizedString("checkIn", comment: "Check In"))
|
||||
.font(isAccessory ? .caption2 : .headline)
|
||||
.fontWeight(.bold)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if !isAccessory {
|
||||
Text(NSLocalizedString("tapToCheckIn", comment: "Tap to check in today"))
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
if let notableDay = notableDay {
|
||||
NotableDayView(notableDay: notableDay)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
WidgetFooter()
|
||||
} else if let notableDay = notableDay {
|
||||
NotableDayView(notableDay: notableDay)
|
||||
}
|
||||
}
|
||||
.padding(isAccessory ? 0 : (family == .systemSmall ? 6 : 12))
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func LoadingView() -> some View {
|
||||
VStack(alignment: .leading, spacing: isAccessory ? 2 : 8) {
|
||||
HStack(spacing: 4) {
|
||||
ProgressView()
|
||||
.scaleEffect(isAccessory ? 0.6 : 0.8)
|
||||
Text(NSLocalizedString("loading", comment: "Loading..."))
|
||||
.font(isAccessory ? .caption2 : .caption)
|
||||
.foregroundColor(.secondary)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if !isAccessory {
|
||||
Spacer()
|
||||
WidgetFooter()
|
||||
}
|
||||
}
|
||||
.padding(isAccessory ? 0 : 12)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func ErrorView(error: String) -> some View {
|
||||
Link(destination: URL(string: "solian://dashboard")!) {
|
||||
VStack(alignment: .leading, spacing: isAccessory ? 2 : 8) {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "exclamationmark.triangle")
|
||||
.foregroundColor(.secondary)
|
||||
.font(isAccessory ? .caption : .title3)
|
||||
Text(NSLocalizedString("error", comment: "Error"))
|
||||
.font(isAccessory ? .caption2 : .headline)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if !isAccessory {
|
||||
Text(NSLocalizedString("openAppToRefresh", comment: "Open app to refresh"))
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text(error)
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(nil)
|
||||
.multilineTextAlignment(.leading)
|
||||
|
||||
Spacer()
|
||||
|
||||
WidgetFooter()
|
||||
}
|
||||
}
|
||||
.padding(isAccessory ? 0 : (family == .systemSmall ? 6 : 12))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CheckInWidgetRootView: View {
|
||||
var entry: Provider.Entry
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
var body: some View {
|
||||
if #available(iOS 17.0, *) {
|
||||
ZStack {
|
||||
CheckInWidgetEntryView(entry: entry)
|
||||
|
||||
if entry.result != nil || entry.notableDay != nil {
|
||||
GeometryReader { geometry in
|
||||
Image(colorScheme == .dark ? "CloudyLambDark" : "CloudyLamb")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(
|
||||
width: geometry.size.width * 0.9,
|
||||
height: geometry.size.width * 0.9
|
||||
)
|
||||
.opacity(0.18)
|
||||
.mask(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color.white,
|
||||
Color.white,
|
||||
Color.clear
|
||||
]),
|
||||
startPoint: .topLeading,
|
||||
endPoint: .bottomTrailing
|
||||
)
|
||||
)
|
||||
.position(
|
||||
x: geometry.size.width * 0.9,
|
||||
y: 20
|
||||
)
|
||||
}
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
}
|
||||
.containerBackground(.fill.tertiary, for: .widget)
|
||||
.padding(.vertical, 8)
|
||||
} else {
|
||||
CheckInWidgetEntryView(entry: entry)
|
||||
.padding()
|
||||
.background()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SolianCheckInWidget: Widget {
|
||||
let kind: String = "SolianCheckInWidget"
|
||||
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind, provider: Provider()) { entry in
|
||||
CheckInWidgetRootView(entry: entry)
|
||||
}
|
||||
.configurationDisplayName("Check In")
|
||||
.description("View your daily check-in status")
|
||||
.supportedFamilies(supportedFamilies)
|
||||
}
|
||||
|
||||
private var supportedFamilies: [WidgetFamily] {
|
||||
#if os(iOS)
|
||||
return [.systemSmall, .systemMedium, .systemLarge, .accessoryRectangular]
|
||||
#else
|
||||
return [.systemSmall, .systemMedium, .systemLarge]
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#Preview(as: .systemSmall) {
|
||||
SolianCheckInWidget()
|
||||
} timeline: {
|
||||
CheckInEntry(date: .now, result: nil, notableDay: nil, error: nil, isLoading: false)
|
||||
}
|
||||
|
||||
#Preview(as: .systemMedium) {
|
||||
SolianCheckInWidget()
|
||||
} timeline: {
|
||||
CheckInEntry(
|
||||
date: .now,
|
||||
result: CheckInResult(
|
||||
id: "test-id",
|
||||
level: 2,
|
||||
rewardPoints: 10,
|
||||
rewardExperience: 100,
|
||||
tips: [
|
||||
CheckInTip(isPositive: true, title: "Good Luck", content: "Great day"),
|
||||
CheckInTip(isPositive: true, title: "Creative", content: "Inspiration"),
|
||||
CheckInTip(isPositive: false, title: "Shopping", content: "Expensive")
|
||||
],
|
||||
accountId: "account-id",
|
||||
account: nil,
|
||||
createdAt: ISO8601DateFormatter().string(from: Date()),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
),
|
||||
notableDay: NotableDay(
|
||||
date: ISO8601DateFormatter().string(from: Calendar.current.date(byAdding: .day, value: 5, to: Date())!),
|
||||
localName: "Christmas",
|
||||
globalName: "Christmas",
|
||||
countryCode: nil,
|
||||
localizableKey: nil,
|
||||
holidays: []
|
||||
),
|
||||
error: nil,
|
||||
isLoading: false
|
||||
)
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
#Preview(as: .accessoryRectangular) {
|
||||
SolianCheckInWidget()
|
||||
} timeline: {
|
||||
CheckInEntry(
|
||||
date: .now,
|
||||
result: CheckInResult(
|
||||
id: "test-id",
|
||||
level: 4,
|
||||
rewardPoints: 50,
|
||||
rewardExperience: 500,
|
||||
tips: [
|
||||
CheckInTip(isPositive: true, title: "Lucky", content: "Great fortune"),
|
||||
CheckInTip(isPositive: true, title: "Success", content: "Opportunity")
|
||||
],
|
||||
accountId: "account-id",
|
||||
account: nil,
|
||||
createdAt: ISO8601DateFormatter().string(from: Date()),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
),
|
||||
notableDay: NotableDay(
|
||||
date: ISO8601DateFormatter().string(from: Date()),
|
||||
localName: "New Year",
|
||||
globalName: "New Year",
|
||||
countryCode: nil,
|
||||
localizableKey: nil,
|
||||
holidays: []
|
||||
),
|
||||
error: nil,
|
||||
isLoading: false
|
||||
)
|
||||
}
|
||||
#endif
|
||||
849
ios/SolianWidgetExtension/SolianNotificationWidget.swift
Normal file
849
ios/SolianWidgetExtension/SolianNotificationWidget.swift
Normal file
@@ -0,0 +1,849 @@
|
||||
//
|
||||
// SolianNotificationWidget.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by LittleSheep on 2026/1/4.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
// MARK: - Notification Widget
|
||||
|
||||
struct NotificationMeta: Codable {
|
||||
let pfp: String?
|
||||
let images: [String]?
|
||||
let actionUri: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case pfp
|
||||
case images
|
||||
case actionUri = "action_uri"
|
||||
}
|
||||
}
|
||||
|
||||
struct SnNotification: Codable, Identifiable {
|
||||
let id: String
|
||||
let topic: String
|
||||
let title: String
|
||||
let subtitle: String
|
||||
let content: String
|
||||
let meta: NotificationMeta?
|
||||
let priority: Int
|
||||
let viewedAt: String?
|
||||
let accountId: String
|
||||
let createdAt: String
|
||||
let updatedAt: String
|
||||
let deletedAt: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case topic
|
||||
case title
|
||||
case subtitle
|
||||
case content
|
||||
case meta
|
||||
case priority
|
||||
case viewedAt = "viewed_at"
|
||||
case accountId = "account_id"
|
||||
case createdAt = "created_at"
|
||||
case updatedAt = "updated_at"
|
||||
case deletedAt = "deleted_at"
|
||||
}
|
||||
|
||||
var createdDate: Date? {
|
||||
ISO8601DateFormatter().date(from: createdAt)
|
||||
}
|
||||
|
||||
var isUnread: Bool {
|
||||
return viewedAt == nil
|
||||
}
|
||||
|
||||
func getTopicIcon() -> String {
|
||||
switch topic {
|
||||
case "post.replies":
|
||||
return "arrow.uturn.backward"
|
||||
case "wallet.transactions":
|
||||
return "wallet.pass"
|
||||
case "relationships.friends.request":
|
||||
return "person.badge.plus"
|
||||
case "invites.chat":
|
||||
return "message.badge"
|
||||
case "invites.realm":
|
||||
return "globe"
|
||||
case "auth.login":
|
||||
return "arrow.right.square"
|
||||
case "posts.new":
|
||||
return "doc.badge.plus"
|
||||
case "wallet.orders.paid":
|
||||
return "baggage"
|
||||
case "posts.reactions.new":
|
||||
return "face.smiling"
|
||||
default:
|
||||
return "bell"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NotificationEntry: TimelineEntry {
|
||||
let date: Date
|
||||
let notifications: [SnNotification]?
|
||||
let unreadCount: Int
|
||||
let error: String?
|
||||
let isLoading: Bool
|
||||
|
||||
static func placeholder() -> NotificationEntry {
|
||||
NotificationEntry(date: Date(), notifications: nil, unreadCount: 0, error: nil, isLoading: true)
|
||||
}
|
||||
}
|
||||
|
||||
class NotificationService {
|
||||
private let networkService = WidgetNetworkService()
|
||||
|
||||
private lazy var session: URLSession = {
|
||||
let configuration = URLSessionConfiguration.ephemeral
|
||||
configuration.timeoutIntervalForRequest = 10.0
|
||||
configuration.timeoutIntervalForResource = 10.0
|
||||
configuration.waitsForConnectivity = false
|
||||
return URLSession(configuration: configuration)
|
||||
}()
|
||||
|
||||
func fetchRecentNotifications(take: Int = 5) async throws -> [SnNotification] {
|
||||
if take == 0 {
|
||||
return []
|
||||
}
|
||||
|
||||
guard let token = networkService.token else {
|
||||
throw RemoteError.missingCredentials
|
||||
}
|
||||
|
||||
let baseURL = networkService.baseURL
|
||||
guard let url = URL(string: "\(baseURL)/ring/notifications?unmark=true&take=\(take)") else {
|
||||
throw RemoteError.invalidURL
|
||||
}
|
||||
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = "GET"
|
||||
request.setValue("AtField \(token)", forHTTPHeaderField: "Authorization")
|
||||
request.setValue("application/json", forHTTPHeaderField: "Accept")
|
||||
request.timeoutInterval = 10.0
|
||||
|
||||
let (data, response) = try await session.data(for: request)
|
||||
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
throw RemoteError.invalidResponse
|
||||
}
|
||||
|
||||
switch httpResponse.statusCode {
|
||||
case 200...299:
|
||||
let decoder = JSONDecoder()
|
||||
let notifications = try decoder.decode([SnNotification].self, from: data)
|
||||
return notifications
|
||||
case 404:
|
||||
return []
|
||||
default:
|
||||
throw RemoteError.httpError(httpResponse.statusCode)
|
||||
}
|
||||
}
|
||||
|
||||
func fetchUnreadCount() async throws -> Int {
|
||||
guard let token = networkService.token else {
|
||||
throw RemoteError.missingCredentials
|
||||
}
|
||||
|
||||
let baseURL = networkService.baseURL
|
||||
guard let url = URL(string: "\(baseURL)/ring/notifications/count") else {
|
||||
throw RemoteError.invalidURL
|
||||
}
|
||||
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = "GET"
|
||||
request.setValue("AtField \(token)", forHTTPHeaderField: "Authorization")
|
||||
request.setValue("application/json", forHTTPHeaderField: "Accept")
|
||||
request.timeoutInterval = 10.0
|
||||
|
||||
let (data, response) = try await session.data(for: request)
|
||||
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
throw RemoteError.invalidResponse
|
||||
}
|
||||
|
||||
switch httpResponse.statusCode {
|
||||
case 200...299:
|
||||
if let count = try? JSONSerialization.jsonObject(with: data) as? Int {
|
||||
return count
|
||||
} else if let count = try? JSONSerialization.jsonObject(with: data) as? Double {
|
||||
return Int(count)
|
||||
}
|
||||
return 0
|
||||
case 404:
|
||||
return 0
|
||||
default:
|
||||
throw RemoteError.httpError(httpResponse.statusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NotificationProvider: TimelineProvider {
|
||||
private let notificationService = NotificationService()
|
||||
|
||||
func placeholder(in context: Context) -> NotificationEntry {
|
||||
NotificationEntry.placeholder()
|
||||
}
|
||||
|
||||
func getSnapshot(in context: Context, completion: @escaping (NotificationEntry) -> ()) {
|
||||
Task {
|
||||
print("[WidgetKit] [NotificationProvider] Getting snapshot...")
|
||||
async let notifications = try? await notificationService.fetchRecentNotifications(take: 5)
|
||||
async let unreadCount = try? await notificationService.fetchUnreadCount()
|
||||
|
||||
let notifs = try? await notifications
|
||||
let unread = (try? await unreadCount) ?? 0
|
||||
|
||||
print("[WidgetKit] [NotificationProvider] Snapshot - Notifications: \(notifs?.count ?? 0), Unread: \(unread)")
|
||||
|
||||
let entry = NotificationEntry(date: Date(), notifications: notifs, unreadCount: unread, error: nil, isLoading: false)
|
||||
completion(entry)
|
||||
}
|
||||
}
|
||||
|
||||
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
|
||||
Task {
|
||||
let currentDate = Date()
|
||||
print("[WidgetKit] [NotificationProvider] Getting timeline at \(currentDate)...")
|
||||
|
||||
do {
|
||||
let takeLimit: Int
|
||||
switch context.family {
|
||||
case .systemSmall:
|
||||
takeLimit = 0
|
||||
case .systemMedium:
|
||||
takeLimit = 1
|
||||
case .systemLarge:
|
||||
takeLimit = 3
|
||||
default:
|
||||
takeLimit = 0
|
||||
}
|
||||
|
||||
async let notifications = try await notificationService.fetchRecentNotifications(take: takeLimit)
|
||||
async let unreadCount = try await notificationService.fetchUnreadCount()
|
||||
|
||||
let notifs = try await notifications
|
||||
let unread = try await unreadCount
|
||||
|
||||
print("[WidgetKit] [NotificationProvider] Timeline - Notifications: \(notifs.count), Unread: \(unread)")
|
||||
|
||||
let entry = NotificationEntry(date: currentDate, notifications: notifs, unreadCount: unread, error: nil, isLoading: false)
|
||||
|
||||
let nextUpdate = Calendar.current.date(byAdding: .minute, value: 15, to: currentDate)!
|
||||
print("[WidgetKit] [NotificationProvider] Next update at: \(nextUpdate)")
|
||||
let timeline = Timeline(entries: [entry], policy: .after(nextUpdate))
|
||||
completion(timeline)
|
||||
} catch {
|
||||
print("[WidgetKit] [NotificationProvider] Error in getTimeline: \(error.localizedDescription)")
|
||||
let entry = NotificationEntry(date: currentDate, notifications: nil, unreadCount: 0, error: error.localizedDescription, isLoading: false)
|
||||
let nextUpdate = Calendar.current.date(byAdding: .minute, value: 5, to: currentDate)!
|
||||
let timeline = Timeline(entries: [entry], policy: .after(nextUpdate))
|
||||
completion(timeline)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NotificationWidgetEntryView: View {
|
||||
var entry: NotificationProvider.Entry
|
||||
@Environment(\.widgetFamily) var family
|
||||
|
||||
var body: some View {
|
||||
if let notifications = entry.notifications, !notifications.isEmpty {
|
||||
HasNotificationsView(notifications: notifications, unreadCount: entry.unreadCount)
|
||||
} else if entry.isLoading {
|
||||
LoadingView()
|
||||
} else if let error = entry.error {
|
||||
ErrorView(error: error)
|
||||
} else {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
private var isCompact: Bool {
|
||||
family == .systemSmall || isAccessory
|
||||
}
|
||||
|
||||
private var isAccessory: Bool {
|
||||
if #available(iOS 16.0, *) {
|
||||
if case .accessoryRectangular = family {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func HasNotificationsView(notifications: [SnNotification], unreadCount: Int) -> some View {
|
||||
Link(destination: URL(string: "solian://notifications")!) {
|
||||
if isCompact {
|
||||
if isAccessory {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: "bell.fill")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.orange)
|
||||
.padding(.leading, 1.5)
|
||||
|
||||
Text(NSLocalizedString("notifications", comment: "Notifications"))
|
||||
.font(.caption2)
|
||||
.fontWeight(.bold)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if unreadCount > 0 {
|
||||
HStack(spacing: 4) {
|
||||
Text("\(unreadCount)")
|
||||
.font(.caption2)
|
||||
.fontWeight(.bold)
|
||||
.padding(.horizontal, 6)
|
||||
.background(
|
||||
Capsule()
|
||||
.fill(Color.blue.opacity(0.5))
|
||||
)
|
||||
|
||||
Text(NSLocalizedString("unread", comment: "unread"))
|
||||
.font(.caption2)
|
||||
}
|
||||
}
|
||||
|
||||
Text("on the Solar Network")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.horizontal, 1.5)
|
||||
}
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "bell.fill")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.orange)
|
||||
|
||||
Text(NSLocalizedString("notifications", comment: "Notifications"))
|
||||
.font(.headline)
|
||||
.fontWeight(.bold)
|
||||
|
||||
Spacer()
|
||||
}.padding(.bottom, 8)
|
||||
|
||||
Spacer(minLength: 2)
|
||||
|
||||
if unreadCount > 0 {
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text("\(unreadCount)")
|
||||
.font(.system(.largeTitle, design: .rounded))
|
||||
.fontWeight(.bold)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(minLength: 2)
|
||||
|
||||
if unreadCount > 0 {
|
||||
Text(NSLocalizedString("unreadNotifications", comment: "unread notifications"))
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
.lineLimit(2)
|
||||
.multilineTextAlignment(.leading)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
} else {
|
||||
Text(NSLocalizedString("noUnreadNotifications", comment: "no unread notifications"))
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
}
|
||||
.padding(12)
|
||||
}
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: 8) {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "bell.fill")
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.orange)
|
||||
|
||||
Text(NSLocalizedString("notifications", comment: "Notifications"))
|
||||
.font(.headline)
|
||||
.fontWeight(.bold)
|
||||
|
||||
Spacer()
|
||||
|
||||
if unreadCount > 0 {
|
||||
Text("\(unreadCount)")
|
||||
.font(.caption)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(.white)
|
||||
.padding(.horizontal, 6)
|
||||
.padding(.vertical, 2)
|
||||
.background(.blue)
|
||||
.clipShape(Capsule())
|
||||
}
|
||||
}.padding(.bottom, 8)
|
||||
|
||||
let displayCount = family == .systemMedium ? 1 : 5
|
||||
let displayNotifications = Array(notifications.prefix(displayCount))
|
||||
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
ForEach(displayNotifications) { notification in
|
||||
NotificationItemView(notification: notification, compact: false)
|
||||
}
|
||||
}
|
||||
|
||||
if family == .systemMedium {
|
||||
Spacer()
|
||||
} else {
|
||||
Spacer()
|
||||
Text(NSLocalizedString("tapToViewAll", comment: "Tap to view all notifications"))
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
.padding(12)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func NotificationItemView(notification: SnNotification, compact: Bool) -> some View {
|
||||
HStack(alignment: .top, spacing: compact ? 6 : 12) {
|
||||
if compact {
|
||||
Image(systemName: notification.getTopicIcon())
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
} else {
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(Color.gray.opacity(0.2))
|
||||
.frame(width: 32, height: 32)
|
||||
|
||||
Image(systemName: notification.getTopicIcon())
|
||||
.font(.caption)
|
||||
.foregroundColor(.primary)
|
||||
}
|
||||
}
|
||||
|
||||
VStack(alignment: .leading, spacing: 2) {
|
||||
Text(notification.title)
|
||||
.font(compact ? .caption : .subheadline)
|
||||
.fontWeight(notification.isUnread ? .semibold : .regular)
|
||||
.lineLimit(1)
|
||||
|
||||
if !compact && !notification.subtitle.isEmpty {
|
||||
Text(notification.subtitle)
|
||||
.font(.caption)
|
||||
.lineLimit(1)
|
||||
}
|
||||
|
||||
if !compact && !notification.content.isEmpty {
|
||||
Text(notification.content)
|
||||
.font(.caption2)
|
||||
.lineLimit(2)
|
||||
.multilineTextAlignment(.leading)
|
||||
}
|
||||
|
||||
if let createdDate = notification.createdDate {
|
||||
Text(formatRelativeTime(createdDate))
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.top, 2)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer()
|
||||
|
||||
if notification.isUnread {
|
||||
Circle()
|
||||
.fill(Color.blue)
|
||||
.frame(width: compact ? 6 : 8, height: compact ? 6 : 8)
|
||||
.padding(.trailing, 6)
|
||||
.padding(.top, 8)
|
||||
}
|
||||
}
|
||||
.padding(.vertical, compact ? 2 : 4)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func NotificationCompactItem(notification: SnNotification) -> some View {
|
||||
HStack(spacing: 4) {
|
||||
Image(systemName: notification.getTopicIcon())
|
||||
.font(.caption2)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text(notification.title)
|
||||
.font(.caption2)
|
||||
.lineLimit(1)
|
||||
.fontWeight(notification.isUnread ? .semibold : .regular)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func EmptyView() -> some View {
|
||||
Link(destination: URL(string: "solian://notifications")!) {
|
||||
VStack(alignment: .leading, spacing: isAccessory ? 4 : 8) {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "bell")
|
||||
.font(isAccessory ? .caption : .title3)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text(NSLocalizedString("notifications", comment: "Notifications"))
|
||||
.font(isAccessory ? .caption2 : .headline)
|
||||
.fontWeight(.bold)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if !isAccessory {
|
||||
Text(NSLocalizedString("noNotifications", comment: "No notifications yet"))
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.padding(isAccessory ? 4 : 12)
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func LoadingView() -> some View {
|
||||
VStack(alignment: .leading, spacing: isAccessory ? 4 : 8) {
|
||||
HStack(spacing: 6) {
|
||||
ProgressView()
|
||||
.scaleEffect(isAccessory ? 0.6 : 0.8)
|
||||
Text(NSLocalizedString("loading", comment: "Loading..."))
|
||||
.font(isAccessory ? .caption2 : .caption)
|
||||
.foregroundColor(.secondary)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if !isAccessory {
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.padding(isAccessory ? 4 : 12)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private func ErrorView(error: String) -> some View {
|
||||
Link(destination: URL(string: "solian://notifications")!) {
|
||||
VStack(alignment: .leading, spacing: isAccessory ? 4 : 8) {
|
||||
HStack(spacing: 6) {
|
||||
Image(systemName: "exclamationmark.triangle")
|
||||
.foregroundColor(.secondary)
|
||||
.font(isAccessory ? .caption : .title3)
|
||||
|
||||
Text(NSLocalizedString("error", comment: "Error"))
|
||||
.font(isAccessory ? .caption2 : .headline)
|
||||
Spacer()
|
||||
}
|
||||
|
||||
if !isAccessory {
|
||||
Text(NSLocalizedString("openAppToRefresh", comment: "Open app to refresh"))
|
||||
.font(.caption)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
Text(error)
|
||||
.font(.footnote)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(nil)
|
||||
.multilineTextAlignment(.leading)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
.padding(isAccessory ? 4 : 12)
|
||||
}
|
||||
}
|
||||
|
||||
private func formatRelativeTime(_ date: Date) -> String {
|
||||
let now = Date()
|
||||
let interval = now.timeIntervalSince(date)
|
||||
|
||||
if interval < 60 {
|
||||
return NSLocalizedString("justNow", comment: "Just now")
|
||||
} else if interval < 3600 {
|
||||
let minutes = Int(interval / 60)
|
||||
return String(format: NSLocalizedString("minutesAgo", comment: "%d min ago"), minutes)
|
||||
} else if interval < 86400 {
|
||||
let hours = Int(interval / 3600)
|
||||
return String(format: NSLocalizedString("hoursAgo", comment: "%d hr ago"), hours)
|
||||
} else {
|
||||
let days = Int(interval / 86400)
|
||||
return String(format: NSLocalizedString("daysAgo", comment: "%d d ago"), days)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NotificationWidgetRootView: View {
|
||||
var entry: NotificationProvider.Entry
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
var body: some View {
|
||||
if #available(iOS 17.0, *) {
|
||||
ZStack {
|
||||
NotificationWidgetEntryView(entry: entry)
|
||||
|
||||
if let notifications = entry.notifications, !notifications.isEmpty {
|
||||
GeometryReader { geometry in
|
||||
Image(colorScheme == .dark ? "CloudyLambDark" : "CloudyLamb")
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.frame(
|
||||
width: geometry.size.width * 0.9,
|
||||
height: geometry.size.width * 0.9
|
||||
)
|
||||
.opacity(0.12)
|
||||
.mask(
|
||||
LinearGradient(
|
||||
gradient: Gradient(colors: [
|
||||
Color.white,
|
||||
Color.white,
|
||||
Color.clear
|
||||
]),
|
||||
startPoint: .topLeading,
|
||||
endPoint: .bottomTrailing
|
||||
)
|
||||
)
|
||||
.position(
|
||||
x: geometry.size.width * 0.85,
|
||||
y: 20
|
||||
)
|
||||
}
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
}
|
||||
.containerBackground(.fill.tertiary, for: .widget)
|
||||
.padding(.vertical, 8)
|
||||
} else {
|
||||
NotificationWidgetEntryView(entry: entry)
|
||||
.padding()
|
||||
.background()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SolianNotificationWidget: Widget {
|
||||
let kind: String = "SolianNotificationWidget"
|
||||
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind, provider: NotificationProvider()) { entry in
|
||||
NotificationWidgetRootView(entry: entry)
|
||||
}
|
||||
.configurationDisplayName("Notifications")
|
||||
.description("View your recent notifications")
|
||||
.supportedFamilies(supportedFamilies)
|
||||
}
|
||||
|
||||
private var supportedFamilies: [WidgetFamily] {
|
||||
#if os(iOS)
|
||||
return [.systemSmall, .systemMedium, .systemLarge, .accessoryRectangular]
|
||||
#else
|
||||
return [.systemSmall, .systemMedium, .systemLarge]
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#Preview(as: .accessoryRectangular) {
|
||||
SolianNotificationWidget()
|
||||
} timeline: {
|
||||
NotificationEntry(
|
||||
date: .now,
|
||||
notifications: [
|
||||
SnNotification(
|
||||
id: "1",
|
||||
topic: "post.replies",
|
||||
title: "New reply to your post",
|
||||
subtitle: "Someone replied to your message",
|
||||
content: "This is notification content",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: nil,
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date()),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
),
|
||||
SnNotification(
|
||||
id: "2",
|
||||
topic: "relationships.friends.request",
|
||||
title: "New friend request",
|
||||
subtitle: "You have a pending friend request",
|
||||
content: "Someone wants to be your friend",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date().addingTimeInterval(-3600)),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
)
|
||||
],
|
||||
unreadCount: 1,
|
||||
error: nil,
|
||||
isLoading: false
|
||||
)
|
||||
}
|
||||
|
||||
#Preview(as: .systemSmall) {
|
||||
SolianNotificationWidget()
|
||||
} timeline: {
|
||||
NotificationEntry(
|
||||
date: .now,
|
||||
notifications: [
|
||||
SnNotification(
|
||||
id: "1",
|
||||
topic: "post.replies",
|
||||
title: "New reply to your post",
|
||||
subtitle: "Someone replied to your message",
|
||||
content: "This is notification content",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: nil,
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date()),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
),
|
||||
SnNotification(
|
||||
id: "2",
|
||||
topic: "relationships.friends.request",
|
||||
title: "New friend request",
|
||||
subtitle: "You have a pending friend request",
|
||||
content: "Someone wants to be your friend",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date().addingTimeInterval(-3600)),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
)
|
||||
],
|
||||
unreadCount: 1,
|
||||
error: nil,
|
||||
isLoading: false
|
||||
)
|
||||
}
|
||||
|
||||
#Preview(as: .systemMedium) {
|
||||
SolianNotificationWidget()
|
||||
} timeline: {
|
||||
NotificationEntry(
|
||||
date: .now,
|
||||
notifications: [
|
||||
SnNotification(
|
||||
id: "1",
|
||||
topic: "post.replies",
|
||||
title: "New reply to your post",
|
||||
subtitle: "Someone replied to your message",
|
||||
content: "This is notification content",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: nil,
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date()),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
),
|
||||
SnNotification(
|
||||
id: "2",
|
||||
topic: "relationships.friends.request",
|
||||
title: "New friend request",
|
||||
subtitle: "You have a pending friend request",
|
||||
content: "Someone wants to be your friend",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: nil,
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date().addingTimeInterval(-3600)),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
),
|
||||
SnNotification(
|
||||
id: "3",
|
||||
topic: "invites.chat",
|
||||
title: "New chat invite",
|
||||
subtitle: "You've been invited to a chat",
|
||||
content: "Join the conversation",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: ISO8601DateFormatter().string(from: Date().addingTimeInterval(-86400)),
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date().addingTimeInterval(-86400)),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
)
|
||||
],
|
||||
unreadCount: 2,
|
||||
error: nil,
|
||||
isLoading: false
|
||||
)
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
#Preview(as: .systemLarge) {
|
||||
SolianNotificationWidget()
|
||||
} timeline: {
|
||||
NotificationEntry(
|
||||
date: .now,
|
||||
notifications: [
|
||||
SnNotification(
|
||||
id: "1",
|
||||
topic: "post.replies",
|
||||
title: "New reply",
|
||||
subtitle: "Someone replied",
|
||||
content: "Content",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: nil,
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date()),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
),
|
||||
SnNotification(
|
||||
id: "2",
|
||||
topic: "relationships.friends.request",
|
||||
title: "New friend request",
|
||||
subtitle: "You have a pending friend request",
|
||||
content: "Someone wants to be your friend",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: nil,
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date().addingTimeInterval(-3600)),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
),
|
||||
SnNotification(
|
||||
id: "3",
|
||||
topic: "invites.chat",
|
||||
title: "New chat invite",
|
||||
subtitle: "You've been invited to a chat",
|
||||
content: "Join the conversation",
|
||||
meta: nil,
|
||||
priority: 0,
|
||||
viewedAt: ISO8601DateFormatter().string(from: Date().addingTimeInterval(-86400)),
|
||||
accountId: "acc-1",
|
||||
createdAt: ISO8601DateFormatter().string(from: Date().addingTimeInterval(-86400)),
|
||||
updatedAt: ISO8601DateFormatter().string(from: Date()),
|
||||
deletedAt: nil
|
||||
)
|
||||
],
|
||||
unreadCount: 3,
|
||||
error: nil,
|
||||
isLoading: false
|
||||
)
|
||||
}
|
||||
#endif
|
||||
17
ios/SolianWidgetExtension/SolianWidgetExtensionBundle.swift
Normal file
17
ios/SolianWidgetExtension/SolianWidgetExtensionBundle.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// SolianWidgetExtensionBundle.swift
|
||||
// SolianWidgetExtension
|
||||
//
|
||||
// Created by LittleSheep on 2026/1/3.
|
||||
//
|
||||
|
||||
import WidgetKit
|
||||
import SwiftUI
|
||||
|
||||
@main
|
||||
struct SolianWidgetExtensionBundle: WidgetBundle {
|
||||
var body: some Widget {
|
||||
SolianCheckInWidget()
|
||||
SolianNotificationWidget()
|
||||
}
|
||||
}
|
||||
136
ios/SolianWidgetExtension/WidgetNetworking.swift
Normal file
136
ios/SolianWidgetExtension/WidgetNetworking.swift
Normal file
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// Networking.swift
|
||||
// SolianWidgetExtensionExtension
|
||||
//
|
||||
// Created by LittleSheep on 2026/1/4.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum RemoteError: Error {
|
||||
case missingCredentials
|
||||
case invalidURL
|
||||
case invalidResponse
|
||||
case httpError(Int)
|
||||
case decodingError
|
||||
}
|
||||
|
||||
extension RemoteError: LocalizedError {
|
||||
var errorDescription: String? {
|
||||
switch self {
|
||||
case .missingCredentials:
|
||||
return "Please open the app to sign in."
|
||||
case .invalidURL:
|
||||
return "Invalid server configuration."
|
||||
case .invalidResponse:
|
||||
return "Server returned an invalid response."
|
||||
case .httpError(let code):
|
||||
return "Server error (\(code))."
|
||||
case .decodingError:
|
||||
return "Failed to read server data."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TokenData: Codable {
|
||||
let token: String
|
||||
}
|
||||
|
||||
class WidgetNetworkService {
|
||||
private let appGroup = "group.solsynth.solian"
|
||||
private let tokenKey = "flutter.dyn_user_tk"
|
||||
private let urlKey = "flutter.app_server_url"
|
||||
|
||||
private lazy var session: URLSession = {
|
||||
let configuration = URLSessionConfiguration.ephemeral
|
||||
configuration.timeoutIntervalForRequest = 10.0
|
||||
configuration.timeoutIntervalForResource = 10.0
|
||||
configuration.waitsForConnectivity = false
|
||||
return URLSession(configuration: configuration)
|
||||
}()
|
||||
|
||||
private var userDefaults: UserDefaults? {
|
||||
UserDefaults(suiteName: appGroup)
|
||||
}
|
||||
|
||||
var token: String? {
|
||||
guard let tokenString = userDefaults?.string(forKey: tokenKey) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let data = tokenString.data(using: .utf8) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
do {
|
||||
let tokenData = try JSONDecoder().decode(TokenData.self, from: data)
|
||||
return tokenData.token
|
||||
} catch {
|
||||
print("[WidgetKit] Failed to decode token: \(error)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
var baseURL: String {
|
||||
return userDefaults?.string(forKey: urlKey) ?? "https://api.solian.app"
|
||||
}
|
||||
|
||||
func makeRequest<T: Codable>(
|
||||
path: String,
|
||||
method: String = "GET",
|
||||
headers: [String: String] = [:]
|
||||
) async throws -> T? {
|
||||
guard let token = token else {
|
||||
throw RemoteError.missingCredentials
|
||||
}
|
||||
|
||||
guard let url = URL(string: "\(baseURL)\(path)") else {
|
||||
throw RemoteError.invalidURL
|
||||
}
|
||||
|
||||
var request = URLRequest(url: url)
|
||||
request.httpMethod = method
|
||||
request.setValue("AtField \(token)", forHTTPHeaderField: "Authorization")
|
||||
request.setValue("application/json", forHTTPHeaderField: "Accept")
|
||||
|
||||
for (key, value) in headers {
|
||||
request.setValue(value, forHTTPHeaderField: key)
|
||||
}
|
||||
|
||||
request.timeoutInterval = 10.0
|
||||
|
||||
print("[WidgetKit] [Network] Requesting: \(baseURL)\(path)")
|
||||
|
||||
let (data, response) = try await session.data(for: request)
|
||||
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
throw RemoteError.invalidResponse
|
||||
}
|
||||
|
||||
print("[WidgetKit] [Network] Status: \(httpResponse.statusCode), Data length: \(data.count)")
|
||||
|
||||
if let jsonString = String(data: data, encoding: .utf8) {
|
||||
print("[WidgetKit] [Network] Response: \(jsonString.prefix(500))")
|
||||
}
|
||||
|
||||
switch httpResponse.statusCode {
|
||||
case 200...299:
|
||||
let decoder = JSONDecoder()
|
||||
do {
|
||||
let result = try decoder.decode(T.self, from: data)
|
||||
print("[WidgetKit] [Network] Successfully decoded response")
|
||||
return result
|
||||
} catch {
|
||||
print("[WidgetKit] [Network] Decoding error: \(error.localizedDescription)")
|
||||
print("[WidgetKit] [Network] Expected type: \(String(describing: T.self))")
|
||||
throw RemoteError.decodingError
|
||||
}
|
||||
case 404:
|
||||
print("[WidgetKit] [Network] Resource not found (404)")
|
||||
return nil
|
||||
default:
|
||||
print("[WidgetKit] [Network] HTTP Error: \(httpResponse.statusCode)")
|
||||
throw RemoteError.httpError(httpResponse.statusCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
41
ios/SolianWidgetExtension/en.lproj/Localizable.strings
Normal file
41
ios/SolianWidgetExtension/en.lproj/Localizable.strings
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Check In Level Names */
|
||||
"checkInResultT0" = "Great Misfortune";
|
||||
"checkInResultT1" = "Misfortune";
|
||||
"checkInResultT2" = "Moderate";
|
||||
"checkInResultT3" = "Fortune";
|
||||
"checkInResultT4" = "Great Fortune";
|
||||
"checkInResultT5" = "Special";
|
||||
|
||||
/* Widget UI Strings */
|
||||
"checkIn" = "Check In";
|
||||
"tapToCheckIn" = "Tap to check in today";
|
||||
"error" = "Error";
|
||||
"openAppToRefresh" = "Open app to refresh";
|
||||
"loading" = "Loading...";
|
||||
"rewardPoints" = "%d";
|
||||
"rewardExperience" = "%d EXP";
|
||||
"footer" = "Solian Check In";
|
||||
|
||||
/* Notable Day Strings */
|
||||
"notableDayToday" = "%@ is today!";
|
||||
"notableDayIs" = "%@ is %@";
|
||||
"notableDayUpcoming" = "Upcoming";
|
||||
"today" = "Today";
|
||||
|
||||
/* Notification Widget Strings */
|
||||
"notifications" = "Notifications";
|
||||
"noNotifications" = "No notifications yet";
|
||||
"tapToViewAll" = "Tap to view all notifications";
|
||||
"justNow" = "Just now";
|
||||
"minutesAgo" = "%d min ago";
|
||||
"hoursAgo" = "%d hr ago";
|
||||
"daysAgo" = "%d d ago";
|
||||
"pleaseSignIn" = "Please open the app to sign in.";
|
||||
"invalidServerConfig" = "Invalid server configuration.";
|
||||
"invalidResponse" = "Server returned an invalid response.";
|
||||
"httpError" = "Server error (%d).";
|
||||
"decodingError" = "Failed to read server data.";
|
||||
"unreadNotifications" = "Notification(s) unread";
|
||||
"noNotifications" = "No notifications";
|
||||
"noUnreadNotifications" = "All notifications are read";
|
||||
"unread" = "unread";
|
||||
36
ios/SolianWidgetExtension/es.lproj/Localizable.strings
Normal file
36
ios/SolianWidgetExtension/es.lproj/Localizable.strings
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Check In Level Names */
|
||||
"checkInResultT0" = "Gran Desventura";
|
||||
"checkInResultT1" = "Desventura";
|
||||
"checkInResultT2" = "Moderado";
|
||||
"checkInResultT3" = "Buena Fortuna";
|
||||
"checkInResultT4" = "Gran Fortuna";
|
||||
"checkInResultT5" = "Especial";
|
||||
|
||||
/* Widget UI Strings */
|
||||
"checkIn" = "Registrar";
|
||||
"tapToCheckIn" = "Toca para registrar hoy";
|
||||
"error" = "Error";
|
||||
"openAppToRefresh" = "Abre la aplicación para actualizar";
|
||||
"loading" = "Cargando...";
|
||||
"rewardPoints" = "%d";
|
||||
"rewardExperience" = "%d EXP";
|
||||
"footer" = "Registro Solian";
|
||||
|
||||
/* Notable Day Strings */
|
||||
"notableDayToday" = "%@ es hoy!";
|
||||
"notableDayIs" = "%@ es %@";
|
||||
"today" = "Hoy";
|
||||
|
||||
/* Notification Widget Strings */
|
||||
"notifications" = "Notificaciones";
|
||||
"noNotifications" = "Aún no hay notificaciones";
|
||||
"tapToViewAll" = "Toca para ver todas las notificaciones";
|
||||
"justNow" = "Ahora mismo";
|
||||
"minutesAgo" = "hace %d min";
|
||||
"hoursAgo" = "hace %d hr";
|
||||
"daysAgo" = "hace %d días";
|
||||
"pleaseSignIn" = "Por favor, abre la aplicación para iniciar sesión.";
|
||||
"invalidServerConfig" = "Configuración del servidor no válida.";
|
||||
"invalidResponse" = "El servidor devolvió una respuesta no válida.";
|
||||
"httpError" = "Error del servidor (%d).";
|
||||
"decodingError" = "Error al leer los datos del servidor.";
|
||||
36
ios/SolianWidgetExtension/ja.lproj/Localizable.strings
Normal file
36
ios/SolianWidgetExtension/ja.lproj/Localizable.strings
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Check In Level Names */
|
||||
"checkInResultT0" = "大凶";
|
||||
"checkInResultT1" = "凶";
|
||||
"checkInResultT2" = "中平";
|
||||
"checkInResultT3" = "吉";
|
||||
"checkInResultT4" = "大吉";
|
||||
"checkInResultT5" = "特殊";
|
||||
|
||||
/* Widget UI Strings */
|
||||
"checkIn" = "チェックイン";
|
||||
"tapToCheckIn" = "タップして今日チェックイン";
|
||||
"error" = "エラー";
|
||||
"openAppToRefresh" = "アプリを開いて更新";
|
||||
"loading" = "読み込み中...";
|
||||
"rewardPoints" = "%d";
|
||||
"rewardExperience" = "%d 経験値";
|
||||
"footer" = "Solian チェックイン";
|
||||
|
||||
/* Notable Day Strings */
|
||||
"notableDayToday" = "%@は今日です!";
|
||||
"notableDayIs" = "%@は%@です";
|
||||
"today" = "今日";
|
||||
|
||||
/* Notification Widget Strings */
|
||||
"notifications" = "通知";
|
||||
"noNotifications" = "まだ通知はありません";
|
||||
"tapToViewAll" = "タップしてすべての通知を表示";
|
||||
"justNow" = "たった今";
|
||||
"minutesAgo" = "%d分前";
|
||||
"hoursAgo" = "%d時間前";
|
||||
"daysAgo" = "%d日前";
|
||||
"pleaseSignIn" = "アプリを開いてサインインしてください。";
|
||||
"invalidServerConfig" = "サーバー設定が無効です。";
|
||||
"invalidResponse" = "サーバーから無効な応答が返されました。";
|
||||
"httpError" = "サーバーエラー (%d)。";
|
||||
"decodingError" = "サーバーデータの読み込みに失敗しました。";
|
||||
36
ios/SolianWidgetExtension/ko.lproj/Localizable.strings
Normal file
36
ios/SolianWidgetExtension/ko.lproj/Localizable.strings
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Check In Level Names */
|
||||
"checkInResultT0" = "대흉";
|
||||
"checkInResultT1" = "흉";
|
||||
"checkInResultT2" = "중평";
|
||||
"checkInResultT3" = "길";
|
||||
"checkInResultT4" = "대길";
|
||||
"checkInResultT5" = "특수";
|
||||
|
||||
/* Widget UI Strings */
|
||||
"checkIn" = "체크인";
|
||||
"tapToCheckIn" = "탭하여 오늘 체크인";
|
||||
"error" = "오류";
|
||||
"openAppToRefresh" = "앱을 열어 새로고침";
|
||||
"loading" = "로딩 중...";
|
||||
"rewardPoints" = "%d";
|
||||
"rewardExperience" = "%d 경험치";
|
||||
"footer" = "Solian 체크인";
|
||||
|
||||
/* Notable Day Strings */
|
||||
"notableDayToday" = "%@ 오늘입니다!";
|
||||
"notableDayIs" = "%@ 은/는 %@";
|
||||
"today" = "오늘";
|
||||
|
||||
/* Notification Widget Strings */
|
||||
"notifications" = "알림";
|
||||
"noNotifications" = "아직 알림이 없습니다";
|
||||
"tapToViewAll" = "탭하여 모든 알림 보기";
|
||||
"justNow" = "방금";
|
||||
"minutesAgo" = "%d분 전";
|
||||
"hoursAgo" = "%d시간 전";
|
||||
"daysAgo" = "%d일 전";
|
||||
"pleaseSignIn" = "앱을 열어 로그인하세요.";
|
||||
"invalidServerConfig" = "서버 구성이 올바르지 않습니다.";
|
||||
"invalidResponse" = "서버에서 잘못된 응답을 받았습니다.";
|
||||
"httpError" = "서버 오류 (%d).";
|
||||
"decodingError" = "서버 데이터 읽기에 실패했습니다.";
|
||||
41
ios/SolianWidgetExtension/zh-Hans.lproj/Localizable.strings
Normal file
41
ios/SolianWidgetExtension/zh-Hans.lproj/Localizable.strings
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Check In Level Names */
|
||||
"checkInResultT0" = "大凶";
|
||||
"checkInResultT1" = "凶";
|
||||
"checkInResultT2" = "中平";
|
||||
"checkInResultT3" = "吉";
|
||||
"checkInResultT4" = "大吉";
|
||||
"checkInResultT5" = "特殊";
|
||||
|
||||
/* Widget UI Strings */
|
||||
"checkIn" = "打卡";
|
||||
"tapToCheckIn" = "点击今日打卡";
|
||||
"error" = "错误";
|
||||
"openAppToRefresh" = "打开应用以刷新";
|
||||
"loading" = "加载中...";
|
||||
"rewardPoints" = "%d";
|
||||
"rewardExperience" = "%d 经验值";
|
||||
"footer" = "Solian 签到";
|
||||
|
||||
/* Notable Day Strings */
|
||||
"notableDayToday" = "%@是今天!";
|
||||
"notableDayIs" = "%@ 是 %@";
|
||||
"notableDayUpcoming" = "接下来";
|
||||
"today" = "今天";
|
||||
|
||||
/* Notification Widget Strings */
|
||||
"notifications" = "通知";
|
||||
"noNotifications" = "还没有通知";
|
||||
"tapToViewAll" = "点击查看所有通知";
|
||||
"justNow" = "刚刚";
|
||||
"minutesAgo" = "%d分钟前";
|
||||
"hoursAgo" = "%d小时前";
|
||||
"daysAgo" = "%d天前";
|
||||
"pleaseSignIn" = "请打开应用登录。";
|
||||
"invalidServerConfig" = "服务器配置无效。";
|
||||
"invalidResponse" = "服务器返回了无效响应。";
|
||||
"httpError" = "服务器错误 (%d)。";
|
||||
"decodingError" = "读取服务器数据失败。";
|
||||
"unreadNotifications" = "条通知未读";
|
||||
"noNotifications" = "没有通知";
|
||||
"noUnreadNotifications" = "没有未读通知";
|
||||
"unread" = "未读";
|
||||
36
ios/SolianWidgetExtension/zh-Hant.lproj/Localizable.strings
Normal file
36
ios/SolianWidgetExtension/zh-Hant.lproj/Localizable.strings
Normal file
@@ -0,0 +1,36 @@
|
||||
/* Check In Level Names */
|
||||
"checkInResultT0" = "大凶";
|
||||
"checkInResultT1" = "凶";
|
||||
"checkInResultT2" = "中平";
|
||||
"checkInResultT3" = "吉";
|
||||
"checkInResultT4" = "大吉";
|
||||
"checkInResultT5" = "特殊";
|
||||
|
||||
/* Widget UI Strings */
|
||||
"checkIn" = "打卡";
|
||||
"tapToCheckIn" = "點擊今日打卡";
|
||||
"error" = "錯誤";
|
||||
"openAppToRefresh" = "打開應用以刷新";
|
||||
"loading" = "載入中...";
|
||||
"rewardPoints" = "%d";
|
||||
"rewardExperience" = "%d 經驗值";
|
||||
"footer" = "Solian 簽到";
|
||||
|
||||
/* Notable Day Strings */
|
||||
"notableDayToday" = "%@是今天!";
|
||||
"notableDayIs" = "%@ 是 %@";
|
||||
"today" = "今天";
|
||||
|
||||
/* Notification Widget Strings */
|
||||
"notifications" = "通知";
|
||||
"noNotifications" = "還沒有通知";
|
||||
"tapToViewAll" = "點擊查看所有通知";
|
||||
"justNow" = "剛剛";
|
||||
"minutesAgo" = "%d分鐘前";
|
||||
"hoursAgo" = "%d小時前";
|
||||
"daysAgo" = "%d天前";
|
||||
"pleaseSignIn" = "請打開應用登錄。";
|
||||
"invalidServerConfig" = "伺服器配置無效。";
|
||||
"invalidResponse" = "伺服器返回了無效響應。";
|
||||
"httpError" = "伺服器錯誤 (%d)。";
|
||||
"decodingError" = "讀取伺服器數據失敗。";
|
||||
12
ios/SolianWidgetExtensionExtension.entitlements
Normal file
12
ios/SolianWidgetExtensionExtension.entitlements
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.solsynth.solian</string>
|
||||
</array>
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -20,6 +20,7 @@ import 'package:island/pods/userinfo.dart';
|
||||
import 'package:island/pods/websocket.dart';
|
||||
import 'package:island/route.dart';
|
||||
import 'package:island/services/notify.dart';
|
||||
import 'package:island/services/widget_sync_service.dart';
|
||||
import 'package:island/services/timezone.dart';
|
||||
import 'package:island/widgets/alert.dart';
|
||||
import 'package:island/widgets/app_scaffold.dart';
|
||||
@@ -282,6 +283,11 @@ class IslandApp extends HookConsumerWidget {
|
||||
ref.listen(websocketStateProvider, (_, state) {
|
||||
talker.info('[WebSocket] $state');
|
||||
});
|
||||
ref.listen(userInfoProvider, (_, user) {
|
||||
if (user.value != null) {
|
||||
WidgetSyncService().syncToWidget();
|
||||
}
|
||||
});
|
||||
Future(() {
|
||||
userNotifier.fetchUser().then((_) {
|
||||
final user = ref.watch(userInfoProvider);
|
||||
|
||||
@@ -32,10 +32,10 @@ final List<RouteItem> kAvailableRoutes = [
|
||||
icon: Symbols.explore,
|
||||
),
|
||||
RouteItem(
|
||||
name: 'searchPosts'.tr(),
|
||||
path: '/posts/search',
|
||||
description: 'searchPostsDescription'.tr(),
|
||||
searchableAliases: ['search', 'posts'],
|
||||
name: 'universalSearch'.tr(),
|
||||
path: '/search',
|
||||
description: 'universalSearchDescription'.tr(),
|
||||
searchableAliases: ['search', 'universal', 'fediverse'],
|
||||
icon: Symbols.search,
|
||||
),
|
||||
RouteItem(
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'activity_rpc.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(presenceActivities)
|
||||
const presenceActivitiesProvider = PresenceActivitiesFamily._();
|
||||
final presenceActivitiesProvider = PresenceActivitiesFamily._();
|
||||
|
||||
final class PresenceActivitiesProvider
|
||||
extends
|
||||
@@ -22,7 +22,7 @@ final class PresenceActivitiesProvider
|
||||
with
|
||||
$FutureModifier<List<SnPresenceActivity>>,
|
||||
$FutureProvider<List<SnPresenceActivity>> {
|
||||
const PresenceActivitiesProvider._({
|
||||
PresenceActivitiesProvider._({
|
||||
required PresenceActivitiesFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -71,7 +71,7 @@ String _$presenceActivitiesHash() =>
|
||||
|
||||
final class PresenceActivitiesFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<List<SnPresenceActivity>>, String> {
|
||||
const PresenceActivitiesFamily._()
|
||||
PresenceActivitiesFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'presenceActivitiesProvider',
|
||||
|
||||
@@ -10,7 +10,7 @@ final articleDetailProvider = FutureProvider.autoDispose
|
||||
|
||||
try {
|
||||
final response = await dio.get<Map<String, dynamic>>(
|
||||
'/sphere/feeds/articles/$articleId',
|
||||
'/insight/feeds/articles/$articleId',
|
||||
);
|
||||
|
||||
if (response.statusCode == 200 && response.data != null) {
|
||||
|
||||
@@ -10,11 +10,11 @@ part of 'call.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(CallNotifier)
|
||||
const callProvider = CallNotifierProvider._();
|
||||
final callProvider = CallNotifierProvider._();
|
||||
|
||||
final class CallNotifierProvider
|
||||
extends $NotifierProvider<CallNotifier, CallState> {
|
||||
const CallNotifierProvider._()
|
||||
CallNotifierProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -48,7 +48,6 @@ abstract class _$CallNotifier extends $Notifier<CallState> {
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref = this.ref as $Ref<CallState, CallState>;
|
||||
final element =
|
||||
ref.element
|
||||
@@ -58,6 +57,6 @@ abstract class _$CallNotifier extends $Notifier<CallState> {
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ part of 'chat_online_count.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(ChatOnlineCountNotifier)
|
||||
const chatOnlineCountProvider = ChatOnlineCountNotifierFamily._();
|
||||
final chatOnlineCountProvider = ChatOnlineCountNotifierFamily._();
|
||||
|
||||
final class ChatOnlineCountNotifierProvider
|
||||
extends $AsyncNotifierProvider<ChatOnlineCountNotifier, int> {
|
||||
const ChatOnlineCountNotifierProvider._({
|
||||
ChatOnlineCountNotifierProvider._({
|
||||
required ChatOnlineCountNotifierFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -63,7 +63,7 @@ final class ChatOnlineCountNotifierFamily extends $Family
|
||||
FutureOr<int>,
|
||||
String
|
||||
> {
|
||||
const ChatOnlineCountNotifierFamily._()
|
||||
ChatOnlineCountNotifierFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'chatOnlineCountProvider',
|
||||
@@ -87,7 +87,6 @@ abstract class _$ChatOnlineCountNotifier extends $AsyncNotifier<int> {
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build(_$args);
|
||||
final ref = this.ref as $Ref<AsyncValue<int>, int>;
|
||||
final element =
|
||||
ref.element
|
||||
@@ -97,6 +96,6 @@ abstract class _$ChatOnlineCountNotifier extends $AsyncNotifier<int> {
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, () => build(_$args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ part of 'chat_room.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(ChatRoomJoinedNotifier)
|
||||
const chatRoomJoinedProvider = ChatRoomJoinedNotifierProvider._();
|
||||
final chatRoomJoinedProvider = ChatRoomJoinedNotifierProvider._();
|
||||
|
||||
final class ChatRoomJoinedNotifierProvider
|
||||
extends $AsyncNotifierProvider<ChatRoomJoinedNotifier, List<SnChatRoom>> {
|
||||
const ChatRoomJoinedNotifierProvider._()
|
||||
ChatRoomJoinedNotifierProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -42,7 +42,6 @@ abstract class _$ChatRoomJoinedNotifier
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref =
|
||||
this.ref as $Ref<AsyncValue<List<SnChatRoom>>, List<SnChatRoom>>;
|
||||
final element =
|
||||
@@ -53,16 +52,16 @@ abstract class _$ChatRoomJoinedNotifier
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
|
||||
@ProviderFor(ChatRoomNotifier)
|
||||
const chatRoomProvider = ChatRoomNotifierFamily._();
|
||||
final chatRoomProvider = ChatRoomNotifierFamily._();
|
||||
|
||||
final class ChatRoomNotifierProvider
|
||||
extends $AsyncNotifierProvider<ChatRoomNotifier, SnChatRoom?> {
|
||||
const ChatRoomNotifierProvider._({
|
||||
ChatRoomNotifierProvider._({
|
||||
required ChatRoomNotifierFamily super.from,
|
||||
required String? super.argument,
|
||||
}) : super(
|
||||
@@ -109,7 +108,7 @@ final class ChatRoomNotifierFamily extends $Family
|
||||
FutureOr<SnChatRoom?>,
|
||||
String?
|
||||
> {
|
||||
const ChatRoomNotifierFamily._()
|
||||
ChatRoomNotifierFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'chatRoomProvider',
|
||||
@@ -133,7 +132,6 @@ abstract class _$ChatRoomNotifier extends $AsyncNotifier<SnChatRoom?> {
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build(_$args);
|
||||
final ref = this.ref as $Ref<AsyncValue<SnChatRoom?>, SnChatRoom?>;
|
||||
final element =
|
||||
ref.element
|
||||
@@ -143,16 +141,16 @@ abstract class _$ChatRoomNotifier extends $AsyncNotifier<SnChatRoom?> {
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, () => build(_$args));
|
||||
}
|
||||
}
|
||||
|
||||
@ProviderFor(ChatRoomIdentityNotifier)
|
||||
const chatRoomIdentityProvider = ChatRoomIdentityNotifierFamily._();
|
||||
final chatRoomIdentityProvider = ChatRoomIdentityNotifierFamily._();
|
||||
|
||||
final class ChatRoomIdentityNotifierProvider
|
||||
extends $AsyncNotifierProvider<ChatRoomIdentityNotifier, SnChatMember?> {
|
||||
const ChatRoomIdentityNotifierProvider._({
|
||||
ChatRoomIdentityNotifierProvider._({
|
||||
required ChatRoomIdentityNotifierFamily super.from,
|
||||
required String? super.argument,
|
||||
}) : super(
|
||||
@@ -201,7 +199,7 @@ final class ChatRoomIdentityNotifierFamily extends $Family
|
||||
FutureOr<SnChatMember?>,
|
||||
String?
|
||||
> {
|
||||
const ChatRoomIdentityNotifierFamily._()
|
||||
ChatRoomIdentityNotifierFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'chatRoomIdentityProvider',
|
||||
@@ -226,7 +224,6 @@ abstract class _$ChatRoomIdentityNotifier
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build(_$args);
|
||||
final ref = this.ref as $Ref<AsyncValue<SnChatMember?>, SnChatMember?>;
|
||||
final element =
|
||||
ref.element
|
||||
@@ -236,12 +233,12 @@ abstract class _$ChatRoomIdentityNotifier
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, () => build(_$args));
|
||||
}
|
||||
}
|
||||
|
||||
@ProviderFor(chatroomInvites)
|
||||
const chatroomInvitesProvider = ChatroomInvitesProvider._();
|
||||
final chatroomInvitesProvider = ChatroomInvitesProvider._();
|
||||
|
||||
final class ChatroomInvitesProvider
|
||||
extends
|
||||
@@ -253,7 +250,7 @@ final class ChatroomInvitesProvider
|
||||
with
|
||||
$FutureModifier<List<SnChatMember>>,
|
||||
$FutureProvider<List<SnChatMember>> {
|
||||
const ChatroomInvitesProvider._()
|
||||
ChatroomInvitesProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
|
||||
@@ -7,6 +7,7 @@ import "package:island/pods/chat/chat_room.dart";
|
||||
import "package:island/pods/lifecycle.dart";
|
||||
import "package:island/pods/chat/messages_notifier.dart";
|
||||
import "package:island/pods/websocket.dart";
|
||||
import "package:island/talker.dart";
|
||||
import "package:island/widgets/chat/call_button.dart";
|
||||
import "package:riverpod_annotation/riverpod_annotation.dart";
|
||||
|
||||
@@ -35,6 +36,22 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier {
|
||||
Timer? _typingCooldownTimer;
|
||||
Timer? _periodicSubscribeTimer;
|
||||
StreamSubscription? _wsSubscription;
|
||||
Function? _sendMessage;
|
||||
|
||||
void _cleanupResources() {
|
||||
if (_wsSubscription != null) {
|
||||
_wsSubscription!.cancel();
|
||||
_wsSubscription = null;
|
||||
}
|
||||
if (_typingCleanupTimer != null) {
|
||||
_typingCleanupTimer!.cancel();
|
||||
_typingCleanupTimer = null;
|
||||
}
|
||||
if (_periodicSubscribeTimer != null) {
|
||||
_periodicSubscribeTimer!.cancel();
|
||||
_periodicSubscribeTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
List<SnChatMember> build(String roomId) {
|
||||
@@ -43,6 +60,8 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier {
|
||||
final chatIdentityAsync = ref.watch(chatRoomIdentityProvider(roomId));
|
||||
_messagesNotifier = ref.watch(messagesProvider(roomId).notifier);
|
||||
|
||||
_cleanupResources();
|
||||
|
||||
if (chatRoomAsync.isLoading || chatIdentityAsync.isLoading) {
|
||||
return [];
|
||||
}
|
||||
@@ -56,7 +75,9 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier {
|
||||
|
||||
// Subscribe to messages
|
||||
final wsState = ref.read(websocketStateProvider.notifier);
|
||||
wsState.sendMessage(
|
||||
_sendMessage = wsState.sendMessage;
|
||||
talker.info('[MessageSubscriber] Subscribing room $roomId');
|
||||
_sendMessage!(
|
||||
jsonEncode(
|
||||
WebSocketPacket(
|
||||
type: 'messages.subscribe',
|
||||
@@ -93,7 +114,7 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier {
|
||||
|
||||
// Set up periodic subscribe timer (every 5 minutes)
|
||||
_periodicSubscribeTimer = Timer.periodic(const Duration(minutes: 5), (_) {
|
||||
wsState.sendMessage(
|
||||
_sendMessage!(
|
||||
jsonEncode(
|
||||
WebSocketPacket(
|
||||
type: 'messages.subscribe',
|
||||
@@ -104,14 +125,13 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier {
|
||||
);
|
||||
});
|
||||
|
||||
// Listen to app lifecycle changes
|
||||
ref.listen(appLifecycleStateProvider, (previous, next) {
|
||||
final lifecycleState = next.value;
|
||||
if (lifecycleState == AppLifecycleState.paused ||
|
||||
lifecycleState == AppLifecycleState.inactive) {
|
||||
// Unsubscribe when app goes to background
|
||||
final wsState = ref.read(websocketStateProvider.notifier);
|
||||
wsState.sendMessage(
|
||||
talker.info('[MessageSubscriber] Unsubscribing room $roomId');
|
||||
_sendMessage!(
|
||||
jsonEncode(
|
||||
WebSocketPacket(
|
||||
type: 'messages.unsubscribe',
|
||||
@@ -122,8 +142,8 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier {
|
||||
);
|
||||
} else if (lifecycleState == AppLifecycleState.resumed) {
|
||||
// Resubscribe when app comes back to foreground
|
||||
final wsState = ref.read(websocketStateProvider.notifier);
|
||||
wsState.sendMessage(
|
||||
talker.info('[MessageSubscriber] Subscribing room $roomId');
|
||||
_sendMessage!(
|
||||
jsonEncode(
|
||||
WebSocketPacket(
|
||||
type: 'messages.subscribe',
|
||||
@@ -135,22 +155,44 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier {
|
||||
}
|
||||
});
|
||||
|
||||
// Cleanup on dispose
|
||||
ref.onDispose(() {
|
||||
ref.read(currentSubscribedChatIdProvider.notifier).set(null);
|
||||
wsState.sendMessage(
|
||||
jsonEncode(
|
||||
WebSocketPacket(
|
||||
type: 'messages.unsubscribe',
|
||||
data: {'chat_room_id': roomId},
|
||||
endpoint: 'messager',
|
||||
final subscribedNotifier = ref.watch(
|
||||
currentSubscribedChatIdProvider.notifier,
|
||||
);
|
||||
|
||||
ref.onCancel(() {
|
||||
talker.info('[MessageSubscriber] Unsubscribing room $roomId');
|
||||
subscribedNotifier.set(null);
|
||||
try {
|
||||
_sendMessage!(
|
||||
jsonEncode(
|
||||
WebSocketPacket(
|
||||
type: 'messages.unsubscribe',
|
||||
data: {'chat_room_id': roomId},
|
||||
endpoint: 'messager',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
_wsSubscription?.cancel();
|
||||
_typingCleanupTimer?.cancel();
|
||||
_typingCooldownTimer?.cancel();
|
||||
_periodicSubscribeTimer?.cancel();
|
||||
);
|
||||
} catch (e, stackTrace) {
|
||||
talker.error(
|
||||
'[MessageSubscriber] Error sending unsubscribe message for room $roomId: $e\n$stackTrace',
|
||||
);
|
||||
}
|
||||
try {
|
||||
_cleanupResources();
|
||||
} catch (e, stackTrace) {
|
||||
talker.error(
|
||||
'[MessageSubscriber] Error during cleanup for room $roomId: $e\n$stackTrace',
|
||||
);
|
||||
}
|
||||
try {
|
||||
if (_typingCooldownTimer != null) {
|
||||
_typingCooldownTimer!.cancel();
|
||||
}
|
||||
} catch (e, stackTrace) {
|
||||
talker.error(
|
||||
'[MessageSubscriber] Error cancelling typing cooldown timer for room $roomId: $e\n$stackTrace',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
return _typingStatuses;
|
||||
@@ -201,8 +243,8 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier {
|
||||
|
||||
void sendReadReceipt() {
|
||||
// Send websocket packet
|
||||
final wsState = ref.read(websocketStateProvider.notifier);
|
||||
wsState.sendMessage(
|
||||
if (_sendMessage == null) return;
|
||||
_sendMessage!(
|
||||
jsonEncode(
|
||||
WebSocketPacket(
|
||||
type: 'messages.read',
|
||||
@@ -218,8 +260,8 @@ class ChatSubscribeNotifier extends _$ChatSubscribeNotifier {
|
||||
if (_typingCooldownTimer != null) return;
|
||||
|
||||
// Send typing status immediately
|
||||
final wsState = ref.read(websocketStateProvider.notifier);
|
||||
wsState.sendMessage(
|
||||
if (_sendMessage == null) return;
|
||||
_sendMessage!(
|
||||
jsonEncode(
|
||||
WebSocketPacket(
|
||||
type: 'messages.typing',
|
||||
|
||||
@@ -10,11 +10,11 @@ part of 'chat_subscribe.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(ChatSubscribeNotifier)
|
||||
const chatSubscribeProvider = ChatSubscribeNotifierFamily._();
|
||||
final chatSubscribeProvider = ChatSubscribeNotifierFamily._();
|
||||
|
||||
final class ChatSubscribeNotifierProvider
|
||||
extends $NotifierProvider<ChatSubscribeNotifier, List<SnChatMember>> {
|
||||
const ChatSubscribeNotifierProvider._({
|
||||
ChatSubscribeNotifierProvider._({
|
||||
required ChatSubscribeNotifierFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -59,7 +59,7 @@ final class ChatSubscribeNotifierProvider
|
||||
}
|
||||
|
||||
String _$chatSubscribeNotifierHash() =>
|
||||
r'a05739450e6d23eb3d8c0a96078887b2b58ffd10';
|
||||
r'b7624ae45ace2944a88f8b4d14ddce556c236371';
|
||||
|
||||
final class ChatSubscribeNotifierFamily extends $Family
|
||||
with
|
||||
@@ -70,7 +70,7 @@ final class ChatSubscribeNotifierFamily extends $Family
|
||||
List<SnChatMember>,
|
||||
String
|
||||
> {
|
||||
const ChatSubscribeNotifierFamily._()
|
||||
ChatSubscribeNotifierFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'chatSubscribeProvider',
|
||||
@@ -94,7 +94,6 @@ abstract class _$ChatSubscribeNotifier extends $Notifier<List<SnChatMember>> {
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build(_$args);
|
||||
final ref = this.ref as $Ref<List<SnChatMember>, List<SnChatMember>>;
|
||||
final element =
|
||||
ref.element
|
||||
@@ -104,6 +103,6 @@ abstract class _$ChatSubscribeNotifier extends $Notifier<List<SnChatMember>> {
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, () => build(_$args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ part of 'chat_summary.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(ChatUnreadCountNotifier)
|
||||
const chatUnreadCountProvider = ChatUnreadCountNotifierProvider._();
|
||||
final chatUnreadCountProvider = ChatUnreadCountNotifierProvider._();
|
||||
|
||||
final class ChatUnreadCountNotifierProvider
|
||||
extends $AsyncNotifierProvider<ChatUnreadCountNotifier, int> {
|
||||
const ChatUnreadCountNotifierProvider._()
|
||||
ChatUnreadCountNotifierProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -41,7 +41,6 @@ abstract class _$ChatUnreadCountNotifier extends $AsyncNotifier<int> {
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref = this.ref as $Ref<AsyncValue<int>, int>;
|
||||
final element =
|
||||
ref.element
|
||||
@@ -51,16 +50,16 @@ abstract class _$ChatUnreadCountNotifier extends $AsyncNotifier<int> {
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
|
||||
@ProviderFor(ChatSummary)
|
||||
const chatSummaryProvider = ChatSummaryProvider._();
|
||||
final chatSummaryProvider = ChatSummaryProvider._();
|
||||
|
||||
final class ChatSummaryProvider
|
||||
extends $AsyncNotifierProvider<ChatSummary, Map<String, SnChatSummary>> {
|
||||
const ChatSummaryProvider._()
|
||||
ChatSummaryProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -87,7 +86,6 @@ abstract class _$ChatSummary
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref =
|
||||
this.ref
|
||||
as $Ref<
|
||||
@@ -105,6 +103,6 @@ abstract class _$ChatSummary
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ part of 'messages_notifier.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(MessagesNotifier)
|
||||
const messagesProvider = MessagesNotifierFamily._();
|
||||
final messagesProvider = MessagesNotifierFamily._();
|
||||
|
||||
final class MessagesNotifierProvider
|
||||
extends $AsyncNotifierProvider<MessagesNotifier, List<LocalChatMessage>> {
|
||||
const MessagesNotifierProvider._({
|
||||
MessagesNotifierProvider._({
|
||||
required MessagesNotifierFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -61,7 +61,7 @@ final class MessagesNotifierFamily extends $Family
|
||||
FutureOr<List<LocalChatMessage>>,
|
||||
String
|
||||
> {
|
||||
const MessagesNotifierFamily._()
|
||||
MessagesNotifierFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'messagesProvider',
|
||||
@@ -86,7 +86,6 @@ abstract class _$MessagesNotifier
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build(_$args);
|
||||
final ref =
|
||||
this.ref
|
||||
as $Ref<AsyncValue<List<LocalChatMessage>>, List<LocalChatMessage>>;
|
||||
@@ -101,6 +100,6 @@ abstract class _$MessagesNotifier
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, () => build(_$args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ Map<String, dynamic> _$ThemeColorsToJson(_ThemeColors instance) =>
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(AppSettingsNotifier)
|
||||
const appSettingsProvider = AppSettingsNotifierProvider._();
|
||||
final appSettingsProvider = AppSettingsNotifierProvider._();
|
||||
|
||||
final class AppSettingsNotifierProvider
|
||||
extends $NotifierProvider<AppSettingsNotifier, AppSettings> {
|
||||
const AppSettingsNotifierProvider._()
|
||||
AppSettingsNotifierProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -72,7 +72,6 @@ abstract class _$AppSettingsNotifier extends $Notifier<AppSettings> {
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref = this.ref as $Ref<AppSettings, AppSettings>;
|
||||
final element =
|
||||
ref.element
|
||||
@@ -82,6 +81,6 @@ abstract class _$AppSettingsNotifier extends $Notifier<AppSettings> {
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'file_list.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(billingUsage)
|
||||
const billingUsageProvider = BillingUsageProvider._();
|
||||
final billingUsageProvider = BillingUsageProvider._();
|
||||
|
||||
final class BillingUsageProvider
|
||||
extends
|
||||
@@ -22,7 +22,7 @@ final class BillingUsageProvider
|
||||
with
|
||||
$FutureModifier<Map<String, dynamic>?>,
|
||||
$FutureProvider<Map<String, dynamic>?> {
|
||||
const BillingUsageProvider._()
|
||||
BillingUsageProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -51,7 +51,7 @@ final class BillingUsageProvider
|
||||
String _$billingUsageHash() => r'58d8bc774868d60781574c85d6b25869a79c57aa';
|
||||
|
||||
@ProviderFor(billingQuota)
|
||||
const billingQuotaProvider = BillingQuotaProvider._();
|
||||
final billingQuotaProvider = BillingQuotaProvider._();
|
||||
|
||||
final class BillingQuotaProvider
|
||||
extends
|
||||
@@ -63,7 +63,7 @@ final class BillingQuotaProvider
|
||||
with
|
||||
$FutureModifier<Map<String, dynamic>?>,
|
||||
$FutureProvider<Map<String, dynamic>?> {
|
||||
const BillingQuotaProvider._()
|
||||
BillingQuotaProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'file_references.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(fileReferences)
|
||||
const fileReferencesProvider = FileReferencesFamily._();
|
||||
final fileReferencesProvider = FileReferencesFamily._();
|
||||
|
||||
final class FileReferencesProvider
|
||||
extends
|
||||
@@ -20,7 +20,7 @@ final class FileReferencesProvider
|
||||
FutureOr<List<Reference>>
|
||||
>
|
||||
with $FutureModifier<List<Reference>>, $FutureProvider<List<Reference>> {
|
||||
const FileReferencesProvider._({
|
||||
FileReferencesProvider._({
|
||||
required FileReferencesFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -68,7 +68,7 @@ String _$fileReferencesHash() => r'd66c678c221f61978bdb242b98e6dbe31d0c204b';
|
||||
|
||||
final class FileReferencesFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<List<Reference>>, String> {
|
||||
const FileReferencesFamily._()
|
||||
FileReferencesFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'fileReferencesProvider',
|
||||
|
||||
@@ -12,7 +12,7 @@ part of 'event_calendar.dart';
|
||||
/// This can be used anywhere in the app where calendar data is needed
|
||||
|
||||
@ProviderFor(eventCalendar)
|
||||
const eventCalendarProvider = EventCalendarFamily._();
|
||||
final eventCalendarProvider = EventCalendarFamily._();
|
||||
|
||||
/// Provider for fetching event calendar data
|
||||
/// This can be used anywhere in the app where calendar data is needed
|
||||
@@ -29,7 +29,7 @@ final class EventCalendarProvider
|
||||
$FutureProvider<List<SnEventCalendarEntry>> {
|
||||
/// Provider for fetching event calendar data
|
||||
/// This can be used anywhere in the app where calendar data is needed
|
||||
const EventCalendarProvider._({
|
||||
EventCalendarProvider._({
|
||||
required EventCalendarFamily super.from,
|
||||
required EventCalendarQuery super.argument,
|
||||
}) : super(
|
||||
@@ -84,7 +84,7 @@ final class EventCalendarFamily extends $Family
|
||||
FutureOr<List<SnEventCalendarEntry>>,
|
||||
EventCalendarQuery
|
||||
> {
|
||||
const EventCalendarFamily._()
|
||||
EventCalendarFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'eventCalendarProvider',
|
||||
|
||||
@@ -10,11 +10,11 @@ part of 'link_preview.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(LinkPreview)
|
||||
const linkPreviewProvider = LinkPreviewFamily._();
|
||||
final linkPreviewProvider = LinkPreviewFamily._();
|
||||
|
||||
final class LinkPreviewProvider
|
||||
extends $AsyncNotifierProvider<LinkPreview, SnScrappedLink?> {
|
||||
const LinkPreviewProvider._({
|
||||
LinkPreviewProvider._({
|
||||
required LinkPreviewFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -61,7 +61,7 @@ final class LinkPreviewFamily extends $Family
|
||||
FutureOr<SnScrappedLink?>,
|
||||
String
|
||||
> {
|
||||
const LinkPreviewFamily._()
|
||||
LinkPreviewFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'linkPreviewProvider',
|
||||
@@ -85,7 +85,6 @@ abstract class _$LinkPreview extends $AsyncNotifier<SnScrappedLink?> {
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build(_$args);
|
||||
final ref = this.ref as $Ref<AsyncValue<SnScrappedLink?>, SnScrappedLink?>;
|
||||
final element =
|
||||
ref.element
|
||||
@@ -95,6 +94,6 @@ abstract class _$LinkPreview extends $AsyncNotifier<SnScrappedLink?> {
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, () => build(_$args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ part of 'network.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(NetworkStatusNotifier)
|
||||
const networkStatusProvider = NetworkStatusNotifierProvider._();
|
||||
final networkStatusProvider = NetworkStatusNotifierProvider._();
|
||||
|
||||
final class NetworkStatusNotifierProvider
|
||||
extends $NotifierProvider<NetworkStatusNotifier, NetworkStatus> {
|
||||
const NetworkStatusNotifierProvider._()
|
||||
NetworkStatusNotifierProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -49,7 +49,6 @@ abstract class _$NetworkStatusNotifier extends $Notifier<NetworkStatus> {
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final created = build();
|
||||
final ref = this.ref as $Ref<NetworkStatus, NetworkStatus>;
|
||||
final element =
|
||||
ref.element
|
||||
@@ -59,6 +58,6 @@ abstract class _$NetworkStatusNotifier extends $Notifier<NetworkStatus> {
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleValue(ref, created);
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'site_files.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(siteFiles)
|
||||
const siteFilesProvider = SiteFilesFamily._();
|
||||
final siteFilesProvider = SiteFilesFamily._();
|
||||
|
||||
final class SiteFilesProvider
|
||||
extends
|
||||
@@ -22,7 +22,7 @@ final class SiteFilesProvider
|
||||
with
|
||||
$FutureModifier<List<SnSiteFileEntry>>,
|
||||
$FutureProvider<List<SnSiteFileEntry>> {
|
||||
const SiteFilesProvider._({
|
||||
SiteFilesProvider._({
|
||||
required SiteFilesFamily super.from,
|
||||
required ({String siteId, String? path}) super.argument,
|
||||
}) : super(
|
||||
@@ -74,7 +74,7 @@ final class SiteFilesFamily extends $Family
|
||||
FutureOr<List<SnSiteFileEntry>>,
|
||||
({String siteId, String? path})
|
||||
> {
|
||||
const SiteFilesFamily._()
|
||||
SiteFilesFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'siteFilesProvider',
|
||||
@@ -91,7 +91,7 @@ final class SiteFilesFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(siteFileContent)
|
||||
const siteFileContentProvider = SiteFileContentFamily._();
|
||||
final siteFileContentProvider = SiteFileContentFamily._();
|
||||
|
||||
final class SiteFileContentProvider
|
||||
extends
|
||||
@@ -101,7 +101,7 @@ final class SiteFileContentProvider
|
||||
FutureOr<SnFileContent>
|
||||
>
|
||||
with $FutureModifier<SnFileContent>, $FutureProvider<SnFileContent> {
|
||||
const SiteFileContentProvider._({
|
||||
SiteFileContentProvider._({
|
||||
required SiteFileContentFamily super.from,
|
||||
required ({String siteId, String relativePath}) super.argument,
|
||||
}) : super(
|
||||
@@ -157,7 +157,7 @@ final class SiteFileContentFamily extends $Family
|
||||
FutureOr<SnFileContent>,
|
||||
({String siteId, String relativePath})
|
||||
> {
|
||||
const SiteFileContentFamily._()
|
||||
SiteFileContentFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'siteFileContentProvider',
|
||||
@@ -179,12 +179,12 @@ final class SiteFileContentFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(siteFileContentRaw)
|
||||
const siteFileContentRawProvider = SiteFileContentRawFamily._();
|
||||
final siteFileContentRawProvider = SiteFileContentRawFamily._();
|
||||
|
||||
final class SiteFileContentRawProvider
|
||||
extends $FunctionalProvider<AsyncValue<String>, String, FutureOr<String>>
|
||||
with $FutureModifier<String>, $FutureProvider<String> {
|
||||
const SiteFileContentRawProvider._({
|
||||
SiteFileContentRawProvider._({
|
||||
required SiteFileContentRawFamily super.from,
|
||||
required ({String siteId, String relativePath}) super.argument,
|
||||
}) : super(
|
||||
@@ -240,7 +240,7 @@ final class SiteFileContentRawFamily extends $Family
|
||||
FutureOr<String>,
|
||||
({String siteId, String relativePath})
|
||||
> {
|
||||
const SiteFileContentRawFamily._()
|
||||
SiteFileContentRawFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'siteFileContentRawProvider',
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'site_pages.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(sitePages)
|
||||
const sitePagesProvider = SitePagesFamily._();
|
||||
final sitePagesProvider = SitePagesFamily._();
|
||||
|
||||
final class SitePagesProvider
|
||||
extends
|
||||
@@ -22,7 +22,7 @@ final class SitePagesProvider
|
||||
with
|
||||
$FutureModifier<List<SnPublicationPage>>,
|
||||
$FutureProvider<List<SnPublicationPage>> {
|
||||
const SitePagesProvider._({
|
||||
SitePagesProvider._({
|
||||
required SitePagesFamily super.from,
|
||||
required (String, String) super.argument,
|
||||
}) : super(
|
||||
@@ -74,7 +74,7 @@ final class SitePagesFamily extends $Family
|
||||
FutureOr<List<SnPublicationPage>>,
|
||||
(String, String)
|
||||
> {
|
||||
const SitePagesFamily._()
|
||||
SitePagesFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'sitePagesProvider',
|
||||
@@ -91,7 +91,7 @@ final class SitePagesFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(sitePage)
|
||||
const sitePageProvider = SitePageFamily._();
|
||||
final sitePageProvider = SitePageFamily._();
|
||||
|
||||
final class SitePageProvider
|
||||
extends
|
||||
@@ -103,7 +103,7 @@ final class SitePageProvider
|
||||
with
|
||||
$FutureModifier<SnPublicationPage>,
|
||||
$FutureProvider<SnPublicationPage> {
|
||||
const SitePageProvider._({
|
||||
SitePageProvider._({
|
||||
required SitePageFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -151,7 +151,7 @@ String _$sitePageHash() => r'542f70c5b103fe34d7cf7eb0821d52f017022efc';
|
||||
|
||||
final class SitePageFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnPublicationPage>, String> {
|
||||
const SitePageFamily._()
|
||||
SitePageFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'sitePageProvider',
|
||||
|
||||
@@ -10,12 +10,12 @@ part of 'theme.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(theme)
|
||||
const themeProvider = ThemeProvider._();
|
||||
final themeProvider = ThemeProvider._();
|
||||
|
||||
final class ThemeProvider
|
||||
extends $FunctionalProvider<ThemeSet, ThemeSet, ThemeSet>
|
||||
with $Provider<ThemeSet> {
|
||||
const ThemeProvider._()
|
||||
ThemeProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
|
||||
@@ -10,12 +10,12 @@ part of 'translate.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(translateString)
|
||||
const translateStringProvider = TranslateStringFamily._();
|
||||
final translateStringProvider = TranslateStringFamily._();
|
||||
|
||||
final class TranslateStringProvider
|
||||
extends $FunctionalProvider<AsyncValue<String>, String, FutureOr<String>>
|
||||
with $FutureModifier<String>, $FutureProvider<String> {
|
||||
const TranslateStringProvider._({
|
||||
TranslateStringProvider._({
|
||||
required TranslateStringFamily super.from,
|
||||
required TranslateQuery super.argument,
|
||||
}) : super(
|
||||
@@ -62,7 +62,7 @@ String _$translateStringHash() => r'51d638cf07cbf3ffa9469298f5bd9c667bc0ccb7';
|
||||
|
||||
final class TranslateStringFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<String>, TranslateQuery> {
|
||||
const TranslateStringFamily._()
|
||||
TranslateStringFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'translateStringProvider',
|
||||
@@ -79,12 +79,12 @@ final class TranslateStringFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(detectStringLanguage)
|
||||
const detectStringLanguageProvider = DetectStringLanguageFamily._();
|
||||
final detectStringLanguageProvider = DetectStringLanguageFamily._();
|
||||
|
||||
final class DetectStringLanguageProvider
|
||||
extends $FunctionalProvider<String?, String?, String?>
|
||||
with $Provider<String?> {
|
||||
const DetectStringLanguageProvider._({
|
||||
DetectStringLanguageProvider._({
|
||||
required DetectStringLanguageFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -140,7 +140,7 @@ String _$detectStringLanguageHash() =>
|
||||
|
||||
final class DetectStringLanguageFamily extends $Family
|
||||
with $FunctionalFamilyOverride<String?, String> {
|
||||
const DetectStringLanguageFamily._()
|
||||
DetectStringLanguageFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'detectStringLanguageProvider',
|
||||
|
||||
@@ -8,7 +8,7 @@ import 'package:island/pods/network.dart';
|
||||
final webFeedListProvider = FutureProvider.autoDispose
|
||||
.family<List<SnWebFeed>, String>((ref, pubName) async {
|
||||
final client = ref.watch(apiClientProvider);
|
||||
final response = await client.get('/sphere/publishers/$pubName/feeds');
|
||||
final response = await client.get('/insight/publishers/$pubName/feeds');
|
||||
return (response.data as List)
|
||||
.map((json) => SnWebFeed.fromJson(json))
|
||||
.toList();
|
||||
|
||||
117
lib/route.dart
117
lib/route.dart
@@ -6,8 +6,6 @@ import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/screens/about.dart';
|
||||
import 'package:island/screens/activitypub/list.dart';
|
||||
import 'package:island/screens/activitypub/search.dart';
|
||||
import 'package:island/screens/dashboard/dash.dart';
|
||||
import 'package:island/screens/developers/app_detail.dart';
|
||||
import 'package:island/screens/developers/bot_detail.dart';
|
||||
@@ -20,7 +18,6 @@ import 'package:island/screens/files/file_list.dart';
|
||||
import 'package:island/screens/files/file_detail.dart';
|
||||
import 'package:island/screens/posts/post_categories_list.dart';
|
||||
import 'package:island/screens/posts/post_category_detail.dart';
|
||||
import 'package:island/screens/posts/post_search.dart';
|
||||
import 'package:island/screens/search.dart';
|
||||
import 'package:island/widgets/app_scaffold.dart';
|
||||
import 'package:island/widgets/app_wrapper.dart';
|
||||
@@ -172,6 +169,7 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
builder: (context, state) => const AboutScreen(),
|
||||
),
|
||||
|
||||
// File routes
|
||||
GoRoute(
|
||||
name: 'fileDetail',
|
||||
path: '/files/:id',
|
||||
@@ -188,30 +186,56 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
},
|
||||
),
|
||||
|
||||
// Post routes
|
||||
GoRoute(
|
||||
name: 'postShuffle',
|
||||
path: '/posts/shuffle',
|
||||
builder: (context, state) => const PostShuffleScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postCategories',
|
||||
path: '/posts/categories',
|
||||
builder: (context, state) => const PostCategoriesListScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postCategoryDetail',
|
||||
path: '/posts/categories/:slug',
|
||||
builder: (context, state) {
|
||||
final slug = state.pathParameters['slug']!;
|
||||
return PostCategoryDetailScreen(slug: slug, isCategory: true);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postTagDetail',
|
||||
path: '/posts/tags/:slug',
|
||||
builder: (context, state) {
|
||||
final slug = state.pathParameters['slug']!;
|
||||
return PostCategoryDetailScreen(slug: slug, isCategory: false);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postDetail',
|
||||
path: '/posts/:id',
|
||||
builder: (context, state) {
|
||||
final id = state.pathParameters['id']!;
|
||||
return PostDetailScreen(id: id);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
name: 'publisherProfile',
|
||||
path: '/publishers/:name',
|
||||
builder: (context, state) {
|
||||
final name = state.pathParameters['name']!;
|
||||
return PublisherProfileScreen(name: name);
|
||||
},
|
||||
),
|
||||
|
||||
GoRoute(
|
||||
name: 'universalSearch',
|
||||
path: '/search',
|
||||
builder: (context, state) => const UniversalSearchScreen(),
|
||||
),
|
||||
|
||||
GoRoute(
|
||||
name: 'activitypubSearch',
|
||||
path: '/activitypub/search',
|
||||
builder: (context, state) => const ApSearchScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'activitypubFollowing',
|
||||
path: '/activitypub/following',
|
||||
builder: (context, state) =>
|
||||
const ApListScreen(type: ActivityPubListType.following),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'activitypubFollowers',
|
||||
path: '/activitypub/followers',
|
||||
builder: (context, state) =>
|
||||
const ApListScreen(type: ActivityPubListType.followers),
|
||||
),
|
||||
|
||||
// Main tabs with TabsScreen shell
|
||||
ShellRoute(
|
||||
navigatorKey: _tabsShellKey,
|
||||
@@ -239,56 +263,7 @@ final routerProvider = Provider<GoRouter>((ref) {
|
||||
transitionsBuilder: _tabPagesTransitionBuilder,
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postSearch',
|
||||
path: '/posts/search',
|
||||
builder: (context, state) => const PostSearchScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postShuffle',
|
||||
path: '/posts/shuffle',
|
||||
builder: (context, state) => const PostShuffleScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postCategories',
|
||||
path: '/posts/categories',
|
||||
builder: (context, state) => const PostCategoriesListScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postCategoryDetail',
|
||||
path: '/posts/categories/:slug',
|
||||
builder: (context, state) {
|
||||
final slug = state.pathParameters['slug']!;
|
||||
return PostCategoryDetailScreen(slug: slug, isCategory: true);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postTagDetail',
|
||||
path: '/posts/tags/:slug',
|
||||
builder: (context, state) {
|
||||
final slug = state.pathParameters['slug']!;
|
||||
return PostCategoryDetailScreen(
|
||||
slug: slug,
|
||||
isCategory: false,
|
||||
);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
name: 'postDetail',
|
||||
path: '/posts/:id',
|
||||
builder: (context, state) {
|
||||
final id = state.pathParameters['id']!;
|
||||
return PostDetailScreen(id: id);
|
||||
},
|
||||
),
|
||||
GoRoute(
|
||||
name: 'publisherProfile',
|
||||
path: '/publishers/:name',
|
||||
builder: (context, state) {
|
||||
final name = state.pathParameters['name']!;
|
||||
return PublisherProfileScreen(name: name);
|
||||
},
|
||||
),
|
||||
|
||||
GoRoute(
|
||||
name: 'discoveryRealms',
|
||||
path: '/discovery/realms',
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import 'package:island/screens/activitypub/activitypub.dart';
|
||||
|
||||
Add to Explore tab routes, after postCategoryDetail route:
|
||||
|
||||
GoRoute(
|
||||
name: 'activitypubSearch',
|
||||
path: '/activitypub/search',
|
||||
builder: (context, state) => const ActivityPubSearchScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'activitypubFollowing',
|
||||
path: '/activitypub/following',
|
||||
builder: (context, state) => const ActivityPubListScreen(
|
||||
type: ActivityPubListType.following,
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
name: 'activitypubFollowers',
|
||||
path: '/activitypub/followers',
|
||||
builder: (context, state) => const ActivityPubListScreen(
|
||||
type: ActivityPubListType.followers,
|
||||
),
|
||||
),
|
||||
@@ -74,7 +74,7 @@ class AccountScreen extends HookConsumerWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (user.value?.profile.background?.id != null)
|
||||
if (user.value?.profile.background != null)
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
@@ -112,7 +112,7 @@ class AccountScreen extends HookConsumerWidget {
|
||||
Builder(
|
||||
builder: (context) {
|
||||
final hasBackground =
|
||||
user.value?.profile.background?.id != null;
|
||||
user.value?.profile.background != null;
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
spacing: hasBackground ? 0 : 16,
|
||||
|
||||
@@ -10,12 +10,12 @@ part of 'credits.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(socialCredits)
|
||||
const socialCreditsProvider = SocialCreditsProvider._();
|
||||
final socialCreditsProvider = SocialCreditsProvider._();
|
||||
|
||||
final class SocialCreditsProvider
|
||||
extends $FunctionalProvider<AsyncValue<double>, double, FutureOr<double>>
|
||||
with $FutureModifier<double>, $FutureProvider<double> {
|
||||
const SocialCreditsProvider._()
|
||||
SocialCreditsProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'account_settings.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(authFactors)
|
||||
const authFactorsProvider = AuthFactorsProvider._();
|
||||
final authFactorsProvider = AuthFactorsProvider._();
|
||||
|
||||
final class AuthFactorsProvider
|
||||
extends
|
||||
@@ -22,7 +22,7 @@ final class AuthFactorsProvider
|
||||
with
|
||||
$FutureModifier<List<SnAuthFactor>>,
|
||||
$FutureProvider<List<SnAuthFactor>> {
|
||||
const AuthFactorsProvider._()
|
||||
AuthFactorsProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -51,7 +51,7 @@ final class AuthFactorsProvider
|
||||
String _$authFactorsHash() => r'ed87d7dbd421fef0a5620416727c3dc598c97ef5';
|
||||
|
||||
@ProviderFor(contactMethods)
|
||||
const contactMethodsProvider = ContactMethodsProvider._();
|
||||
final contactMethodsProvider = ContactMethodsProvider._();
|
||||
|
||||
final class ContactMethodsProvider
|
||||
extends
|
||||
@@ -63,7 +63,7 @@ final class ContactMethodsProvider
|
||||
with
|
||||
$FutureModifier<List<SnContactMethod>>,
|
||||
$FutureProvider<List<SnContactMethod>> {
|
||||
const ContactMethodsProvider._()
|
||||
ContactMethodsProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -92,7 +92,7 @@ final class ContactMethodsProvider
|
||||
String _$contactMethodsHash() => r'1d3d03e9ffbf36126236558ead22cb7d88bb9cb2';
|
||||
|
||||
@ProviderFor(accountConnections)
|
||||
const accountConnectionsProvider = AccountConnectionsProvider._();
|
||||
final accountConnectionsProvider = AccountConnectionsProvider._();
|
||||
|
||||
final class AccountConnectionsProvider
|
||||
extends
|
||||
@@ -104,7 +104,7 @@ final class AccountConnectionsProvider
|
||||
with
|
||||
$FutureModifier<List<SnAccountConnection>>,
|
||||
$FutureProvider<List<SnAccountConnection>> {
|
||||
const AccountConnectionsProvider._()
|
||||
AccountConnectionsProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
|
||||
@@ -74,14 +74,10 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
|
||||
submitting.value = true;
|
||||
try {
|
||||
final cloudFile =
|
||||
await FileUploader.createCloudFile(
|
||||
ref: ref,
|
||||
fileData: UniversalFile(
|
||||
data: result,
|
||||
type: UniversalFileType.image,
|
||||
),
|
||||
).future;
|
||||
final cloudFile = await FileUploader.createCloudFile(
|
||||
ref: ref,
|
||||
fileData: UniversalFile(data: result, type: UniversalFileType.image),
|
||||
).future;
|
||||
if (cloudFile == null) {
|
||||
throw ArgumentError('Failed to upload the file...');
|
||||
}
|
||||
@@ -188,8 +184,9 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
if (usernameColorType.value == 'gradient') ...{
|
||||
if (usernameColorDirection.text.isNotEmpty)
|
||||
'direction': usernameColorDirection.text,
|
||||
'colors':
|
||||
usernameColorColors.value.where((c) => c.isNotEmpty).toList(),
|
||||
'colors': usernameColorColors.value
|
||||
.where((c) => c.isNotEmpty)
|
||||
.toList(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -206,18 +203,16 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
'time_zone': timeZoneController.text,
|
||||
'birthday': birthday.value?.toUtc().toIso8601String(),
|
||||
'username_color': usernameColorData,
|
||||
'links':
|
||||
links.value
|
||||
.where((e) => e.name.isNotEmpty && e.url.isNotEmpty)
|
||||
.toList(),
|
||||
'links': links.value
|
||||
.where((e) => e.name.isNotEmpty && e.url.isNotEmpty)
|
||||
.toList(),
|
||||
},
|
||||
);
|
||||
final userNotifier = ref.read(userInfoProvider.notifier);
|
||||
userNotifier.fetchUser();
|
||||
links.value =
|
||||
links.value
|
||||
.where((e) => e.name.isNotEmpty && e.url.isNotEmpty)
|
||||
.toList();
|
||||
links.value = links.value
|
||||
.where((e) => e.name.isNotEmpty && e.url.isNotEmpty)
|
||||
.toList();
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
} finally {
|
||||
@@ -244,13 +239,12 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
GestureDetector(
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
child:
|
||||
user.value!.profile.background?.id != null
|
||||
? CloudImageWidget(
|
||||
fileId: user.value!.profile.background!.id,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
child: user.value!.profile.background != null
|
||||
? CloudImageWidget(
|
||||
file: user.value!.profile.background,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
onTap: () {
|
||||
updateProfilePicture('background');
|
||||
@@ -261,7 +255,7 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
bottom: -32,
|
||||
child: GestureDetector(
|
||||
child: ProfilePictureWidget(
|
||||
fileId: user.value!.profile.picture?.id,
|
||||
file: user.value!.profile.picture,
|
||||
radius: 40,
|
||||
),
|
||||
onTap: () {
|
||||
@@ -291,14 +285,14 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
),
|
||||
controller: usernameController,
|
||||
readOnly: true,
|
||||
onTapOutside:
|
||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(labelText: 'nickname'.tr()),
|
||||
controller: nicknameController,
|
||||
onTapOutside:
|
||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
DropdownButtonFormField2<String>(
|
||||
decoration: InputDecoration(
|
||||
@@ -385,9 +379,8 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
labelText: 'firstName'.tr(),
|
||||
),
|
||||
controller: firstNameController,
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@@ -396,9 +389,8 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
labelText: 'middleName'.tr(),
|
||||
),
|
||||
controller: middleNameController,
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@@ -407,9 +399,8 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
labelText: 'lastName'.tr(),
|
||||
),
|
||||
controller: lastNameController,
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -423,8 +414,8 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
maxLines: null,
|
||||
minLines: 3,
|
||||
controller: bioController,
|
||||
onTapOutside:
|
||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
Row(
|
||||
spacing: 16,
|
||||
@@ -445,33 +436,34 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
onSelected: (String selection) {
|
||||
genderController.text = selection;
|
||||
},
|
||||
fieldViewBuilder: (
|
||||
context,
|
||||
controller,
|
||||
focusNode,
|
||||
onFieldSubmitted,
|
||||
) {
|
||||
// Initialize the controller with the current value
|
||||
if (controller.text.isEmpty &&
|
||||
genderController.text.isNotEmpty) {
|
||||
controller.text = genderController.text;
|
||||
}
|
||||
fieldViewBuilder:
|
||||
(
|
||||
context,
|
||||
controller,
|
||||
focusNode,
|
||||
onFieldSubmitted,
|
||||
) {
|
||||
// Initialize the controller with the current value
|
||||
if (controller.text.isEmpty &&
|
||||
genderController.text.isNotEmpty) {
|
||||
controller.text = genderController.text;
|
||||
}
|
||||
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'gender'.tr(),
|
||||
),
|
||||
onChanged: (value) {
|
||||
genderController.text = value;
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'gender'.tr(),
|
||||
),
|
||||
onChanged: (value) {
|
||||
genderController.text = value;
|
||||
},
|
||||
onTapOutside: (_) => FocusManager
|
||||
.instance
|
||||
.primaryFocus
|
||||
?.unfocus(),
|
||||
);
|
||||
},
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus
|
||||
?.unfocus(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@@ -480,9 +472,8 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
labelText: 'pronouns'.tr(),
|
||||
),
|
||||
controller: pronounsController,
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -496,9 +487,8 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
labelText: 'location'.tr(),
|
||||
),
|
||||
controller: locationController,
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
@@ -507,8 +497,8 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
if (textEditingValue.text.isEmpty) {
|
||||
return const Iterable<String>.empty();
|
||||
}
|
||||
final lowercaseQuery =
|
||||
textEditingValue.text.toLowerCase();
|
||||
final lowercaseQuery = textEditingValue.text
|
||||
.toLowerCase();
|
||||
return getAvailableTz().where((tz) {
|
||||
return tz.toLowerCase().contains(lowercaseQuery);
|
||||
});
|
||||
@@ -516,46 +506,49 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
onSelected: (String selection) {
|
||||
timeZoneController.text = selection;
|
||||
},
|
||||
fieldViewBuilder: (
|
||||
context,
|
||||
controller,
|
||||
focusNode,
|
||||
onFieldSubmitted,
|
||||
) {
|
||||
// Sync the controller with timeZoneController when the widget is built
|
||||
if (controller.text != timeZoneController.text) {
|
||||
controller.text = timeZoneController.text;
|
||||
}
|
||||
fieldViewBuilder:
|
||||
(
|
||||
context,
|
||||
controller,
|
||||
focusNode,
|
||||
onFieldSubmitted,
|
||||
) {
|
||||
// Sync the controller with timeZoneController when the widget is built
|
||||
if (controller.text !=
|
||||
timeZoneController.text) {
|
||||
controller.text = timeZoneController.text;
|
||||
}
|
||||
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'timeZone'.tr(),
|
||||
suffix: InkWell(
|
||||
child: const Icon(
|
||||
Symbols.my_location,
|
||||
size: 18,
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'timeZone'.tr(),
|
||||
suffix: InkWell(
|
||||
child: const Icon(
|
||||
Symbols.my_location,
|
||||
size: 18,
|
||||
),
|
||||
onTap: () async {
|
||||
try {
|
||||
showLoadingModal(context);
|
||||
final machineTz =
|
||||
await getMachineTz();
|
||||
controller.text = machineTz;
|
||||
timeZoneController.text = machineTz;
|
||||
} finally {
|
||||
if (context.mounted) {
|
||||
hideLoadingModal(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
try {
|
||||
showLoadingModal(context);
|
||||
final machineTz = await getMachineTz();
|
||||
controller.text = machineTz;
|
||||
timeZoneController.text = machineTz;
|
||||
} finally {
|
||||
if (context.mounted) {
|
||||
hideLoadingModal(context);
|
||||
}
|
||||
}
|
||||
onChanged: (value) {
|
||||
timeZoneController.text = value;
|
||||
},
|
||||
),
|
||||
),
|
||||
onChanged: (value) {
|
||||
timeZoneController.text = value;
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
optionsViewBuilder: (context, onSelected, options) {
|
||||
return Align(
|
||||
alignment: Alignment.topLeft,
|
||||
@@ -569,21 +562,21 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
itemCount: options.length,
|
||||
itemBuilder: (
|
||||
BuildContext context,
|
||||
int index,
|
||||
) {
|
||||
final option = options.elementAt(index);
|
||||
return ListTile(
|
||||
title: Text(
|
||||
option,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
onTap: () {
|
||||
onSelected(option);
|
||||
itemBuilder:
|
||||
(BuildContext context, int index) {
|
||||
final option = options.elementAt(
|
||||
index,
|
||||
);
|
||||
return ListTile(
|
||||
title: Text(
|
||||
option,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
onTap: () {
|
||||
onSelected(option);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -644,10 +637,9 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerHighest,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
@@ -664,25 +656,23 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
type: usernameColorType.value,
|
||||
value:
|
||||
usernameColorType.value == 'plain' &&
|
||||
usernameColorValue
|
||||
.text
|
||||
.isNotEmpty
|
||||
? usernameColorValue.text
|
||||
: null,
|
||||
usernameColorValue.text.isNotEmpty
|
||||
? usernameColorValue.text
|
||||
: null,
|
||||
direction:
|
||||
usernameColorType.value ==
|
||||
'gradient' &&
|
||||
usernameColorDirection
|
||||
.text
|
||||
.isNotEmpty
|
||||
? usernameColorDirection.text
|
||||
: null,
|
||||
'gradient' &&
|
||||
usernameColorDirection
|
||||
.text
|
||||
.isNotEmpty
|
||||
? usernameColorDirection.text
|
||||
: null,
|
||||
colors:
|
||||
usernameColorType.value == 'gradient'
|
||||
? usernameColorColors.value
|
||||
.where((c) => c.isNotEmpty)
|
||||
.toList()
|
||||
: null,
|
||||
? usernameColorColors.value
|
||||
.where((c) => c.isNotEmpty)
|
||||
.toList()
|
||||
: null,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -724,10 +714,9 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
? Symbols.check_circle
|
||||
: Symbols.error,
|
||||
size: 16,
|
||||
color:
|
||||
canUseColor
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
color: canUseColor
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
const Gap(4),
|
||||
Text(
|
||||
@@ -736,10 +725,9 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
: 'upgradeRequired'.tr(),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color:
|
||||
canUseColor
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
color: canUseColor
|
||||
? Colors.green
|
||||
: Colors.red,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -792,34 +780,35 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
onSelected: (String selection) {
|
||||
usernameColorValue.text = selection;
|
||||
},
|
||||
fieldViewBuilder: (
|
||||
context,
|
||||
controller,
|
||||
focusNode,
|
||||
onFieldSubmitted,
|
||||
) {
|
||||
// Initialize the controller with the current value
|
||||
if (controller.text.isEmpty &&
|
||||
usernameColorValue.text.isNotEmpty) {
|
||||
controller.text = usernameColorValue.text;
|
||||
}
|
||||
fieldViewBuilder:
|
||||
(
|
||||
context,
|
||||
controller,
|
||||
focusNode,
|
||||
onFieldSubmitted,
|
||||
) {
|
||||
// Initialize the controller with the current value
|
||||
if (controller.text.isEmpty &&
|
||||
usernameColorValue.text.isNotEmpty) {
|
||||
controller.text = usernameColorValue.text;
|
||||
}
|
||||
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'colorValue'.tr(),
|
||||
hintText: 'e.g. red or #ff6600',
|
||||
),
|
||||
onChanged: (value) {
|
||||
usernameColorValue.text = value;
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'colorValue'.tr(),
|
||||
hintText: 'e.g. red or #ff6600',
|
||||
),
|
||||
onChanged: (value) {
|
||||
usernameColorValue.text = value;
|
||||
},
|
||||
onTapOutside: (_) => FocusManager
|
||||
.instance
|
||||
.primaryFocus
|
||||
?.unfocus(),
|
||||
);
|
||||
},
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus
|
||||
?.unfocus(),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (usernameColorType.value == 'gradient') ...[
|
||||
DropdownButtonFormField2<String>(
|
||||
@@ -862,10 +851,9 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
child: Text('gradientDirectionToTopLeft'.tr()),
|
||||
),
|
||||
],
|
||||
value:
|
||||
usernameColorDirection.text.isNotEmpty
|
||||
? usernameColorDirection.text
|
||||
: 'to right',
|
||||
value: usernameColorDirection.text.isNotEmpty
|
||||
? usernameColorDirection.text
|
||||
: 'to right',
|
||||
onChanged: (value) {
|
||||
usernameColorDirection.text = value ?? 'to right';
|
||||
},
|
||||
@@ -911,21 +899,19 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
onChanged: (value) {
|
||||
usernameColorColors.value[i] = value;
|
||||
},
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus
|
||||
?.unfocus(),
|
||||
onTapOutside: (_) => FocusManager
|
||||
.instance
|
||||
.primaryFocus
|
||||
?.unfocus(),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Symbols.delete),
|
||||
onPressed: () {
|
||||
usernameColorColors.value =
|
||||
usernameColorColors.value
|
||||
.whereIndexed(
|
||||
(idx, _) => idx != i,
|
||||
)
|
||||
.toList();
|
||||
usernameColorColors
|
||||
.value = usernameColorColors.value
|
||||
.whereIndexed((idx, _) => idx != i)
|
||||
.toList();
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -968,10 +954,10 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
name: value,
|
||||
);
|
||||
},
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus
|
||||
?.unfocus(),
|
||||
onTapOutside: (_) => FocusManager
|
||||
.instance
|
||||
.primaryFocus
|
||||
?.unfocus(),
|
||||
),
|
||||
),
|
||||
const Gap(8),
|
||||
@@ -987,19 +973,18 @@ class UpdateProfileScreen extends HookConsumerWidget {
|
||||
url: value,
|
||||
);
|
||||
},
|
||||
onTapOutside:
|
||||
(_) =>
|
||||
FocusManager.instance.primaryFocus
|
||||
?.unfocus(),
|
||||
onTapOutside: (_) => FocusManager
|
||||
.instance
|
||||
.primaryFocus
|
||||
?.unfocus(),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Symbols.delete),
|
||||
onPressed: () {
|
||||
links.value =
|
||||
links.value
|
||||
.whereIndexed((idx, _) => idx != i)
|
||||
.toList();
|
||||
links.value = links.value
|
||||
.whereIndexed((idx, _) => idx != i)
|
||||
.toList();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -57,7 +57,7 @@ class _AccountBasicInfo extends StatelessWidget {
|
||||
return Card(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final hasBackground = data.profile.background?.id != null;
|
||||
final hasBackground = data.profile.background != null;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -962,7 +962,7 @@ class AccountProfileScreen extends HookConsumerWidget {
|
||||
flexibleSpace: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: data.profile.background?.id != null
|
||||
child: data.profile.background != null
|
||||
? CloudImageWidget(
|
||||
file: data.profile.background,
|
||||
)
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'profile.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(account)
|
||||
const accountProvider = AccountFamily._();
|
||||
final accountProvider = AccountFamily._();
|
||||
|
||||
final class AccountProvider
|
||||
extends
|
||||
@@ -20,7 +20,7 @@ final class AccountProvider
|
||||
FutureOr<SnAccount>
|
||||
>
|
||||
with $FutureModifier<SnAccount>, $FutureProvider<SnAccount> {
|
||||
const AccountProvider._({
|
||||
AccountProvider._({
|
||||
required AccountFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -67,7 +67,7 @@ String _$accountHash() => r'5e2b7bd59151b4638a5561f495537c259f767123';
|
||||
|
||||
final class AccountFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnAccount>, String> {
|
||||
const AccountFamily._()
|
||||
AccountFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'accountProvider',
|
||||
@@ -84,7 +84,7 @@ final class AccountFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(accountBadges)
|
||||
const accountBadgesProvider = AccountBadgesFamily._();
|
||||
final accountBadgesProvider = AccountBadgesFamily._();
|
||||
|
||||
final class AccountBadgesProvider
|
||||
extends
|
||||
@@ -96,7 +96,7 @@ final class AccountBadgesProvider
|
||||
with
|
||||
$FutureModifier<List<SnAccountBadge>>,
|
||||
$FutureProvider<List<SnAccountBadge>> {
|
||||
const AccountBadgesProvider._({
|
||||
AccountBadgesProvider._({
|
||||
required AccountBadgesFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -144,7 +144,7 @@ String _$accountBadgesHash() => r'68db63f49827020beecbdbf20529520d0cd14a7d';
|
||||
|
||||
final class AccountBadgesFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<List<SnAccountBadge>>, String> {
|
||||
const AccountBadgesFamily._()
|
||||
AccountBadgesFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'accountBadgesProvider',
|
||||
@@ -161,13 +161,13 @@ final class AccountBadgesFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(accountAppbarForcegroundColor)
|
||||
const accountAppbarForcegroundColorProvider =
|
||||
final accountAppbarForcegroundColorProvider =
|
||||
AccountAppbarForcegroundColorFamily._();
|
||||
|
||||
final class AccountAppbarForcegroundColorProvider
|
||||
extends $FunctionalProvider<AsyncValue<Color?>, Color?, FutureOr<Color?>>
|
||||
with $FutureModifier<Color?>, $FutureProvider<Color?> {
|
||||
const AccountAppbarForcegroundColorProvider._({
|
||||
AccountAppbarForcegroundColorProvider._({
|
||||
required AccountAppbarForcegroundColorFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -216,7 +216,7 @@ String _$accountAppbarForcegroundColorHash() =>
|
||||
|
||||
final class AccountAppbarForcegroundColorFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<Color?>, String> {
|
||||
const AccountAppbarForcegroundColorFamily._()
|
||||
AccountAppbarForcegroundColorFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'accountAppbarForcegroundColorProvider',
|
||||
@@ -233,7 +233,7 @@ final class AccountAppbarForcegroundColorFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(accountDirectChat)
|
||||
const accountDirectChatProvider = AccountDirectChatFamily._();
|
||||
final accountDirectChatProvider = AccountDirectChatFamily._();
|
||||
|
||||
final class AccountDirectChatProvider
|
||||
extends
|
||||
@@ -243,7 +243,7 @@ final class AccountDirectChatProvider
|
||||
FutureOr<SnChatRoom?>
|
||||
>
|
||||
with $FutureModifier<SnChatRoom?>, $FutureProvider<SnChatRoom?> {
|
||||
const AccountDirectChatProvider._({
|
||||
AccountDirectChatProvider._({
|
||||
required AccountDirectChatFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -291,7 +291,7 @@ String _$accountDirectChatHash() => r'71bc9eed34a436a3743e8ef87f7aaae861fc5746';
|
||||
|
||||
final class AccountDirectChatFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnChatRoom?>, String> {
|
||||
const AccountDirectChatFamily._()
|
||||
AccountDirectChatFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'accountDirectChatProvider',
|
||||
@@ -308,7 +308,7 @@ final class AccountDirectChatFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(accountRelationship)
|
||||
const accountRelationshipProvider = AccountRelationshipFamily._();
|
||||
final accountRelationshipProvider = AccountRelationshipFamily._();
|
||||
|
||||
final class AccountRelationshipProvider
|
||||
extends
|
||||
@@ -318,7 +318,7 @@ final class AccountRelationshipProvider
|
||||
FutureOr<SnRelationship?>
|
||||
>
|
||||
with $FutureModifier<SnRelationship?>, $FutureProvider<SnRelationship?> {
|
||||
const AccountRelationshipProvider._({
|
||||
AccountRelationshipProvider._({
|
||||
required AccountRelationshipFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -367,7 +367,7 @@ String _$accountRelationshipHash() =>
|
||||
|
||||
final class AccountRelationshipFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnRelationship?>, String> {
|
||||
const AccountRelationshipFamily._()
|
||||
AccountRelationshipFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'accountRelationshipProvider',
|
||||
@@ -384,7 +384,7 @@ final class AccountRelationshipFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(accountBotDeveloper)
|
||||
const accountBotDeveloperProvider = AccountBotDeveloperFamily._();
|
||||
final accountBotDeveloperProvider = AccountBotDeveloperFamily._();
|
||||
|
||||
final class AccountBotDeveloperProvider
|
||||
extends
|
||||
@@ -394,7 +394,7 @@ final class AccountBotDeveloperProvider
|
||||
FutureOr<SnDeveloper?>
|
||||
>
|
||||
with $FutureModifier<SnDeveloper?>, $FutureProvider<SnDeveloper?> {
|
||||
const AccountBotDeveloperProvider._({
|
||||
AccountBotDeveloperProvider._({
|
||||
required AccountBotDeveloperFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -443,7 +443,7 @@ String _$accountBotDeveloperHash() =>
|
||||
|
||||
final class AccountBotDeveloperFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnDeveloper?>, String> {
|
||||
const AccountBotDeveloperFamily._()
|
||||
AccountBotDeveloperFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'accountBotDeveloperProvider',
|
||||
@@ -460,7 +460,7 @@ final class AccountBotDeveloperFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(accountPublishers)
|
||||
const accountPublishersProvider = AccountPublishersFamily._();
|
||||
final accountPublishersProvider = AccountPublishersFamily._();
|
||||
|
||||
final class AccountPublishersProvider
|
||||
extends
|
||||
@@ -472,7 +472,7 @@ final class AccountPublishersProvider
|
||||
with
|
||||
$FutureModifier<List<SnPublisher>>,
|
||||
$FutureProvider<List<SnPublisher>> {
|
||||
const AccountPublishersProvider._({
|
||||
AccountPublishersProvider._({
|
||||
required AccountPublishersFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -520,7 +520,7 @@ String _$accountPublishersHash() => r'25f5695b4a5154163d77f1769876d826bf736609';
|
||||
|
||||
final class AccountPublishersFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<List<SnPublisher>>, String> {
|
||||
const AccountPublishersFamily._()
|
||||
AccountPublishersFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'accountPublishersProvider',
|
||||
|
||||
@@ -113,7 +113,7 @@ class RelationshipListTile extends StatelessWidget {
|
||||
contentPadding: const EdgeInsets.only(left: 16, right: 12),
|
||||
leading: AccountPfcGestureDetector(
|
||||
uname: account.name,
|
||||
child: ProfilePictureWidget(fileId: account.profile.picture?.id),
|
||||
child: ProfilePictureWidget(file: account.profile.picture),
|
||||
),
|
||||
title: Row(
|
||||
spacing: 6,
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'relationship.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(sentFriendRequest)
|
||||
const sentFriendRequestProvider = SentFriendRequestProvider._();
|
||||
final sentFriendRequestProvider = SentFriendRequestProvider._();
|
||||
|
||||
final class SentFriendRequestProvider
|
||||
extends
|
||||
@@ -22,7 +22,7 @@ final class SentFriendRequestProvider
|
||||
with
|
||||
$FutureModifier<List<SnRelationship>>,
|
||||
$FutureProvider<List<SnRelationship>> {
|
||||
const SentFriendRequestProvider._()
|
||||
SentFriendRequestProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
export 'list.dart';
|
||||
export 'search.dart';
|
||||
@@ -1,151 +0,0 @@
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:island/models/activitypub.dart';
|
||||
import 'package:island/services/activitypub_service.dart';
|
||||
import 'package:island/widgets/activitypub/user_list_item.dart';
|
||||
import 'package:island/widgets/alert.dart';
|
||||
import 'package:island/widgets/app_scaffold.dart';
|
||||
import 'package:island/widgets/extended_refresh_indicator.dart';
|
||||
import 'package:material_symbols_icons/symbols.dart';
|
||||
|
||||
enum ActivityPubListType { following, followers }
|
||||
|
||||
class ApListScreen extends HookConsumerWidget {
|
||||
final ActivityPubListType type;
|
||||
|
||||
const ApListScreen({super.key, required this.type});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final users = useState<List<SnActivityPubUser>>([]);
|
||||
final isLoading = useState(true);
|
||||
final followingUris = useState<Set<String>>({});
|
||||
final isLoadingAction = useState<String?>(null);
|
||||
|
||||
Future<void> loadUsers() async {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
final service = ref.read(activityPubServiceProvider);
|
||||
final result = type == ActivityPubListType.following
|
||||
? await service.getFollowing()
|
||||
: await service.getFollowers();
|
||||
users.value = result;
|
||||
followingUris.value = result.map((user) => user.actorUri).toSet();
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> handleFollow(SnActivityPubUser user) async {
|
||||
isLoadingAction.value = user.actorUri;
|
||||
try {
|
||||
final service = ref.read(activityPubServiceProvider);
|
||||
await service.followRemoteUser(user.actorUri);
|
||||
followingUris.value = {...followingUris.value, user.actorUri};
|
||||
showSnackBar('followedUser'.tr(args: ['@${user.username}']));
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
} finally {
|
||||
isLoadingAction.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> handleUnfollow(SnActivityPubUser user) async {
|
||||
isLoadingAction.value = user.actorUri;
|
||||
try {
|
||||
final service = ref.read(activityPubServiceProvider);
|
||||
await service.unfollowRemoteUser(user.actorUri);
|
||||
followingUris.value = followingUris.value
|
||||
.where((uri) => uri != user.actorUri)
|
||||
.toSet();
|
||||
if (type == ActivityPubListType.following) {
|
||||
users.value = users.value
|
||||
.where((u) => u.actorUri != user.actorUri)
|
||||
.toList();
|
||||
}
|
||||
showSnackBar('unfollowedUser'.tr(args: ['@${user.username}']));
|
||||
} catch (err) {
|
||||
showErrorAlert(err);
|
||||
} finally {
|
||||
isLoadingAction.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
final title = type == ActivityPubListType.following
|
||||
? 'following'.tr()
|
||||
: 'followers'.tr();
|
||||
|
||||
return AppScaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
elevation: 0,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: loadUsers,
|
||||
tooltip: 'refresh'.tr(),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: isLoading.value
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: users.value.isEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Symbols.group,
|
||||
size: 64,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
type == ActivityPubListType.following
|
||||
? 'followingEmpty'.tr()
|
||||
: 'followersEmpty'.tr(),
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'followingEmptyHint'.tr(),
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ExtendedRefreshIndicator(
|
||||
onRefresh: loadUsers,
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
itemCount: users.value.length,
|
||||
separatorBuilder: (context, index) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final user = users.value[index];
|
||||
final isFollowing = followingUris.value.contains(
|
||||
user.actorUri,
|
||||
);
|
||||
final isLoadingUser = isLoadingAction.value == user.actorUri;
|
||||
return ActivityPubUserListItem(
|
||||
user: user,
|
||||
isFollowing: isFollowing,
|
||||
isLoading: isLoadingUser,
|
||||
onFollow: type == ActivityPubListType.followers
|
||||
? () => handleFollow(user)
|
||||
: null,
|
||||
onUnfollow: type == ActivityPubListType.following
|
||||
? () => handleUnfollow(user)
|
||||
: null,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,12 @@ part of 'captcha.config.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(captchaUrl)
|
||||
const captchaUrlProvider = CaptchaUrlProvider._();
|
||||
final captchaUrlProvider = CaptchaUrlProvider._();
|
||||
|
||||
final class CaptchaUrlProvider
|
||||
extends $FunctionalProvider<AsyncValue<String>, String, FutureOr<String>>
|
||||
with $FutureModifier<String>, $FutureProvider<String> {
|
||||
const CaptchaUrlProvider._()
|
||||
CaptchaUrlProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
|
||||
@@ -519,11 +519,7 @@ class ChatListScreen extends HookConsumerWidget {
|
||||
),
|
||||
);
|
||||
},
|
||||
).padding(
|
||||
bottom:
|
||||
(isWideScreen(context) ? 0 : 56) +
|
||||
MediaQuery.of(context).padding.bottom,
|
||||
)
|
||||
).padding(bottom: MediaQuery.of(context).padding.bottom)
|
||||
: null,
|
||||
appBar: AppBar(
|
||||
flexibleSpace: Container(
|
||||
@@ -603,11 +599,13 @@ class ChatListScreen extends HookConsumerWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
body: ChatListBodyWidget(
|
||||
isFloating: false,
|
||||
tabController: tabController,
|
||||
selectedTab: selectedTab,
|
||||
),
|
||||
body: userInfo.value == null
|
||||
? const ResponseUnauthorizedWidget()
|
||||
: ChatListBodyWidget(
|
||||
isFloating: false,
|
||||
tabController: tabController,
|
||||
selectedTab: selectedTab,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ class EditChatScreen extends HookConsumerWidget {
|
||||
bottom: -32,
|
||||
child: GestureDetector(
|
||||
child: ProfilePictureWidget(
|
||||
fileId: picture.value?.id,
|
||||
file: picture.value,
|
||||
radius: 40,
|
||||
fallbackIcon: Symbols.group,
|
||||
),
|
||||
|
||||
@@ -98,15 +98,15 @@ class PublicRoomPreview extends HookConsumerWidget {
|
||||
SizedBox(
|
||||
height: 26,
|
||||
width: 26,
|
||||
child: (room.type == 1 && room.picture?.id == null)
|
||||
child: (room.type == 1 && room.picture == null)
|
||||
? SplitAvatarWidget(
|
||||
filesId: room.members!
|
||||
.map((e) => e.account.profile.picture?.id)
|
||||
files: room.members!
|
||||
.map((e) => e.account.profile.picture)
|
||||
.toList(),
|
||||
)
|
||||
: room.picture?.id != null
|
||||
: room.picture != null
|
||||
? ProfilePictureWidget(
|
||||
fileId: room.picture?.id,
|
||||
file: room.picture,
|
||||
fallbackIcon: Symbols.chat,
|
||||
)
|
||||
: CircleAvatar(
|
||||
@@ -131,15 +131,15 @@ class PublicRoomPreview extends HookConsumerWidget {
|
||||
SizedBox(
|
||||
height: 26,
|
||||
width: 26,
|
||||
child: (room.type == 1 && room.picture?.id == null)
|
||||
child: (room.type == 1 && room.picture == null)
|
||||
? SplitAvatarWidget(
|
||||
filesId: room.members!
|
||||
.map((e) => e.account.profile.picture?.id)
|
||||
files: room.members!
|
||||
.map((e) => e.account.profile.picture)
|
||||
.toList(),
|
||||
)
|
||||
: room.picture?.id != null
|
||||
: room.picture != null
|
||||
? ProfilePictureWidget(
|
||||
fileId: room.picture?.id,
|
||||
file: room.picture,
|
||||
fallbackIcon: Symbols.chat,
|
||||
)
|
||||
: CircleAvatar(
|
||||
|
||||
@@ -48,6 +48,7 @@ class ChatRoomScreen extends HookConsumerWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final mediaQuery = MediaQuery.of(context);
|
||||
final chatRoom = ref.watch(chatRoomProvider(id));
|
||||
final chatIdentity = ref.watch(chatRoomIdentityProvider(id));
|
||||
final isSyncing = ref.watch(chatSyncingProvider);
|
||||
@@ -427,15 +428,15 @@ class ChatRoomScreen extends HookConsumerWidget {
|
||||
child: SizedBox(
|
||||
height: 26,
|
||||
width: 26,
|
||||
child: (room!.type == 1 && room.picture?.id == null)
|
||||
child: (room!.type == 1 && room.picture == null)
|
||||
? SplitAvatarWidget(
|
||||
filesId: getValidMembers(
|
||||
files: getValidMembers(
|
||||
room.members!,
|
||||
).map((e) => e.account.profile.picture?.id).toList(),
|
||||
).map((e) => e.account.profile.picture).toList(),
|
||||
)
|
||||
: room.picture?.id != null
|
||||
: room.picture != null
|
||||
? ProfilePictureWidget(
|
||||
fileId: room.picture?.id,
|
||||
file: room.picture,
|
||||
fallbackIcon: Symbols.chat,
|
||||
)
|
||||
: CircleAvatar(
|
||||
@@ -473,15 +474,15 @@ class ChatRoomScreen extends HookConsumerWidget {
|
||||
child: SizedBox(
|
||||
height: 28,
|
||||
width: 28,
|
||||
child: (room!.type == 1 && room.picture?.id == null)
|
||||
child: (room!.type == 1 && room.picture == null)
|
||||
? SplitAvatarWidget(
|
||||
filesId: getValidMembers(
|
||||
files: getValidMembers(
|
||||
room.members!,
|
||||
).map((e) => e.account.profile.picture?.id).toList(),
|
||||
).map((e) => e.account.profile.picture).toList(),
|
||||
)
|
||||
: room.picture?.id != null
|
||||
: room.picture != null
|
||||
? ProfilePictureWidget(
|
||||
fileId: room.picture?.id,
|
||||
file: room.picture,
|
||||
fallbackIcon: Symbols.chat,
|
||||
)
|
||||
: CircleAvatar(
|
||||
@@ -651,12 +652,12 @@ class ChatRoomScreen extends HookConsumerWidget {
|
||||
curve: Curves.easeOut,
|
||||
tween: EdgeInsetsTween(
|
||||
begin: EdgeInsets.only(
|
||||
top: MediaQuery.of(context).padding.top,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 8 + height,
|
||||
top: mediaQuery.padding.top,
|
||||
bottom: mediaQuery.padding.bottom + 8 + height,
|
||||
),
|
||||
end: EdgeInsets.only(
|
||||
top: MediaQuery.of(context).padding.top,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 8 + height,
|
||||
top: mediaQuery.padding.top,
|
||||
bottom: mediaQuery.padding.bottom + 8 + height,
|
||||
),
|
||||
),
|
||||
builder: (context, padding, child) {
|
||||
@@ -852,7 +853,12 @@ class ChatRoomScreen extends HookConsumerWidget {
|
||||
top: 8,
|
||||
right: 16,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8 + mediaQuery.padding.bottom,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(
|
||||
context,
|
||||
@@ -887,10 +893,7 @@ class ChatRoomScreen extends HookConsumerWidget {
|
||||
child: Opacity(
|
||||
opacity: bottomGradientNotifier.value.value,
|
||||
child: Container(
|
||||
height: math.min(
|
||||
MediaQuery.of(context).size.height * 0.1,
|
||||
128,
|
||||
),
|
||||
height: math.min(mediaQuery.size.height * 0.1, 128),
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.bottomCenter,
|
||||
@@ -914,74 +917,68 @@ class ChatRoomScreen extends HookConsumerWidget {
|
||||
Positioned(
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0, // At the very bottom, above gradient
|
||||
bottom: mediaQuery
|
||||
.padding
|
||||
.bottom, // At the very bottom, above gradient
|
||||
child: chatRoom.when(
|
||||
data: (room) => Column(
|
||||
data: (room) => ChatInput(
|
||||
key: inputKey,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ChatInput(
|
||||
messageController: messageController,
|
||||
chatRoom: room!,
|
||||
onSend: sendMessage,
|
||||
onClear: () {
|
||||
if (messageEditingTo.value != null) {
|
||||
attachments.value.clear();
|
||||
messageController.clear();
|
||||
}
|
||||
messageEditingTo.value = null;
|
||||
messageReplyingTo.value = null;
|
||||
messageForwardingTo.value = null;
|
||||
selectedPoll.value = null;
|
||||
selectedFund.value = null;
|
||||
},
|
||||
messageEditingTo: messageEditingTo.value,
|
||||
messageReplyingTo: messageReplyingTo.value,
|
||||
messageForwardingTo: messageForwardingTo.value,
|
||||
selectedPoll: selectedPoll.value,
|
||||
onPollSelected: (poll) => selectedPoll.value = poll,
|
||||
selectedFund: selectedFund.value,
|
||||
onFundSelected: (fund) => selectedFund.value = fund,
|
||||
onPickFile: (bool isPhoto) {
|
||||
if (isPhoto) {
|
||||
pickPhotoMedia();
|
||||
} else {
|
||||
pickVideoMedia();
|
||||
}
|
||||
},
|
||||
onPickAudio: pickAudioMedia,
|
||||
onPickGeneralFile: pickGeneralFile,
|
||||
onLinkAttachment: linkAttachment,
|
||||
attachments: attachments.value,
|
||||
onUploadAttachment: uploadAttachment,
|
||||
onDeleteAttachment: (index) async {
|
||||
final attachment = attachments.value[index];
|
||||
if (attachment.isOnCloud && !attachment.isLink) {
|
||||
final client = ref.watch(apiClientProvider);
|
||||
await client.delete(
|
||||
'/drive/files/${attachment.data.id}',
|
||||
);
|
||||
}
|
||||
final clone = List.of(attachments.value);
|
||||
clone.removeAt(index);
|
||||
attachments.value = clone;
|
||||
},
|
||||
onMoveAttachment: (idx, delta) {
|
||||
if (idx + delta < 0 ||
|
||||
idx + delta >= attachments.value.length) {
|
||||
return;
|
||||
}
|
||||
final clone = List.of(attachments.value);
|
||||
clone.insert(idx + delta, clone.removeAt(idx));
|
||||
attachments.value = clone;
|
||||
},
|
||||
onAttachmentsChanged: (newAttachments) {
|
||||
attachments.value = newAttachments;
|
||||
},
|
||||
attachmentProgress: attachmentProgress.value,
|
||||
),
|
||||
Gap(MediaQuery.of(context).padding.bottom),
|
||||
],
|
||||
messageController: messageController,
|
||||
chatRoom: room!,
|
||||
onSend: sendMessage,
|
||||
onClear: () {
|
||||
if (messageEditingTo.value != null) {
|
||||
attachments.value.clear();
|
||||
messageController.clear();
|
||||
}
|
||||
messageEditingTo.value = null;
|
||||
messageReplyingTo.value = null;
|
||||
messageForwardingTo.value = null;
|
||||
selectedPoll.value = null;
|
||||
selectedFund.value = null;
|
||||
},
|
||||
messageEditingTo: messageEditingTo.value,
|
||||
messageReplyingTo: messageReplyingTo.value,
|
||||
messageForwardingTo: messageForwardingTo.value,
|
||||
selectedPoll: selectedPoll.value,
|
||||
onPollSelected: (poll) => selectedPoll.value = poll,
|
||||
selectedFund: selectedFund.value,
|
||||
onFundSelected: (fund) => selectedFund.value = fund,
|
||||
onPickFile: (bool isPhoto) {
|
||||
if (isPhoto) {
|
||||
pickPhotoMedia();
|
||||
} else {
|
||||
pickVideoMedia();
|
||||
}
|
||||
},
|
||||
onPickAudio: pickAudioMedia,
|
||||
onPickGeneralFile: pickGeneralFile,
|
||||
onLinkAttachment: linkAttachment,
|
||||
attachments: attachments.value,
|
||||
onUploadAttachment: uploadAttachment,
|
||||
onDeleteAttachment: (index) async {
|
||||
final attachment = attachments.value[index];
|
||||
if (attachment.isOnCloud && !attachment.isLink) {
|
||||
final client = ref.watch(apiClientProvider);
|
||||
await client.delete('/drive/files/${attachment.data.id}');
|
||||
}
|
||||
final clone = List.of(attachments.value);
|
||||
clone.removeAt(index);
|
||||
attachments.value = clone;
|
||||
},
|
||||
onMoveAttachment: (idx, delta) {
|
||||
if (idx + delta < 0 ||
|
||||
idx + delta >= attachments.value.length) {
|
||||
return;
|
||||
}
|
||||
final clone = List.of(attachments.value);
|
||||
clone.insert(idx + delta, clone.removeAt(idx));
|
||||
attachments.value = clone;
|
||||
},
|
||||
onAttachmentsChanged: (newAttachments) {
|
||||
attachments.value = newAttachments;
|
||||
},
|
||||
attachmentProgress: attachmentProgress.value,
|
||||
),
|
||||
error: (_, _) => const SizedBox.shrink(),
|
||||
loading: () => const SizedBox.shrink(),
|
||||
@@ -999,7 +996,7 @@ class ChatRoomScreen extends HookConsumerWidget {
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 8,
|
||||
bottom: MediaQuery.of(context).padding.bottom + 8,
|
||||
bottom: mediaQuery.padding.bottom + 8,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
|
||||
@@ -279,9 +279,8 @@ class ChatDetailScreen extends HookConsumerWidget {
|
||||
leading: PageBackButton(shadows: [iconShadow]),
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
background:
|
||||
(currentRoom!.type == 1 &&
|
||||
currentRoom.background?.id != null)
|
||||
? CloudImageWidget(fileId: currentRoom.background!.id)
|
||||
(currentRoom!.type == 1 && currentRoom.background != null)
|
||||
? CloudImageWidget(file: currentRoom.background!)
|
||||
: (currentRoom.type == 1 &&
|
||||
currentRoom.members!.length == 1 &&
|
||||
currentRoom
|
||||
@@ -293,17 +292,16 @@ class ChatDetailScreen extends HookConsumerWidget {
|
||||
?.id !=
|
||||
null)
|
||||
? CloudImageWidget(
|
||||
fileId: currentRoom
|
||||
file: currentRoom
|
||||
.members!
|
||||
.first
|
||||
.account
|
||||
.profile
|
||||
.background!
|
||||
.id,
|
||||
.background!,
|
||||
)
|
||||
: currentRoom.background?.id != null
|
||||
: currentRoom.background != null
|
||||
? CloudImageWidget(
|
||||
fileId: currentRoom.background!.id,
|
||||
file: currentRoom.background!,
|
||||
fit: BoxFit.cover,
|
||||
)
|
||||
: Container(
|
||||
@@ -702,7 +700,7 @@ class _ChatMemberListSheet extends HookConsumerWidget {
|
||||
leading: AccountPfcGestureDetector(
|
||||
uname: member.account.name,
|
||||
child: ProfilePictureWidget(
|
||||
fileId: member.account.profile.picture?.id,
|
||||
file: member.account.profile.picture,
|
||||
),
|
||||
),
|
||||
title: Row(
|
||||
|
||||
@@ -10,12 +10,12 @@ part of 'room_detail.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(totalMessagesCount)
|
||||
const totalMessagesCountProvider = TotalMessagesCountFamily._();
|
||||
final totalMessagesCountProvider = TotalMessagesCountFamily._();
|
||||
|
||||
final class TotalMessagesCountProvider
|
||||
extends $FunctionalProvider<AsyncValue<int>, int, FutureOr<int>>
|
||||
with $FutureModifier<int>, $FutureProvider<int> {
|
||||
const TotalMessagesCountProvider._({
|
||||
TotalMessagesCountProvider._({
|
||||
required TotalMessagesCountFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -63,7 +63,7 @@ String _$totalMessagesCountHash() =>
|
||||
|
||||
final class TotalMessagesCountFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<int>, String> {
|
||||
const TotalMessagesCountFamily._()
|
||||
TotalMessagesCountFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'totalMessagesCountProvider',
|
||||
|
||||
@@ -155,7 +155,7 @@ class PublisherSelector extends StatelessWidget {
|
||||
if (isReadOnly || currentPublisher == null) {
|
||||
return ProfilePictureWidget(
|
||||
radius: 16,
|
||||
fileId: currentPublisher?.picture?.id,
|
||||
file: currentPublisher?.picture,
|
||||
).center().padding(right: 8);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ class PublisherSelector extends StatelessWidget {
|
||||
.map(
|
||||
(e) => ProfilePictureWidget(
|
||||
radius: 16,
|
||||
fileId: e.value?.picture?.id,
|
||||
file: e.value?.picture,
|
||||
).center().padding(right: 8),
|
||||
)
|
||||
.toList();
|
||||
@@ -355,10 +355,7 @@ class CreatorHubScreen extends HookConsumerWidget {
|
||||
value: item,
|
||||
child: ListTile(
|
||||
minTileHeight: 48,
|
||||
leading: ProfilePictureWidget(
|
||||
radius: 16,
|
||||
fileId: item.picture?.id,
|
||||
),
|
||||
leading: ProfilePictureWidget(radius: 16, file: item.picture),
|
||||
title: Text(item.nick),
|
||||
subtitle: Text('@${item.name}'),
|
||||
trailing: currentPublisher.value?.id == item.id
|
||||
@@ -889,7 +886,7 @@ class _PublisherMemberListSheet extends HookConsumerWidget {
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.only(left: 16, right: 12),
|
||||
leading: ProfilePictureWidget(
|
||||
fileId: member.account!.profile.picture?.id,
|
||||
file: member.account!.profile.picture,
|
||||
),
|
||||
title: Row(
|
||||
spacing: 6,
|
||||
@@ -1137,7 +1134,7 @@ class _PublisherInviteSheet extends HookConsumerWidget {
|
||||
final invite = items[index];
|
||||
return ListTile(
|
||||
leading: ProfilePictureWidget(
|
||||
fileId: invite.publisher!.picture?.id,
|
||||
file: invite.publisher!.picture,
|
||||
fallbackIcon: Symbols.group,
|
||||
),
|
||||
title: Text(invite.publisher!.nick),
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'hub.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(publisherStats)
|
||||
const publisherStatsProvider = PublisherStatsFamily._();
|
||||
final publisherStatsProvider = PublisherStatsFamily._();
|
||||
|
||||
final class PublisherStatsProvider
|
||||
extends
|
||||
@@ -22,7 +22,7 @@ final class PublisherStatsProvider
|
||||
with
|
||||
$FutureModifier<SnPublisherStats?>,
|
||||
$FutureProvider<SnPublisherStats?> {
|
||||
const PublisherStatsProvider._({
|
||||
PublisherStatsProvider._({
|
||||
required PublisherStatsFamily super.from,
|
||||
required String? super.argument,
|
||||
}) : super(
|
||||
@@ -70,7 +70,7 @@ String _$publisherStatsHash() => r'eea4ed98bf165cc785874f83b912bb7e23d1f7bc';
|
||||
|
||||
final class PublisherStatsFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnPublisherStats?>, String?> {
|
||||
const PublisherStatsFamily._()
|
||||
PublisherStatsFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'publisherStatsProvider',
|
||||
@@ -87,7 +87,7 @@ final class PublisherStatsFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(publisherHeatmap)
|
||||
const publisherHeatmapProvider = PublisherHeatmapFamily._();
|
||||
final publisherHeatmapProvider = PublisherHeatmapFamily._();
|
||||
|
||||
final class PublisherHeatmapProvider
|
||||
extends
|
||||
@@ -97,7 +97,7 @@ final class PublisherHeatmapProvider
|
||||
FutureOr<SnHeatmap?>
|
||||
>
|
||||
with $FutureModifier<SnHeatmap?>, $FutureProvider<SnHeatmap?> {
|
||||
const PublisherHeatmapProvider._({
|
||||
PublisherHeatmapProvider._({
|
||||
required PublisherHeatmapFamily super.from,
|
||||
required String? super.argument,
|
||||
}) : super(
|
||||
@@ -144,7 +144,7 @@ String _$publisherHeatmapHash() => r'5f70c55e14629ec8628445a317888e02fccd9af2';
|
||||
|
||||
final class PublisherHeatmapFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnHeatmap?>, String?> {
|
||||
const PublisherHeatmapFamily._()
|
||||
PublisherHeatmapFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'publisherHeatmapProvider',
|
||||
@@ -161,7 +161,7 @@ final class PublisherHeatmapFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(publisherIdentity)
|
||||
const publisherIdentityProvider = PublisherIdentityFamily._();
|
||||
final publisherIdentityProvider = PublisherIdentityFamily._();
|
||||
|
||||
final class PublisherIdentityProvider
|
||||
extends
|
||||
@@ -173,7 +173,7 @@ final class PublisherIdentityProvider
|
||||
with
|
||||
$FutureModifier<SnPublisherMember?>,
|
||||
$FutureProvider<SnPublisherMember?> {
|
||||
const PublisherIdentityProvider._({
|
||||
PublisherIdentityProvider._({
|
||||
required PublisherIdentityFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -221,7 +221,7 @@ String _$publisherIdentityHash() => r'299372f25fa4b2bf8e11a8ba2d645100fc38e76f';
|
||||
|
||||
final class PublisherIdentityFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnPublisherMember?>, String> {
|
||||
const PublisherIdentityFamily._()
|
||||
PublisherIdentityFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'publisherIdentityProvider',
|
||||
@@ -238,7 +238,7 @@ final class PublisherIdentityFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(publisherFeatures)
|
||||
const publisherFeaturesProvider = PublisherFeaturesFamily._();
|
||||
final publisherFeaturesProvider = PublisherFeaturesFamily._();
|
||||
|
||||
final class PublisherFeaturesProvider
|
||||
extends
|
||||
@@ -250,7 +250,7 @@ final class PublisherFeaturesProvider
|
||||
with
|
||||
$FutureModifier<Map<String, bool>>,
|
||||
$FutureProvider<Map<String, bool>> {
|
||||
const PublisherFeaturesProvider._({
|
||||
PublisherFeaturesProvider._({
|
||||
required PublisherFeaturesFamily super.from,
|
||||
required String? super.argument,
|
||||
}) : super(
|
||||
@@ -298,7 +298,7 @@ String _$publisherFeaturesHash() => r'08bace2d9a3da227ecec0cbf8709e55ee0646ca2';
|
||||
|
||||
final class PublisherFeaturesFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<Map<String, bool>>, String?> {
|
||||
const PublisherFeaturesFamily._()
|
||||
PublisherFeaturesFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'publisherFeaturesProvider',
|
||||
@@ -315,7 +315,7 @@ final class PublisherFeaturesFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(publisherInvites)
|
||||
const publisherInvitesProvider = PublisherInvitesProvider._();
|
||||
final publisherInvitesProvider = PublisherInvitesProvider._();
|
||||
|
||||
final class PublisherInvitesProvider
|
||||
extends
|
||||
@@ -327,7 +327,7 @@ final class PublisherInvitesProvider
|
||||
with
|
||||
$FutureModifier<List<SnPublisherMember>>,
|
||||
$FutureProvider<List<SnPublisherMember>> {
|
||||
const PublisherInvitesProvider._()
|
||||
PublisherInvitesProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -356,7 +356,7 @@ final class PublisherInvitesProvider
|
||||
String _$publisherInvitesHash() => r'93aafc2f02af0a7a055ec1770b3999363dfaabdc';
|
||||
|
||||
@ProviderFor(publisherActorStatus)
|
||||
const publisherActorStatusProvider = PublisherActorStatusFamily._();
|
||||
final publisherActorStatusProvider = PublisherActorStatusFamily._();
|
||||
|
||||
final class PublisherActorStatusProvider
|
||||
extends
|
||||
@@ -368,7 +368,7 @@ final class PublisherActorStatusProvider
|
||||
with
|
||||
$FutureModifier<SnActorStatusResponse>,
|
||||
$FutureProvider<SnActorStatusResponse> {
|
||||
const PublisherActorStatusProvider._({
|
||||
PublisherActorStatusProvider._({
|
||||
required PublisherActorStatusFamily super.from,
|
||||
required String? super.argument,
|
||||
}) : super(
|
||||
@@ -417,7 +417,7 @@ String _$publisherActorStatusHash() =>
|
||||
|
||||
final class PublisherActorStatusFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnActorStatusResponse>, String?> {
|
||||
const PublisherActorStatusFamily._()
|
||||
PublisherActorStatusFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'publisherActorStatusProvider',
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'poll_list.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(pollWithStats)
|
||||
const pollWithStatsProvider = PollWithStatsFamily._();
|
||||
final pollWithStatsProvider = PollWithStatsFamily._();
|
||||
|
||||
final class PollWithStatsProvider
|
||||
extends
|
||||
@@ -20,7 +20,7 @@ final class PollWithStatsProvider
|
||||
FutureOr<SnPollWithStats>
|
||||
>
|
||||
with $FutureModifier<SnPollWithStats>, $FutureProvider<SnPollWithStats> {
|
||||
const PollWithStatsProvider._({
|
||||
PollWithStatsProvider._({
|
||||
required PollWithStatsFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -68,7 +68,7 @@ String _$pollWithStatsHash() => r'6bb910046ce1e09368f9922dbec52fdc2cc86740';
|
||||
|
||||
final class PollWithStatsFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnPollWithStats>, String> {
|
||||
const PollWithStatsFamily._()
|
||||
PollWithStatsFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'pollWithStatsProvider',
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'publishers_form.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(publishersManaged)
|
||||
const publishersManagedProvider = PublishersManagedProvider._();
|
||||
final publishersManagedProvider = PublishersManagedProvider._();
|
||||
|
||||
final class PublishersManagedProvider
|
||||
extends
|
||||
@@ -22,7 +22,7 @@ final class PublishersManagedProvider
|
||||
with
|
||||
$FutureModifier<List<SnPublisher>>,
|
||||
$FutureProvider<List<SnPublisher>> {
|
||||
const PublishersManagedProvider._()
|
||||
PublishersManagedProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
@@ -51,7 +51,7 @@ final class PublishersManagedProvider
|
||||
String _$publishersManagedHash() => r'ea83759fed9bd5119738b4d09f12b4476959e0a3';
|
||||
|
||||
@ProviderFor(publisherNullable)
|
||||
const publisherNullableProvider = PublisherNullableFamily._();
|
||||
final publisherNullableProvider = PublisherNullableFamily._();
|
||||
|
||||
final class PublisherNullableProvider
|
||||
extends
|
||||
@@ -61,7 +61,7 @@ final class PublisherNullableProvider
|
||||
FutureOr<SnPublisher?>
|
||||
>
|
||||
with $FutureModifier<SnPublisher?>, $FutureProvider<SnPublisher?> {
|
||||
const PublisherNullableProvider._({
|
||||
PublisherNullableProvider._({
|
||||
required PublisherNullableFamily super.from,
|
||||
required String? super.argument,
|
||||
}) : super(
|
||||
@@ -109,7 +109,7 @@ String _$publisherNullableHash() => r'49b28083a2f351c5e5cde0b1a97f6c7503969041';
|
||||
|
||||
final class PublisherNullableFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnPublisher?>, String?> {
|
||||
const PublisherNullableFamily._()
|
||||
PublisherNullableFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'publisherNullableProvider',
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'site_detail.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(publicationSiteDetail)
|
||||
const publicationSiteDetailProvider = PublicationSiteDetailFamily._();
|
||||
final publicationSiteDetailProvider = PublicationSiteDetailFamily._();
|
||||
|
||||
final class PublicationSiteDetailProvider
|
||||
extends
|
||||
@@ -22,7 +22,7 @@ final class PublicationSiteDetailProvider
|
||||
with
|
||||
$FutureModifier<SnPublicationSite>,
|
||||
$FutureProvider<SnPublicationSite> {
|
||||
const PublicationSiteDetailProvider._({
|
||||
PublicationSiteDetailProvider._({
|
||||
required PublicationSiteDetailFamily super.from,
|
||||
required (String, String) super.argument,
|
||||
}) : super(
|
||||
@@ -75,7 +75,7 @@ final class PublicationSiteDetailFamily extends $Family
|
||||
FutureOr<SnPublicationSite>,
|
||||
(String, String)
|
||||
> {
|
||||
const PublicationSiteDetailFamily._()
|
||||
PublicationSiteDetailFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'publicationSiteDetailProvider',
|
||||
|
||||
@@ -69,157 +69,141 @@ class StickerPackDetailContent extends HookConsumerWidget {
|
||||
}
|
||||
|
||||
return pack.when(
|
||||
data:
|
||||
(pack) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
data: (pack) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
Text(pack!.description),
|
||||
Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
Text(pack!.description),
|
||||
Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
const Icon(Symbols.folder, size: 16),
|
||||
Text(
|
||||
'${packContent.value?.length ?? 0}/24',
|
||||
style: GoogleFonts.robotoMono(),
|
||||
),
|
||||
],
|
||||
).opacity(0.85),
|
||||
Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
const Icon(Symbols.sell, size: 16),
|
||||
Text(pack.prefix, style: GoogleFonts.robotoMono()),
|
||||
],
|
||||
).opacity(0.85),
|
||||
Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
const Icon(Symbols.tag, size: 16),
|
||||
Flexible(
|
||||
child: SelectableText(
|
||||
pack.id,
|
||||
maxLines: 1,
|
||||
style: GoogleFonts.robotoMono(),
|
||||
),
|
||||
),
|
||||
],
|
||||
).opacity(0.85),
|
||||
const Icon(Symbols.folder, size: 16),
|
||||
Text(
|
||||
'${packContent.value?.length ?? 0}/24',
|
||||
style: GoogleFonts.robotoMono(),
|
||||
),
|
||||
],
|
||||
).padding(horizontal: 24, vertical: 24),
|
||||
const Divider(height: 1),
|
||||
Expanded(
|
||||
child: packContent.when(
|
||||
data:
|
||||
(stickers) => RefreshIndicator(
|
||||
onRefresh:
|
||||
() => ref.refresh(
|
||||
stickerPackContentProvider(id).future,
|
||||
),
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24,
|
||||
vertical: 20,
|
||||
),
|
||||
gridDelegate:
|
||||
const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 80,
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
),
|
||||
itemCount: stickers.length,
|
||||
itemBuilder: (context, index) {
|
||||
final sticker = stickers[index];
|
||||
return ContextMenuWidget(
|
||||
menuProvider: (_) {
|
||||
return Menu(
|
||||
children: [
|
||||
MenuAction(
|
||||
title: 'stickerCopyPlaceholder'.tr(),
|
||||
image: MenuImage.icon(Symbols.copy_all),
|
||||
callback: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(
|
||||
text:
|
||||
':${pack.prefix}+${sticker.slug}:',
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
MenuSeparator(),
|
||||
MenuAction(
|
||||
title: 'edit'.tr(),
|
||||
image: MenuImage.icon(Symbols.edit),
|
||||
callback: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder:
|
||||
(context) => SheetScaffold(
|
||||
titleText: 'editSticker'.tr(),
|
||||
child: StickerForm(
|
||||
packId: id,
|
||||
id: sticker.id,
|
||||
),
|
||||
),
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
ref.invalidate(
|
||||
stickerPackContentProvider(id),
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
MenuAction(
|
||||
title: 'delete'.tr(),
|
||||
image: MenuImage.icon(Symbols.delete),
|
||||
callback: () {
|
||||
deleteSticker(sticker);
|
||||
},
|
||||
),
|
||||
],
|
||||
).opacity(0.85),
|
||||
Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
const Icon(Symbols.sell, size: 16),
|
||||
Text(pack.prefix, style: GoogleFonts.robotoMono()),
|
||||
],
|
||||
).opacity(0.85),
|
||||
Row(
|
||||
spacing: 4,
|
||||
children: [
|
||||
const Icon(Symbols.tag, size: 16),
|
||||
Flexible(
|
||||
child: SelectableText(
|
||||
pack.id,
|
||||
maxLines: 1,
|
||||
style: GoogleFonts.robotoMono(),
|
||||
),
|
||||
),
|
||||
],
|
||||
).opacity(0.85),
|
||||
],
|
||||
).padding(horizontal: 24, vertical: 24),
|
||||
const Divider(height: 1),
|
||||
Expanded(
|
||||
child: packContent.when(
|
||||
data: (stickers) => RefreshIndicator(
|
||||
onRefresh: () =>
|
||||
ref.refresh(stickerPackContentProvider(id).future),
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 24,
|
||||
vertical: 20,
|
||||
),
|
||||
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 80,
|
||||
mainAxisSpacing: 8,
|
||||
crossAxisSpacing: 8,
|
||||
),
|
||||
itemCount: stickers.length,
|
||||
itemBuilder: (context, index) {
|
||||
final sticker = stickers[index];
|
||||
return ContextMenuWidget(
|
||||
menuProvider: (_) {
|
||||
return Menu(
|
||||
children: [
|
||||
MenuAction(
|
||||
title: 'stickerCopyPlaceholder'.tr(),
|
||||
image: MenuImage.icon(Symbols.copy_all),
|
||||
callback: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(
|
||||
text: ':${pack.prefix}+${sticker.slug}:',
|
||||
),
|
||||
);
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color:
|
||||
Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainer,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(8),
|
||||
),
|
||||
MenuSeparator(),
|
||||
MenuAction(
|
||||
title: 'edit'.tr(),
|
||||
image: MenuImage.icon(Symbols.edit),
|
||||
callback: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => SheetScaffold(
|
||||
titleText: 'editSticker'.tr(),
|
||||
child: StickerForm(
|
||||
packId: id,
|
||||
id: sticker.id,
|
||||
),
|
||||
),
|
||||
child: CloudImageWidget(
|
||||
fileId: sticker.image.id,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
ref.invalidate(
|
||||
stickerPackContentProvider(id),
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
MenuAction(
|
||||
title: 'delete'.tr(),
|
||||
image: MenuImage.icon(Symbols.delete),
|
||||
callback: () {
|
||||
deleteSticker(sticker);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.surfaceContainer,
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child: CloudImageWidget(
|
||||
file: sticker.image,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
error:
|
||||
(err, _) =>
|
||||
Text(
|
||||
'Error: $err',
|
||||
).textAlignment(TextAlign.center).center(),
|
||||
loading: () => const CircularProgressIndicator().center(),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
error: (err, _) =>
|
||||
Text('Error: $err').textAlignment(TextAlign.center).center(),
|
||||
loading: () => const CircularProgressIndicator().center(),
|
||||
),
|
||||
),
|
||||
error:
|
||||
(err, _) =>
|
||||
Text('Error: $err').textAlignment(TextAlign.center).center(),
|
||||
],
|
||||
),
|
||||
error: (err, _) =>
|
||||
Text('Error: $err').textAlignment(TextAlign.center).center(),
|
||||
loading: () => const CircularProgressIndicator().center(),
|
||||
);
|
||||
}
|
||||
@@ -241,65 +225,60 @@ class StickerPackActionMenu extends HookConsumerWidget {
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return PopupMenuButton(
|
||||
icon: Icon(Icons.more_vert, shadows: [iconShadow]),
|
||||
itemBuilder:
|
||||
(context) => [
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder:
|
||||
(context) => SheetScaffold(
|
||||
titleText: 'editStickerPack'.tr(),
|
||||
child: StickerPackForm(
|
||||
pubName: pubName,
|
||||
packId: packId,
|
||||
),
|
||||
),
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
ref.invalidate(stickerPackProvider(packId));
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.edit,
|
||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
),
|
||||
const Gap(12),
|
||||
const Text('editStickerPack').tr(),
|
||||
],
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
onTap: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => SheetScaffold(
|
||||
titleText: 'editStickerPack'.tr(),
|
||||
child: StickerPackForm(pubName: pubName, packId: packId),
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.delete, color: Colors.red),
|
||||
const Gap(12),
|
||||
const Text(
|
||||
'deleteStickerPack',
|
||||
style: TextStyle(color: Colors.red),
|
||||
).tr(),
|
||||
],
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
ref.invalidate(stickerPackProvider(packId));
|
||||
}
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.edit,
|
||||
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
||||
),
|
||||
onTap: () {
|
||||
showConfirmAlert(
|
||||
'deleteStickerPackHint'.tr(),
|
||||
'deleteStickerPack'.tr(),
|
||||
isDanger: true,
|
||||
).then((confirm) {
|
||||
if (confirm) {
|
||||
final client = ref.watch(apiClientProvider);
|
||||
client.delete('/sphere/stickers/$packId');
|
||||
ref.invalidate(stickerPacksProvider);
|
||||
if (context.mounted) context.pop(true);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
const Gap(12),
|
||||
const Text('editStickerPack').tr(),
|
||||
],
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(Icons.delete, color: Colors.red),
|
||||
const Gap(12),
|
||||
const Text(
|
||||
'deleteStickerPack',
|
||||
style: TextStyle(color: Colors.red),
|
||||
).tr(),
|
||||
],
|
||||
),
|
||||
onTap: () {
|
||||
showConfirmAlert(
|
||||
'deleteStickerPackHint'.tr(),
|
||||
'deleteStickerPack'.tr(),
|
||||
isDanger: true,
|
||||
).then((confirm) {
|
||||
if (confirm) {
|
||||
final client = ref.watch(apiClientProvider);
|
||||
client.delete('/sphere/stickers/$packId');
|
||||
ref.invalidate(stickerPacksProvider);
|
||||
if (context.mounted) context.pop(true);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -372,10 +351,9 @@ class StickerForm extends HookConsumerWidget {
|
||||
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||
),
|
||||
child:
|
||||
(image.value?.isEmpty ?? true)
|
||||
? const SizedBox.shrink()
|
||||
: CloudImageWidget(fileId: image.value!),
|
||||
child: (image.value?.isEmpty ?? true)
|
||||
? const SizedBox.shrink()
|
||||
: CloudImageWidget(fileId: image.value!),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -383,10 +361,8 @@ class StickerForm extends HookConsumerWidget {
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder:
|
||||
(context) => CloudFilePicker(
|
||||
allowedTypes: {UniversalFileType.image},
|
||||
),
|
||||
builder: (context) =>
|
||||
CloudFilePicker(allowedTypes: {UniversalFileType.image}),
|
||||
).then((value) {
|
||||
if (value == null) return;
|
||||
image.value = value[0].id;
|
||||
@@ -412,8 +388,8 @@ class StickerForm extends HookConsumerWidget {
|
||||
borderRadius: BorderRadius.all(Radius.circular(12)),
|
||||
),
|
||||
),
|
||||
onTapOutside:
|
||||
(_) => FocusManager.instance.primaryFocus?.unfocus(),
|
||||
onTapOutside: (_) =>
|
||||
FocusManager.instance.primaryFocus?.unfocus(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'pack_detail.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(stickerPackContent)
|
||||
const stickerPackContentProvider = StickerPackContentFamily._();
|
||||
final stickerPackContentProvider = StickerPackContentFamily._();
|
||||
|
||||
final class StickerPackContentProvider
|
||||
extends
|
||||
@@ -20,7 +20,7 @@ final class StickerPackContentProvider
|
||||
FutureOr<List<SnSticker>>
|
||||
>
|
||||
with $FutureModifier<List<SnSticker>>, $FutureProvider<List<SnSticker>> {
|
||||
const StickerPackContentProvider._({
|
||||
StickerPackContentProvider._({
|
||||
required StickerPackContentFamily super.from,
|
||||
required String super.argument,
|
||||
}) : super(
|
||||
@@ -69,7 +69,7 @@ String _$stickerPackContentHash() =>
|
||||
|
||||
final class StickerPackContentFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<List<SnSticker>>, String> {
|
||||
const StickerPackContentFamily._()
|
||||
StickerPackContentFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'stickerPackContentProvider',
|
||||
@@ -86,7 +86,7 @@ final class StickerPackContentFamily extends $Family
|
||||
}
|
||||
|
||||
@ProviderFor(stickerPackSticker)
|
||||
const stickerPackStickerProvider = StickerPackStickerFamily._();
|
||||
final stickerPackStickerProvider = StickerPackStickerFamily._();
|
||||
|
||||
final class StickerPackStickerProvider
|
||||
extends
|
||||
@@ -96,7 +96,7 @@ final class StickerPackStickerProvider
|
||||
FutureOr<SnSticker?>
|
||||
>
|
||||
with $FutureModifier<SnSticker?>, $FutureProvider<SnSticker?> {
|
||||
const StickerPackStickerProvider._({
|
||||
StickerPackStickerProvider._({
|
||||
required StickerPackStickerFamily super.from,
|
||||
required StickerWithPackQuery? super.argument,
|
||||
}) : super(
|
||||
@@ -145,7 +145,7 @@ String _$stickerPackStickerHash() =>
|
||||
final class StickerPackStickerFamily extends $Family
|
||||
with
|
||||
$FunctionalFamilyOverride<FutureOr<SnSticker?>, StickerWithPackQuery?> {
|
||||
const StickerPackStickerFamily._()
|
||||
StickerPackStickerFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'stickerPackStickerProvider',
|
||||
|
||||
@@ -10,7 +10,7 @@ part of 'stickers.dart';
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
|
||||
@ProviderFor(stickerPack)
|
||||
const stickerPackProvider = StickerPackFamily._();
|
||||
final stickerPackProvider = StickerPackFamily._();
|
||||
|
||||
final class StickerPackProvider
|
||||
extends
|
||||
@@ -20,7 +20,7 @@ final class StickerPackProvider
|
||||
FutureOr<SnStickerPack?>
|
||||
>
|
||||
with $FutureModifier<SnStickerPack?>, $FutureProvider<SnStickerPack?> {
|
||||
const StickerPackProvider._({
|
||||
StickerPackProvider._({
|
||||
required StickerPackFamily super.from,
|
||||
required String? super.argument,
|
||||
}) : super(
|
||||
@@ -68,7 +68,7 @@ String _$stickerPackHash() => r'71ef84471237c8191918095094bdfc87d3920e77';
|
||||
|
||||
final class StickerPackFamily extends $Family
|
||||
with $FunctionalFamilyOverride<FutureOr<SnStickerPack?>, String?> {
|
||||
const StickerPackFamily._()
|
||||
StickerPackFamily._()
|
||||
: super(
|
||||
retry: null,
|
||||
name: r'stickerPackProvider',
|
||||
|
||||
@@ -21,6 +21,7 @@ import 'package:island/widgets/app_scaffold.dart';
|
||||
import 'package:island/widgets/notification_tile.dart';
|
||||
import 'package:island/widgets/post/post_featured.dart';
|
||||
import 'package:island/widgets/check_in.dart';
|
||||
import 'package:island/screens/auth/login_modal.dart';
|
||||
import 'package:island/models/activity.dart';
|
||||
import 'package:island/screens/notification.dart';
|
||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||
@@ -116,7 +117,11 @@ class DashboardGrid extends HookConsumerWidget {
|
||||
topRight: isWide ? 0 : 12,
|
||||
)
|
||||
.padding(horizontal: isWide ? 0 : 16),
|
||||
),
|
||||
)
|
||||
else
|
||||
Center(
|
||||
child: _UnauthorizedCard(isWide: isWide),
|
||||
).padding(horizontal: isWide ? 24 : 16),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -303,7 +308,9 @@ class ClockCard extends HookConsumerWidget {
|
||||
spacing: 5,
|
||||
children: [
|
||||
notableDay.when(
|
||||
data: (day) => _buildNotableDayText(context, day!),
|
||||
data: (day) => day == null
|
||||
? Text('unauthorized').tr()
|
||||
: _buildNotableDayText(context, day),
|
||||
error: (err, _) =>
|
||||
Text(err.toString()).fontSize(12),
|
||||
loading: () =>
|
||||
@@ -555,3 +562,64 @@ class FortuneCard extends HookConsumerWidget {
|
||||
).height(48);
|
||||
}
|
||||
}
|
||||
|
||||
class _UnauthorizedCard extends HookConsumerWidget {
|
||||
final bool isWide;
|
||||
const _UnauthorizedCard({required this.isWide});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: isWide ? 48 : 32,
|
||||
vertical: 32,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Gap(16),
|
||||
Icon(
|
||||
Symbols.dashboard_rounded,
|
||||
size: 64,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
fill: 1,
|
||||
),
|
||||
const Gap(16),
|
||||
Text(
|
||||
'Welcome to\nthe Solar Network',
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.bold),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const Gap(8),
|
||||
Text(
|
||||
'Login to access your personalized dashboard with friends, notifications, chats, and more!',
|
||||
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const Gap(12),
|
||||
FilledButton.icon(
|
||||
onPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => const LoginModal(),
|
||||
);
|
||||
},
|
||||
icon: const Icon(Symbols.login),
|
||||
label: Text('login').tr(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user