Beginning of statuses/feed api.
This commit is contained in:
parent
f0ff6a69e4
commit
15a5a95005
|
|
@ -1,3 +1,4 @@
|
||||||
|
# Allow read in the public directories.
|
||||||
<Directory "C:/graphictoria/COMMIT_HASH/web/public/">
|
<Directory "C:/graphictoria/COMMIT_HASH/web/public/">
|
||||||
Require local
|
Require local
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
|
|
@ -7,6 +8,7 @@
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
|
# Defaults for the proceding virtualhosts on *.gtoria.net
|
||||||
<VirtualHost *:80 *:443>
|
<VirtualHost *:80 *:443>
|
||||||
ServerAdmin xlxi@gtoria.net
|
ServerAdmin xlxi@gtoria.net
|
||||||
ServerName gtoria.local
|
ServerName gtoria.local
|
||||||
|
|
@ -14,17 +16,23 @@
|
||||||
ServerAlias www.gtoria.local
|
ServerAlias www.gtoria.local
|
||||||
ServerAlias impulse.gtoria.local
|
ServerAlias impulse.gtoria.local
|
||||||
ServerAlias wiki.gtoria.local
|
ServerAlias wiki.gtoria.local
|
||||||
|
|
||||||
SSLEngine on
|
SSLEngine on
|
||||||
SSLCertificateFile "C:/graphictoria/COMMIT_HASH/etc/cert/localhost.crt"
|
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"
|
ErrorLog "C:/graphictoria/logs/gt-test-error.log"
|
||||||
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Host}i\" \"%{Referer}i\" \"%{User-agent}i\"" gtoria
|
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
|
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"
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
||||||
|
# Api endpoints.
|
||||||
<VirtualHost *:80 *:443>
|
<VirtualHost *:80 *:443>
|
||||||
ServerAlias api.gtoria.local
|
ServerAlias api.gtoria.local
|
||||||
ServerAlias apis.gtoria.local
|
ServerAlias apis.gtoria.local
|
||||||
|
|
@ -38,5 +46,5 @@
|
||||||
ServerAlias ecsv2.gtoria.local
|
ServerAlias ecsv2.gtoria.local
|
||||||
ServerAlias test.public.ecs.gtoria.local
|
ServerAlias test.public.ecs.gtoria.local
|
||||||
|
|
||||||
DocumentRoot "C:/graphictoria/COMMIT_HASH/web/public_api"
|
DocumentRoot "D:/wamp320/graphictoria/sitetest3/web/public_api"
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
@ -3,13 +3,71 @@
|
||||||
namespace App\Http\Controllers\Api;
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Friend;
|
||||||
|
use App\Models\Shout;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class FeedController extends Controller
|
class FeedController extends Controller
|
||||||
{
|
{
|
||||||
protected function listjson()
|
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()
|
protected function handle()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Friend extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Shout extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('friends', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('shouts', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue