1
0
mirror of https://github.com/flarum/core.git synced 2025-08-08 09:26:34 +02:00

feat: messages extension (#4028)

* feat: private messages
This commit is contained in:
Sami Mazouz
2024-09-28 11:12:52 +01:00
committed by GitHub
parent bc4356a7f5
commit b74ecbfacf
186 changed files with 5331 additions and 605 deletions

View File

@@ -0,0 +1,25 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
return Migration::createTable(
'dialogs',
function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('first_message_id')->nullable();
$table->unsignedBigInteger('last_message_id')->nullable();
$table->dateTime('last_message_at')->nullable();
$table->unsignedInteger('last_message_user_id')->nullable();
$table->foreign('last_message_user_id')->references('id')->on('users')->nullOnDelete();
$table->string('type');
$table->timestamps();
}
);

View File

@@ -0,0 +1,23 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
return Migration::createTable(
'dialog_messages',
function (Blueprint $table) {
$table->bigIncrements('id');
$table->foreignId('dialog_id')->constrained()->cascadeOnDelete();
$table->unsignedInteger('user_id')->nullable();
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
$table->text('content');
$table->timestamps();
}
);

View File

@@ -0,0 +1,24 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Flarum\Database\Migration;
use Illuminate\Database\Schema\Blueprint;
return Migration::createTable(
'dialog_user',
function (Blueprint $table) {
$table->id();
$table->foreignId('dialog_id')->constrained()->cascadeOnDelete();
$table->unsignedInteger('user_id');
$table->dateTime('joined_at');
$table->unsignedBigInteger('last_read_message_id')->default(0);
$table->dateTime('last_read_at')->nullable();
$table->foreign('user_id')->references('id')->on('users')->cascadeOnDelete();
}
);

View File

@@ -0,0 +1,26 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
return [
'up' => function (Builder $schema) {
$schema->table('dialogs', function (Blueprint $table) {
$table->foreign('first_message_id')->references('id')->on('dialog_messages')->nullOnDelete();
$table->foreign('last_message_id')->references('id')->on('dialog_messages')->nullOnDelete();
});
},
'down' => function (Builder $schema) {
$schema->table('dialogs', function (Blueprint $table) {
$table->dropForeign(['first_message_id']);
$table->dropForeign(['last_message_id']);
});
}
];

View File

@@ -0,0 +1,15 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Flarum\Database\Migration;
use Flarum\Group\Group;
return Migration::addPermissions([
'dialog.sendMessage' => Group::MEMBER_ID,
]);