diff --git a/README.md b/README.md index bb9420e..1e1c55f 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ Notice that the styles were taken from [AnySpace](https://anyspace.3to.moe/about - [-] Activitypub - [x] Accounts - [-] Posts - - [ ] Local posts should be federated - - [ ] Local posts should be deleted + - [x] Local posts should be federated + - [x] Local posts should be deleted - [x] Remote posts should be fetched - [x] Remote posts should be deleted - [x] Follows @@ -28,7 +28,7 @@ Notice that the styles were taken from [AnySpace](https://anyspace.3to.moe/about - [x] Profile - [ ] Show when the user is online - [ ] Set mood - - [ ] Set interests + - [x] Set interests - [x] Update profile picture - [ ] Mark account as private (in federation manual approval is needed) - [ ] Allow custom CSS @@ -36,8 +36,8 @@ Notice that the styles were taken from [AnySpace](https://anyspace.3to.moe/about - [x] Friends (they are known as follows in the activitypub protocol) - [x] Add friends - [x] Remove friends - - [ ] Posts (everything should be federated) - - [ ] Create posts + - [x] Posts (everything should be federated) + - [x] Create posts - [ ] Delete posts - [ ] Like posts - [ ] Comment posts diff --git a/app/Http/Controllers/AP/APInstanceInboxController.php b/app/Http/Controllers/AP/APInstanceInboxController.php index a08ef48..09c85ef 100644 --- a/app/Http/Controllers/AP/APInstanceInboxController.php +++ b/app/Http/Controllers/AP/APInstanceInboxController.php @@ -95,6 +95,15 @@ class APInstanceInboxController extends Controller case "Person": return $this->handle_update_person ($object); break; + + case "Note": + return $this->handle_update_note ($object); + break; + + default: + Log::info ("APInstanceInboxController:handle_update"); + Log::info (json_encode ($activity)); + break; } return response ()->json (["status" => "ok"]); @@ -127,4 +136,16 @@ class APInstanceInboxController extends Controller return response ()->json (["status" => "ok"]); } + + public function handle_update_note ($object) + { + $note = TypeNote::note_exists ($object ["id"]); + if (!$note) + return response ()->json (["status" => "ok"]); + + TypeNote::update_from_request ($note, $object, $note->get_activity ()->first (), $note->get_actor ()->first ()); + $note->save (); + + return response ()->json (["status" => "ok"]); + } } diff --git a/app/Http/Controllers/PostController.php b/app/Http/Controllers/PostController.php new file mode 100644 index 0000000..61c44e6 --- /dev/null +++ b/app/Http/Controllers/PostController.php @@ -0,0 +1,17 @@ +get_actor ()->first (); + + return view ("posts.show", compact ("note", "actor")); + } +} diff --git a/app/Models/User.php b/app/Models/User.php index 7179a3c..0238c3b 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -92,4 +92,21 @@ class User extends Authenticatable return array_diff ($followers, $following); } + + public function feed () + { + $mutual_friends = $this->mutual_friends (); + $friends_id = [ + $this->actor ()->first ()->id + ]; + + foreach ($mutual_friends as $friend) + { + $friends_id[] = Actor::where ("actor_id", $friend)->first ()->id; + } + + $notes = Note::whereIn ("actor_id", $friends_id)->orderBy ("created_at", "desc")->get (); + + return $notes; + } } diff --git a/app/Types/TypeNote.php b/app/Types/TypeNote.php index f3ecb55..306079b 100644 --- a/app/Types/TypeNote.php +++ b/app/Types/TypeNote.php @@ -76,14 +76,22 @@ class TypeNote $note->content = $request["content"] ?? null; $note->tag = $request["tag"] ?? null; + $attachments = $note->attachments ()->get (); + foreach ($attachments as $attachment) + $attachment->delete (); + if ($request ["attachment"]) { + foreach ($request ["attachment"] as $attachment) { - $note_attachment = NoteAttachment::create ([ - "note_id" => $note->id, - "url" => $attachment ["url"] - ]); + $attachment_url = $attachment ["url"]; + $exists = NoteAttachment::where ("url", $attachment_url)->first (); + if (!$exists) + $note_attachment = NoteAttachment::create ([ + "note_id" => $note->id, + "url" => $attachment ["url"] + ]); } } } diff --git a/resources/views/components/comment_block.blade.php b/resources/views/components/comment_block.blade.php index f4469eb..ac4ee0e 100644 --- a/resources/views/components/comment_block.blade.php +++ b/resources/views/components/comment_block.blade.php @@ -27,16 +27,34 @@ else
- +
-- {!! $post->content !!} -
+ + {!! $post->content !!} +
@foreach ($post->attachments as $attachment)
@endforeach
Comments
++ Displaying 0 of 0 comments +
+ +