Skip to content

Commit 3126c02

Browse files
authored
Merge pull request #13 from invokable/copilot/fix-d08b2e20-2077-49f0-a85e-9c2b9bce22ac
Update .github/copilot-instructions.md with comprehensive accuracy improvements and missing features
2 parents 956357e + 74b986c commit 3126c02

File tree

2 files changed

+54
-16
lines changed

2 files changed

+54
-16
lines changed

.github/copilot-instructions.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,29 @@
55
The `revolution/laravel-threads` package is a Laravel library that provides comprehensive integration with Meta's Threads platform. It serves Laravel developers who need to:
66

77
- **Authenticate users via Threads OAuth** using Laravel Socialite
8-
- **Publish content to Threads** (text posts, images, videos, carousels)
9-
- **Manage Threads content** (delete, repost, search)
8+
- **Publish content to Threads** (text posts, images, videos, carousels, polls)
9+
- **Manage Threads content** (delete, repost, search, status checking)
1010
- **Send notifications through Threads** via Laravel's notification system
1111
- **Retrieve user profiles and posts** from the Threads API
12+
- **Monitor publishing quotas** and API limits
1213

13-
The package abstracts the complexity of the Threads API behind familiar Laravel patterns (facades, service providers, notifications), enabling developers to integrate Threads functionality without dealing with raw HTTP requests or OAuth flows. It supports both direct API usage and Laravel's notification system for automated posting.
14+
The package abstracts the complexity of the Threads API behind familiar Laravel patterns (facades, service providers, notifications), enabling developers to integrate Threads functionality without dealing with raw HTTP requests or OAuth flows. It supports both direct API usage and Laravel's notification system for automated posting, with extensibility through Laravel's macro system.
1415

1516
**Target Users**: Laravel application developers building social media integrations, content management systems, or marketing automation tools that need to interact with Threads.
1617

18+
## Token Management
19+
20+
The package handles two types of Threads API tokens:
21+
22+
- **Short-lived tokens**: Obtained through Socialite OAuth flow, valid for limited time
23+
- **Long-lived tokens**: Valid for 60-90 days, required for API operations
24+
25+
Key token management features:
26+
- Automatic conversion from short-lived to long-lived tokens via `exchangeToken()`
27+
- Token refresh capability via `refreshToken()` for continuous access
28+
- Support for Threads tester tokens (pre-generated as long-lived)
29+
- Database storage recommended (tokens cannot be stored in `.env` permanently)
30+
1731
## Project Organization
1832

1933
### Core Systems
@@ -23,7 +37,8 @@ The package is organized into four main subsystems:
2337
1. **Core API Client System** (`src/ThreadsClient.php`, `src/Contracts/Factory.php`)
2438
- Handles direct HTTP communication with Threads API
2539
- Implements two-phase content creation (create → publish)
26-
- Manages token authentication and refresh
40+
- Manages token authentication, refresh, and quota monitoring
41+
- Supports extensibility through Laravel's macro system
2742

2843
2. **Laravel Integration Layer** (`src/ThreadsServiceProvider.php`, `src/Facades/Threads.php`, `src/Traits/WithThreads.php`)
2944
- Registers services with Laravel's container
@@ -37,7 +52,7 @@ The package is organized into four main subsystems:
3752

3853
4. **Notification System** (`src/Notifications/ThreadsChannel.php`, `src/Notifications/ThreadsMessage.php`)
3954
- Custom Laravel notification channel for Threads
40-
- Supports text, image, and video content
55+
- Supports text, image, video, and poll content
4156
- Integrates with Laravel's notification infrastructure
4257

4358
### Main Files and Directories
@@ -76,30 +91,32 @@ docs/
7691
### Main Classes and Functions
7792

7893
**Core API Client:**
79-
- `ThreadsClient`: Main HTTP client with methods like `createText()`, `createImage()`, `publish()`, `delete()`
94+
- `ThreadsClient`: Main HTTP client with methods like `createText()`, `createImage()`, `createVideo()`, `createCarousel()`, `publish()`, `delete()`, `repost()`, `search()`, `profiles()`, `posts()`, `single()`, `replies()`, `status()`, `quota()`
8095
- `Factory`: Interface defining the client contract for dependency injection
8196

8297
**Laravel Integration:**
83-
- `ThreadsServiceProvider::register()`: Binds Factory to ThreadsClient in service container
84-
- `ThreadsServiceProvider::boot()`: Extends Socialite with Threads driver
85-
- `Threads` (Facade): Provides static access like `Threads::createText()`
98+
- `ThreadsServiceProvider::register()`: Binds Factory to ThreadsClient as scoped service in container
99+
- `ThreadsServiceProvider::boot()`: Extends Socialite with Threads driver using service configuration
100+
- `Threads` (Facade): Provides static access like `Threads::createText()` with macro and conditional support
86101
- `WithThreads::threads()`: Trait method returning configured client instance
87102

