diff --git a/etc/graphictoria.conf b/etc/graphictoria.conf
index 55b63d2..adc676e 100644
--- a/etc/graphictoria.conf
+++ b/etc/graphictoria.conf
@@ -1,3 +1,4 @@
+# Allow read in the public directories.
Require local
AllowOverride All
@@ -7,6 +8,7 @@
AllowOverride All
+# Defaults for the proceding virtualhosts on *.gtoria.net
ServerAdmin xlxi@gtoria.net
ServerName gtoria.local
@@ -14,17 +16,23 @@
ServerAlias www.gtoria.local
ServerAlias impulse.gtoria.local
ServerAlias wiki.gtoria.local
-
+
SSLEngine on
SSLCertificateFile "C:/graphictoria/COMMIT_HASH/etc/cert/localhost.crt"
- SSLCertificateKeyFile "C:/graphictoria/COMMIT_HASH/etc/cert/localhost.key"
-
+ SSLCertificateKeyFile "C:/graphictoria/COMMIT_HASH/etc/cert/localhost.key"
+
ErrorLog "C:/graphictoria/logs/gt-test-error.log"
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Host}i\" \"%{Referer}i\" \"%{User-agent}i\"" gtoria
CustomLog "C:/graphictoria/logs/gt-test-access.log" gtoria
- DocumentRoot "C:/graphictoria/COMMIT_HASH/web/public"
+
+ RewriteEngine On
+ RewriteCond %{HTTP_HOST} !^www\. [NC]
+ RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
+
+ DocumentRoot "D:/wamp320/graphictoria/sitetest3/web/public"
+# Api endpoints.
ServerAlias api.gtoria.local
ServerAlias apis.gtoria.local
@@ -38,5 +46,5 @@
ServerAlias ecsv2.gtoria.local
ServerAlias test.public.ecs.gtoria.local
- DocumentRoot "C:/graphictoria/COMMIT_HASH/web/public_api"
+ DocumentRoot "D:/wamp320/graphictoria/sitetest3/web/public_api"
\ No newline at end of file
diff --git a/web/app/Http/Controllers/Api/FeedController.php b/web/app/Http/Controllers/Api/FeedController.php
index b6a8793..37c9215 100644
--- a/web/app/Http/Controllers/Api/FeedController.php
+++ b/web/app/Http/Controllers/Api/FeedController.php
@@ -3,13 +3,71 @@
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
+use App\Models\Friend;
+use App\Models\Shout;
+use App\Models\User;
use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\DB;
class FeedController extends Controller
{
protected function listjson()
{
- //
+ // TODO: XlXi: Group shouts.
+ $postsQuery = Shout::where([['poster_type', 'user'], ['deleted', '0']])
+ ->where(function($query) {
+ $query->where('poster_id', Auth::id())
+ ->orWhereExists(function($query) {
+ $query->select(DB::raw('*'))
+ ->from('friends')
+ ->where('accepted', 1)
+ ->where(function($query) {
+ $query->whereColumn('shouts.poster_id', 'friends.sender_id')
+ ->orWhereColumn('shouts.poster_id', 'friends.receiver_id');
+ });
+ });
+ })
+ ->orderByDesc('created_at')
+ ->cursorPaginate(15);
+
+ /* */
+
+ $prevCursor = $postsQuery->previousCursor();
+ $nextCursor = $postsQuery->nextCursor();
+
+ $posts = [
+ 'data' => [],
+ 'prev_cursor' => ($prevCursor ? $prevCursor->encode() : null),
+ 'next_cursor' => ($nextCursor ? $nextCursor->encode() : null)
+ ];
+
+ foreach($postsQuery as $post) {
+ // TODO: XlXi: icons/colors
+ // TODO: XlXi: groups
+
+ $poster = [];
+ if($post['poster_type'] == 'user') {
+ $user = User::where('id', $post['poster_id'])->first();
+
+ $poster = [
+ 'type' => 'User',
+ 'name' => $user->username,
+ 'thumbnail' => 'https://www.gtoria.local/images/testing/headshot.png'
+ ];
+ }
+
+ /* */
+
+ array_push($posts['data'], [
+ 'postId' => $post['id'],
+ 'poster' => $poster,
+ 'content' => $post['content'],
+ 'time' => $post['updated_at']
+ ]);
+ }
+
+ return response($posts);
}
protected function handle()
diff --git a/web/app/Models/Friend.php b/web/app/Models/Friend.php
new file mode 100644
index 0000000..2027431
--- /dev/null
+++ b/web/app/Models/Friend.php
@@ -0,0 +1,11 @@
+id();
+ $table->unsignedBigInteger('sender_id');
+ $table->unsignedBigInteger('receiver_id');
+ $table->boolean('accepted')->default(false);
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('friends');
+ }
+};
diff --git a/web/database/migrations/2022_05_22_151023_create_shouts_table.php b/web/database/migrations/2022_05_22_151023_create_shouts_table.php
new file mode 100644
index 0000000..7fd4611
--- /dev/null
+++ b/web/database/migrations/2022_05_22_151023_create_shouts_table.php
@@ -0,0 +1,35 @@
+id();
+ $table->unsignedBigInteger('poster_id');
+ $table->enum('poster_type', ['user', 'group']);
+ $table->longText('content');
+ $table->boolean('deleted')->default(false);
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('shouts');
+ }
+};