diff --git a/app/Http/Controllers/CommunitiesController.php b/app/Http/Controllers/PlatformChannelsController.php
similarity index 53%
rename from app/Http/Controllers/CommunitiesController.php
rename to app/Http/Controllers/PlatformChannelsController.php
index 3321035..6816d21 100644
--- a/app/Http/Controllers/CommunitiesController.php
+++ b/app/Http/Controllers/PlatformChannelsController.php
@@ -2,22 +2,22 @@
namespace App\Http\Controllers;
-use App\Models\Community;
+use App\Models\PlatformChannel;
use App\Models\PlatformInstance;
use Illuminate\Http\Request;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
-class CommunitiesController extends Controller
+class PlatformChannelsController extends Controller
{
public function index(): View
{
- $communities = Community::with('platformInstance')
+ $channels = PlatformChannel::with('platformInstance')
->orderBy('platform_instance_id')
->orderBy('name')
->get();
- return view('pages.communities.index', compact('communities'));
+ return view('pages.channels.index', compact('channels'));
}
public function create(): View
@@ -26,7 +26,7 @@ public function create(): View
->orderBy('name')
->get();
- return view('pages.communities.create', compact('instances'));
+ return view('pages.channels.create', compact('instances'));
}
public function store(Request $request): RedirectResponse
@@ -35,46 +35,46 @@ public function store(Request $request): RedirectResponse
'platform_instance_id' => 'required|exists:platform_instances,id',
'name' => 'required|string|max:255',
'display_name' => 'required|string|max:255',
- 'community_id' => 'required|string|max:255',
+ 'channel_id' => 'required|string|max:255',
'description' => 'nullable|string',
]);
- Community::create($validated);
+ PlatformChannel::create($validated);
- return redirect()->route('communities.index')
- ->with('success', 'Community created successfully!');
+ return redirect()->route('channels.index')
+ ->with('success', 'Channel created successfully!');
}
- public function edit(Community $community): View
+ public function edit(PlatformChannel $channel): View
{
$instances = PlatformInstance::where('is_active', true)
->orderBy('name')
->get();
- return view('pages.communities.edit', compact('community', 'instances'));
+ return view('pages.channels.edit', compact('channel', 'instances'));
}
- public function update(Request $request, Community $community): RedirectResponse
+ public function update(Request $request, PlatformChannel $channel): RedirectResponse
{
$validated = $request->validate([
'platform_instance_id' => 'required|exists:platform_instances,id',
'name' => 'required|string|max:255',
'display_name' => 'required|string|max:255',
- 'community_id' => 'required|string|max:255',
+ 'channel_id' => 'required|string|max:255',
'description' => 'nullable|string',
]);
- $community->update($validated);
+ $channel->update($validated);
- return redirect()->route('communities.index')
- ->with('success', 'Community updated successfully!');
+ return redirect()->route('channels.index')
+ ->with('success', 'Channel updated successfully!');
}
- public function destroy(Community $community): RedirectResponse
+ public function destroy(PlatformChannel $channel): RedirectResponse
{
- $community->delete();
+ $channel->delete();
- return redirect()->route('communities.index')
- ->with('success', 'Community deleted successfully!');
+ return redirect()->route('channels.index')
+ ->with('success', 'Channel deleted successfully!');
}
}
\ No newline at end of file
diff --git a/app/Models/PlatformAccount.php b/app/Models/PlatformAccount.php
index 0ca039b..9debe43 100644
--- a/app/Models/PlatformAccount.php
+++ b/app/Models/PlatformAccount.php
@@ -22,7 +22,7 @@
* @property string $status
* @property Carbon $created_at
* @property Carbon $updated_at
- * @property Collection $activeCommunities
+ * @property Collection $activeChannels
* @method static where(string $string, PlatformEnum $platform)
* @method static orderBy(string $string)
* @method static create(array $validated)
@@ -86,16 +86,16 @@ public function setAsActive(): void
$this->update(['is_active' => true]);
}
- public function communities(): BelongsToMany
+ public function channels(): BelongsToMany
{
- return $this->belongsToMany(Community::class, 'account_communities')
+ return $this->belongsToMany(PlatformChannel::class, 'platform_account_channels')
->withPivot(['is_active', 'priority'])
->withTimestamps();
}
- public function activeCommunities(): BelongsToMany
+ public function activeChannels(): BelongsToMany
{
- return $this->communities()
+ return $this->channels()
->wherePivot('is_active', true)
->orderByPivot('priority', 'desc');
}
diff --git a/app/Models/Community.php b/app/Models/PlatformChannel.php
similarity index 66%
rename from app/Models/Community.php
rename to app/Models/PlatformChannel.php
index 012ba4e..bfe7d50 100644
--- a/app/Models/Community.php
+++ b/app/Models/PlatformChannel.php
@@ -10,13 +10,15 @@
* @method static create(array $validated)
* @property PlatformInstance $platformInstance
*/
-class Community extends Model
+class PlatformChannel extends Model
{
+ protected $table = 'platform_channels';
+
protected $fillable = [
'platform_instance_id',
'name',
'display_name',
- 'community_id',
+ 'channel_id',
'description',
'is_active'
];
@@ -32,13 +34,15 @@ public function platformInstance(): BelongsTo
public function platformAccounts(): BelongsToMany
{
- return $this->belongsToMany(PlatformAccount::class, 'account_communities')
+ return $this->belongsToMany(PlatformAccount::class, 'platform_account_channels')
->withPivot(['is_active', 'priority'])
->withTimestamps();
}
public function getFullNameAttribute(): string
{
- return $this->platformInstance->url . '/c/' . $this->name;
+ // For Lemmy, use /c/ prefix. Other platforms may use different formats
+ $prefix = $this->platformInstance->platform === 'lemmy' ? '/c/' : '/';
+ return $this->platformInstance->url . $prefix . $this->name;
}
}
diff --git a/app/Modules/Lemmy/Services/LemmyPublisher.php b/app/Modules/Lemmy/Services/LemmyPublisher.php
index 8ba5d44..d9bfcd1 100644
--- a/app/Modules/Lemmy/Services/LemmyPublisher.php
+++ b/app/Modules/Lemmy/Services/LemmyPublisher.php
@@ -42,27 +42,27 @@ public static function fromActiveAccount(): self
public function publish(Article $article, array $extractedData): Collection
{
$publications = collect();
- $activeCommunities = $this->account->activeCommunities;
+ $activeChannels = $this->account->activeChannels;
- if ($activeCommunities->isEmpty()) {
- throw new PublishException($article, PlatformEnum::LEMMY, new RuntimeException('No active communities configured for account: ' . $this->account->username));
+ if ($activeChannels->isEmpty()) {
+ throw new PublishException($article, PlatformEnum::LEMMY, new RuntimeException('No active channels configured for account: ' . $this->account->username));
}
- $activeCommunities->each(function ($community) use ($article, $extractedData, $publications) {
+ $activeChannels->each(function ($channel) use ($article, $extractedData, $publications) {
try {
- $publication = $this->publishToCommunity($article, $extractedData, $community);
+ $publication = $this->publishToChannel($article, $extractedData, $channel);
$publications->push($publication);
} catch (Exception $e) {
- logger()->warning('Failed to publish to community', [
+ logger()->warning('Failed to publish to channel', [
'article_id' => $article->id,
- 'community' => $community->name,
+ 'channel' => $channel->name,
'error' => $e->getMessage()
]);
}
});
if ($publications->isEmpty()) {
- throw new PublishException($article, PlatformEnum::LEMMY, new RuntimeException('Failed to publish to any community'));
+ throw new PublishException($article, PlatformEnum::LEMMY, new RuntimeException('Failed to publish to any channel'));
}
return $publications;
@@ -72,7 +72,7 @@ public function publish(Article $article, array $extractedData): Collection
* @throws PlatformAuthException
* @throws Exception
*/
- private function publishToCommunity(Article $article, array $extractedData, $community): ArticlePublication
+ private function publishToChannel(Article $article, array $extractedData, $channel): ArticlePublication
{
$token = LemmyAuthService::getToken($this->account);
$languageId = $this->getLanguageIdForSource($article->url);
@@ -81,21 +81,21 @@ private function publishToCommunity(Article $article, array $extractedData, $com
$token,
$extractedData['title'] ?? 'Untitled',
$extractedData['description'] ?? '',
- (int) $community->community_id,
+ (int) $channel->channel_id,
$article->url,
$extractedData['thumbnail'] ?? null,
$languageId
);
- return $this->createPublicationRecord($article, $postData, (int) $community->community_id);
+ return $this->createPublicationRecord($article, $postData, (int) $channel->channel_id);
}
- private function createPublicationRecord(Article $article, array $postData, int $communityId): ArticlePublication
+ private function createPublicationRecord(Article $article, array $postData, int $channelId): ArticlePublication
{
return ArticlePublication::create([
'article_id' => $article->id,
'post_id' => $postData['post_view']['post']['id'],
- 'community_id' => $communityId,
+ 'community_id' => $channelId,
'published_by' => $this->account->username,
'published_at' => now(),
'platform' => 'lemmy',
diff --git a/database/migrations/2025_07_04_233100_create_communities_table.php b/database/migrations/2025_07_04_233100_create_platform_channels_table.php
similarity index 78%
rename from database/migrations/2025_07_04_233100_create_communities_table.php
rename to database/migrations/2025_07_04_233100_create_platform_channels_table.php
index 48ae8a9..51b1c0a 100644
--- a/database/migrations/2025_07_04_233100_create_communities_table.php
+++ b/database/migrations/2025_07_04_233100_create_platform_channels_table.php
@@ -8,12 +8,12 @@
{
public function up(): void
{
- Schema::create('communities', function (Blueprint $table) {
+ Schema::create('platform_channels', function (Blueprint $table) {
$table->id();
$table->foreignId('platform_instance_id')->constrained()->onDelete('cascade');
$table->string('name'); // "technology"
$table->string('display_name'); // "Technology"
- $table->string('community_id'); // API ID from platform
+ $table->string('channel_id'); // API ID from platform
$table->text('description')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
@@ -24,6 +24,6 @@ public function up(): void
public function down(): void
{
- Schema::dropIfExists('communities');
+ Schema::dropIfExists('platform_channels');
}
};
\ No newline at end of file
diff --git a/database/migrations/2025_07_04_233200_create_account_communities_table.php b/database/migrations/2025_07_04_233200_create_platform_account_channels_table.php
similarity index 63%
rename from database/migrations/2025_07_04_233200_create_account_communities_table.php
rename to database/migrations/2025_07_04_233200_create_platform_account_channels_table.php
index 02bd15c..87bb22e 100644
--- a/database/migrations/2025_07_04_233200_create_account_communities_table.php
+++ b/database/migrations/2025_07_04_233200_create_platform_account_channels_table.php
@@ -8,19 +8,19 @@
{
public function up(): void
{
- Schema::create('account_communities', function (Blueprint $table) {
+ Schema::create('platform_account_channels', function (Blueprint $table) {
$table->foreignId('platform_account_id')->constrained()->onDelete('cascade');
- $table->foreignId('community_id')->constrained()->onDelete('cascade');
+ $table->foreignId('platform_channel_id')->constrained()->onDelete('cascade');
$table->boolean('is_active')->default(false);
$table->integer('priority')->default(0); // for ordering
$table->timestamps();
- $table->primary(['platform_account_id', 'community_id']);
+ $table->primary(['platform_account_id', 'platform_channel_id']);
});
}
public function down(): void
{
- Schema::dropIfExists('account_communities');
+ Schema::dropIfExists('platform_account_channels');
}
};
\ No newline at end of file
diff --git a/resources/views/partials/sidebar.blade.php b/resources/views/partials/sidebar.blade.php
index c19df02..d48b406 100644
--- a/resources/views/partials/sidebar.blade.php
+++ b/resources/views/partials/sidebar.blade.php
@@ -13,9 +13,9 @@
Platforms
-
-
- Communities
+
+
+ Channels
diff --git a/routes/web.php b/routes/web.php
index a5e583b..fbd0989 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -24,4 +24,4 @@
Route::resource('platforms', App\Http\Controllers\PlatformAccountsController::class)->names('platforms');
Route::post('/platforms/{platformAccount}/set-active', [App\Http\Controllers\PlatformAccountsController::class, 'setActive'])->name('platforms.set-active');
-Route::resource('communities', App\Http\Controllers\CommunitiesController::class)->names('communities');
+Route::resource('channels', App\Http\Controllers\PlatformChannelsController::class)->names('channels');