88103
**OAuth System:**
89-
- `ThreadsProvider::redirect()`: Initiates OAuth authorization flow
104+
- `ThreadsProvider::redirect()`: Initiates OAuth authorization flow with default scopes
90105
- `ThreadsProvider::user()`: Handles callback and retrieves user data
91106
- `ThreadsProvider::exchangeToken()`: Converts short-lived to long-lived tokens
107+
- Default scopes: `['threads_basic', 'threads_content_publish', 'threads_delete', 'threads_keyword_search']`
92108

93109
**Notification System:**
94110
- `ThreadsChannel::send()`: Processes notifications and dispatches to Threads
95111
- `ThreadsMessage::create()`: Factory method for message construction
96-
- `ThreadsMessage::withImage()`, `ThreadsMessage::withVideo()`: Fluent media attachment
112+
- `ThreadsMessage::withImage()`, `ThreadsMessage::withVideo()`: Fluent media attachment methods
97113

98114
### CI/CD Pipeline
99115

100-
- **`.github/workflows/test.yml`**: Runs PHPUnit tests across PHP 8.2-8.4, generates coverage
101-
- **`.github/workflows/lint.yml`**: Enforces code style using Laravel Pint
102-
- **`phpunit.xml`**: Configures test discovery and coverage reporting
116+
- **`.github/workflows/test.yml`**: Runs PHPUnit tests across PHP 8.2-8.4, generates coverage with Qlty integration
117+
- **`.github/workflows/lint.yml`**: Enforces code style using Laravel Pint (PHP 8.4)
118+
- **`.github/workflows/copilot-setup-steps.yml`**: Automated setup workflow for GitHub Copilot integration
119+
- **`phpunit.xml`**: Configures test discovery and coverage reporting to `build/logs/clover.xml`
103120
- **`pint.json`**: Laravel coding standards with disabled unused imports rule
104121

105122
## Glossary of Codebase-Specific Terms
@@ -124,7 +141,7 @@ docs/
124141

125142
**MediaType** - Enum defining content types: TEXT, IMAGE, VIDEO, CAROUSEL. Located: `src/Enums/MediaType.php`
126143

127-
**ReplyControl** - Enum for reply permissions: EVERYONE, FOLLOW, MENTIONED. Located: `src/Enums/ReplyControl.php`
144+
**ReplyControl** - Enum for reply permissions: EVERYONE, FOLLOW (accounts_you_follow), MENTIONED (mentioned_only). Located: `src/Enums/ReplyControl.php`
128145

129146
**SearchType** - Enum for search ordering: TOP, RECENT. Located: `src/Enums/SearchType.php`
130147

@@ -138,13 +155,29 @@ docs/
138155

139156
**createCarousel** - Method creating multi-media carousel posts. Found in: `ThreadsClient::createCarousel()`
140157

158+
**profiles** - Method retrieving user profile information. Found in: `ThreadsClient::profiles()`
159+
160+
**posts** - Method retrieving user's posts with pagination. Found in: `ThreadsClient::posts()`
161+
162+
**single** - Method retrieving a single post by ID. Found in: `ThreadsClient::single()`
163+
164+
**replies** - Method retrieving replies to posts. Found in: `ThreadsClient::replies()`
165+
166+
**repost** - Method for reposting existing content. Found in: `ThreadsClient::repost()`
167+
168+
**status** - Method checking publishing status of containers. Found in: `ThreadsClient::status()`
169+
170+
**quota** - Method checking API usage limits and quotas. Found in: `ThreadsClient::quota()`
171+
172+
**search** - Method for keyword search across public Threads content. Found in: `ThreadsClient::search()`
173+
141174
**toThreads** - Notification method returning ThreadsMessage instance. Found in: custom notification classes
142175

143176
**routeNotificationForThreads** - Model method providing Threads token for notifications. Found in: Notifiable models
144177

145178
**threads** - Trait method returning configured ThreadsClient instance. Found in: `WithThreads::threads()`
146179

147-
**tokenForThreads** - Abstract method models must implement for token retrieval. Found in: `WithThreads` trait
180+
**tokenForThreads** - Abstract method models must implement for token retrieval. Found in: `WithThreads` trait (must be implemented by classes using the trait)
148181

149182
**POST_DEFAULT_FIELDS** - Constant array of default API response fields. Found in: `ThreadsClient::POST_DEFAULT_FIELDS`
150183

@@ -157,3 +190,7 @@ docs/
157190
**is_carousel** - Boolean flag marking media for carousel inclusion. Found in: media creation methods
158191

159192
**sleep** - Parameter controlling publish timing/delays. Found in: `publish()` and `ThreadsMessage`
193+
194+
**poll_attachment** - Option for adding polls to text posts. Found in: `createText()` options
195+
196+
**Macroable** - Trait enabling custom method addition to ThreadsClient and ThreadsMessage. Found in: `ThreadsClient` and `ThreadsMessage` classes

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/vendor
22
.phpunit.result.cache
33
composer.lock
4+
build

0 commit comments

Comments
 (0)