2026-01-17 02:46:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-01-17 02:46:30 +00:00
|
|
|
namespace App\Socialite;
|
|
|
|
|
|
|
|
|
|
use GuzzleHttp\RequestOptions;
|
|
|
|
|
use Laravel\Socialite\Two\AbstractProvider;
|
|
|
|
|
use Laravel\Socialite\Two\ProviderInterface;
|
|
|
|
|
use Laravel\Socialite\Two\User;
|
|
|
|
|
|
|
|
|
|
class InstagramProvider extends AbstractProvider implements ProviderInterface
|
|
|
|
|
{
|
|
|
|
|
protected $scopes = [
|
|
|
|
|
'instagram_business_basic',
|
|
|
|
|
'instagram_business_content_publish',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected function getAuthUrl($state): string
|
|
|
|
|
{
|
feat: media gallery picker, custom emoji picker, preview tabs, real platform logos
- gallery: extract /assets tabs (uploads, Unsplash, Giphy) into shared
GalleryBrowser used by both /assets and a new MediaPickerDialog inside the
post editor; add JSON search endpoint for workspace assets with tests
- emoji: replace broken emoji-picker-element web component with a custom
EmojiPicker (full Unicode set, search, categories, recently-used,
light/dark, i18n)
- preview tab: platform selector pills, variant tabs (data-driven from
content_types map) so the user can switch Feed/Reel/Story etc. and have
it autosave through the same handler ScheduleTab uses
- platform logos: shared usePlatformLogo composable (logo + label + content
types); replaces inline maps across 5 components, fixes
instagram-facebook falling back to default.png
- tooltips: hover details (display_name · @username + platform label) on
platform avatars across editor, posts list and calendar
- settings cards: show ` · @username` in the title bar so multiple accounts
on the same network are distinguishable
- routes: drop the throttle:6,1 group middleware on social connect routes
(was 429ing legitimate OAuth retries) and rely on the default limiter
2026-05-01 17:53:49 +00:00
|
|
|
// enable_fb_login=0 forces the pure Instagram Login flow (without
|
|
|
|
|
// delegating to Facebook OAuth). Tokens issued from the FB-delegated
|
|
|
|
|
// path can't be exchanged via graph.instagram.com/access_token.
|
|
|
|
|
return 'https://www.instagram.com/oauth/authorize?enable_fb_login=0&'.http_build_query([
|
2026-01-17 02:46:30 +00:00
|
|
|
'client_id' => $this->clientId,
|
|
|
|
|
'redirect_uri' => $this->redirectUrl,
|
|
|
|
|
'response_type' => 'code',
|
|
|
|
|
'scope' => implode(',', $this->getScopes()),
|
feat: media gallery picker, custom emoji picker, preview tabs, real platform logos
- gallery: extract /assets tabs (uploads, Unsplash, Giphy) into shared
GalleryBrowser used by both /assets and a new MediaPickerDialog inside the
post editor; add JSON search endpoint for workspace assets with tests
- emoji: replace broken emoji-picker-element web component with a custom
EmojiPicker (full Unicode set, search, categories, recently-used,
light/dark, i18n)
- preview tab: platform selector pills, variant tabs (data-driven from
content_types map) so the user can switch Feed/Reel/Story etc. and have
it autosave through the same handler ScheduleTab uses
- platform logos: shared usePlatformLogo composable (logo + label + content
types); replaces inline maps across 5 components, fixes
instagram-facebook falling back to default.png
- tooltips: hover details (display_name · @username + platform label) on
platform avatars across editor, posts list and calendar
- settings cards: show ` · @username` in the title bar so multiple accounts
on the same network are distinguishable
- routes: drop the throttle:6,1 group middleware on social connect routes
(was 429ing legitimate OAuth retries) and rely on the default limiter
2026-05-01 17:53:49 +00:00
|
|
|
'state' => $state,
|
2026-01-17 02:46:30 +00:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getTokenUrl(): string
|
|
|
|
|
{
|
|
|
|
|
return 'https://api.instagram.com/oauth/access_token';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getUserByToken($token): array
|
|
|
|
|
{
|
2026-05-02 16:49:20 +00:00
|
|
|
$response = $this->getHttpClient()->get(config('trypost.platforms.instagram.graph_api').'/me', [
|
2026-01-17 02:46:30 +00:00
|
|
|
RequestOptions::QUERY => [
|
|
|
|
|
'access_token' => $token,
|
|
|
|
|
'fields' => 'id,username,account_type,name,profile_picture_url',
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return json_decode((string) $response->getBody(), true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function mapUserToObject(array $user): User
|
|
|
|
|
{
|
|
|
|
|
return (new User)->setRaw($user)->map([
|
|
|
|
|
'id' => $user['id'],
|
|
|
|
|
'nickname' => $user['username'] ?? null,
|
|
|
|
|
'name' => $user['name'] ?? $user['username'] ?? null,
|
|
|
|
|
'avatar' => $user['profile_picture_url'] ?? null,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getAccessTokenResponse($code): array
|
|
|
|
|
{
|
feat: media gallery picker, custom emoji picker, preview tabs, real platform logos
- gallery: extract /assets tabs (uploads, Unsplash, Giphy) into shared
GalleryBrowser used by both /assets and a new MediaPickerDialog inside the
post editor; add JSON search endpoint for workspace assets with tests
- emoji: replace broken emoji-picker-element web component with a custom
EmojiPicker (full Unicode set, search, categories, recently-used,
light/dark, i18n)
- preview tab: platform selector pills, variant tabs (data-driven from
content_types map) so the user can switch Feed/Reel/Story etc. and have
it autosave through the same handler ScheduleTab uses
- platform logos: shared usePlatformLogo composable (logo + label + content
types); replaces inline maps across 5 components, fixes
instagram-facebook falling back to default.png
- tooltips: hover details (display_name · @username + platform label) on
platform avatars across editor, posts list and calendar
- settings cards: show ` · @username` in the title bar so multiple accounts
on the same network are distinguishable
- routes: drop the throttle:6,1 group middleware on social connect routes
(was 429ing legitimate OAuth retries) and rely on the default limiter
2026-05-01 17:53:49 +00:00
|
|
|
// Meta's docs document this endpoint with curl -F flags (multipart/form-data).
|
|
|
|
|
$multipart = [];
|
|
|
|
|
foreach ($this->getTokenFields($code) as $name => $contents) {
|
|
|
|
|
$multipart[] = ['name' => $name, 'contents' => (string) $contents];
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-17 02:46:30 +00:00
|
|
|
$response = $this->getHttpClient()->post($this->getTokenUrl(), [
|
feat: media gallery picker, custom emoji picker, preview tabs, real platform logos
- gallery: extract /assets tabs (uploads, Unsplash, Giphy) into shared
GalleryBrowser used by both /assets and a new MediaPickerDialog inside the
post editor; add JSON search endpoint for workspace assets with tests
- emoji: replace broken emoji-picker-element web component with a custom
EmojiPicker (full Unicode set, search, categories, recently-used,
light/dark, i18n)
- preview tab: platform selector pills, variant tabs (data-driven from
content_types map) so the user can switch Feed/Reel/Story etc. and have
it autosave through the same handler ScheduleTab uses
- platform logos: shared usePlatformLogo composable (logo + label + content
types); replaces inline maps across 5 components, fixes
instagram-facebook falling back to default.png
- tooltips: hover details (display_name · @username + platform label) on
platform avatars across editor, posts list and calendar
- settings cards: show ` · @username` in the title bar so multiple accounts
on the same network are distinguishable
- routes: drop the throttle:6,1 group middleware on social connect routes
(was 429ing legitimate OAuth retries) and rely on the default limiter
2026-05-01 17:53:49 +00:00
|
|
|
RequestOptions::MULTIPART => $multipart,
|
2026-01-17 02:46:30 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$data = json_decode((string) $response->getBody(), true);
|
|
|
|
|
|
|
|
|
|
return $this->exchangeForLongLivedToken($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function exchangeForLongLivedToken(array $data): array
|
|
|
|
|
{
|
feat: media gallery picker, custom emoji picker, preview tabs, real platform logos
- gallery: extract /assets tabs (uploads, Unsplash, Giphy) into shared
GalleryBrowser used by both /assets and a new MediaPickerDialog inside the
post editor; add JSON search endpoint for workspace assets with tests
- emoji: replace broken emoji-picker-element web component with a custom
EmojiPicker (full Unicode set, search, categories, recently-used,
light/dark, i18n)
- preview tab: platform selector pills, variant tabs (data-driven from
content_types map) so the user can switch Feed/Reel/Story etc. and have
it autosave through the same handler ScheduleTab uses
- platform logos: shared usePlatformLogo composable (logo + label + content
types); replaces inline maps across 5 components, fixes
instagram-facebook falling back to default.png
- tooltips: hover details (display_name · @username + platform label) on
platform avatars across editor, posts list and calendar
- settings cards: show ` · @username` in the title bar so multiple accounts
on the same network are distinguishable
- routes: drop the throttle:6,1 group middleware on social connect routes
(was 429ing legitimate OAuth retries) and rely on the default limiter
2026-05-01 17:53:49 +00:00
|
|
|
// Although Meta's docs don't list `client_id` as a required parameter,
|
|
|
|
|
// the API in practice rejects the request without it.
|
2026-05-02 16:49:20 +00:00
|
|
|
$response = $this->getHttpClient()->get(config('trypost.platforms.instagram.auth_api').'/access_token', [
|
2026-01-17 02:46:30 +00:00
|
|
|
RequestOptions::QUERY => [
|
|
|
|
|
'grant_type' => 'ig_exchange_token',
|
feat: media gallery picker, custom emoji picker, preview tabs, real platform logos
- gallery: extract /assets tabs (uploads, Unsplash, Giphy) into shared
GalleryBrowser used by both /assets and a new MediaPickerDialog inside the
post editor; add JSON search endpoint for workspace assets with tests
- emoji: replace broken emoji-picker-element web component with a custom
EmojiPicker (full Unicode set, search, categories, recently-used,
light/dark, i18n)
- preview tab: platform selector pills, variant tabs (data-driven from
content_types map) so the user can switch Feed/Reel/Story etc. and have
it autosave through the same handler ScheduleTab uses
- platform logos: shared usePlatformLogo composable (logo + label + content
types); replaces inline maps across 5 components, fixes
instagram-facebook falling back to default.png
- tooltips: hover details (display_name · @username + platform label) on
platform avatars across editor, posts list and calendar
- settings cards: show ` · @username` in the title bar so multiple accounts
on the same network are distinguishable
- routes: drop the throttle:6,1 group middleware on social connect routes
(was 429ing legitimate OAuth retries) and rely on the default limiter
2026-05-01 17:53:49 +00:00
|
|
|
'client_id' => $this->clientId,
|
2026-01-17 02:46:30 +00:00
|
|
|
'client_secret' => $this->clientSecret,
|
2026-03-31 03:40:18 +00:00
|
|
|
'access_token' => data_get($data, 'access_token'),
|
2026-01-17 02:46:30 +00:00
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$longLivedData = json_decode((string) $response->getBody(), true);
|
|
|
|
|
|
|
|
|
|
return array_merge($data, [
|
|
|
|
|
'access_token' => $longLivedData['access_token'],
|
|
|
|
|
'expires_in' => $longLivedData['expires_in'] ?? null,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function getTokenFields($code): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'client_id' => $this->clientId,
|
|
|
|
|
'client_secret' => $this->clientSecret,
|
|
|
|
|
'grant_type' => 'authorization_code',
|
|
|
|
|
'redirect_uri' => $this->redirectUrl,
|
|
|
|
|
'code' => $code,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|