obtaining actors from mentions and more pagination

This commit is contained in:
Ghostie 2025-01-09 18:49:13 -05:00
parent bffa72125a
commit 324b8e849f
5 changed files with 28 additions and 11 deletions

View File

@ -10,6 +10,8 @@ use App\Models\Actor;
use App\Models\Note; use App\Models\Note;
use App\Models\Hashtag; use App\Models\Hashtag;
use App\Helpers\PaginationHelper;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@ -127,6 +129,9 @@ class HomeController extends Controller
$sent_requests[] = $actor; $sent_requests[] = $actor;
} }
$received_requests = PaginationHelper::paginate (collect ($received_requests), 20, "received");
$sent_requests = PaginationHelper::paginate (collect ($sent_requests), 20, "sent");
return view ("users.requests", compact ("user", "received_requests", "sent_requests")); return view ("users.requests", compact ("user", "received_requests", "sent_requests"));
} }

View File

@ -206,6 +206,9 @@ class TypeActor {
$instance->save (); $instance->save ();
} }
// we need to save the model first
$actor->save ();
ProfileAttachment::where ("actor_id", $actor->id)->delete (); ProfileAttachment::where ("actor_id", $actor->id)->delete ();
foreach ($request ["attachment"] as $attachment) foreach ($request ["attachment"] as $attachment)
{ {
@ -245,7 +248,6 @@ class TypeActor {
$actor = new Actor (); $actor = new Actor ();
TypeActor::update_from_request ($actor, $request); TypeActor::update_from_request ($actor, $request);
$actor->save ();
return $actor; return $actor;
} }

View File

@ -182,20 +182,26 @@ class TypeNote
case "Mention": case "Mention":
$mention_name = $tag["name"]; $mention_name = $tag["name"];
$exploded_name = explode ("@", $mention_name);
$mention_actor = null; $mention_actor = null;
$actor_exists = Actor::where ("local_actor_id", $mention_name)->first (); $actor_exists = null;
if (!$actor_exists) Log::info (json_encode ($exploded_name));
if (count ($exploded_name) == 2)
{ {
// let's check if maybe it's local // let's check if maybe it's local
$processed_name = explode ("@", $mention_name); $actor_exists = Actor::where ("preferredUsername", $exploded_name [1])->first ();
if (count ($processed_name) < 2)
continue;
$actor_exists = Actor::where ("preferredUsername", $processed_name [1])->first ();
if (!$actor_exists) if (!$actor_exists)
continue; continue;
} }
else if (count ($exploded_name) == 3)
{
// maybe it's remote
$actor_exists = TypeActor::actor_exists_or_obtain_from_handle($exploded_name [1], $exploded_name [2]);
}
else
continue;
$mention = NoteMention::create ([ $mention = NoteMention::create ([
"note_id" => $note->id, "note_id" => $note->id,

View File

@ -70,7 +70,7 @@
{!! $note->content !!} {!! $note->content !!}
@foreach ($note->attachments as $attachment) @foreach ($note->attachments as $attachment)
<img loading="lazy" src="{{ $attachment->url }}" width="250"> <img loading="lazy" src="{{ $attachment->url }}" width="250" class="expandable">
@endforeach @endforeach
</div> </div>

View File

@ -14,7 +14,7 @@
<br> <br>
<p> <p>
<b> <b>
<span class="count">{{ count ($user->received_requests ()) }}</span> <span class="count">{{ $received_requests->total () }}</span>
Open Friend Requests Open Friend Requests
</b> </b>
@ -53,12 +53,14 @@
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
{{ $received_requests->withQueryString ()->links("pagination::default") }}
</p> </p>
<br> <br>
<p> <p>
<b> <b>
<span class="count">{{ count ($user->sent_requests ()) }}</span> <span class="count">{{ $sent_requests->total () }}</span>
Pending Friend Requests Pending Friend Requests
</b> </b>
<br> <br>
@ -92,6 +94,8 @@
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
{{ $sent_requests->withQueryString ()->links("pagination::default") }}
</p> </p>
</div> </div>
</div> </div>