diff --git a/app/Models/NoteAttachment.php b/app/Models/NoteAttachment.php index b65f6e6..666970e 100644 --- a/app/Models/NoteAttachment.php +++ b/app/Models/NoteAttachment.php @@ -8,6 +8,7 @@ class NoteAttachment extends Model { protected $fillable = [ "note_id", - "url" + "url", + "media_type" ]; } diff --git a/app/Types/TypeNote.php b/app/Types/TypeNote.php index fe01061..b5eeafb 100644 --- a/app/Types/TypeNote.php +++ b/app/Types/TypeNote.php @@ -143,7 +143,8 @@ class TypeNote if (!$exists) $note_attachment = NoteAttachment::create ([ "note_id" => $note->id, - "url" => $attachment ["url"] + "url" => $attachment ["url"], + "media_type" => $attachment ["mediaType"] ]); } } diff --git a/database/migrations/2025_01_09_235558_add_fields_to_note_attachments_table.php b/database/migrations/2025_01_09_235558_add_fields_to_note_attachments_table.php new file mode 100644 index 0000000..249ebf2 --- /dev/null +++ b/database/migrations/2025_01_09_235558_add_fields_to_note_attachments_table.php @@ -0,0 +1,28 @@ +string ("media_type")->nullable (); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('note_attachments', function (Blueprint $table) { + $table->dropColumn ("media_type"); + }); + } +}; diff --git a/resources/views/posts/show.blade.php b/resources/views/posts/show.blade.php index d7bdcfe..b03d18a 100644 --- a/resources/views/posts/show.blade.php +++ b/resources/views/posts/show.blade.php @@ -70,7 +70,12 @@ {!! $note->content !!} @foreach ($note->attachments as $attachment) - + {{-- check if $attachment->media_type starts with image/ --}} + @if (str_starts_with ($attachment->media_type, "image/") || $attachment->media_type == null) + + @else +

Attachment {{ $attachment->media_type }} is not supported yet

+ @endif @endforeach @@ -92,7 +97,23 @@

Likes: {{ $note->get_likes ()->count () }}
- Boosts: {{ $note->get_boosts ()->count () }} + Boosts: {{ $note->get_boosts ()->count () }}
+ Hashtags: + + @foreach ($note->get_hashtags ()->get () as $hashtag) + + {{ $hashtag->name }} + + @endforeach +
+ Mentions: + + @foreach ($note->get_mentions ()->get () as $mention) + + {{ $mention->actor->local_actor_id ?? '@' . $mention->actor->preferredUsername }} + + @endforeach +