Fix posting from FE not saving object

This commit is contained in:
Shadowfacts 2020-04-20 22:40:48 -04:00
parent 734e30584a
commit 8d1be99036
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,6 @@
defmodule ClacksWeb.FrontendController do
use ClacksWeb, :controller
alias Clacks.{Actor, User, Timeline, Repo, ActivityPub, Activity}
alias Clacks.{Actor, User, Timeline, Repo, ActivityPub, Activity, Object}
alias ClacksWeb.Router.Helpers, as: Routes
alias ClacksWeb.Endpoint
@ -90,10 +90,12 @@ defmodule ClacksWeb.FrontendController do
current_user = conn.assigns[:user] |> Repo.preload(:actor)
note = ActivityPub.note(current_user.actor.ap_id, content)
create = ActivityPub.create(note)
changeset = Activity.changeset_for_creating(create, true)
note_changeset = Object.changeset_for_creating(note)
{:ok, object} = Repo.insert(note_changeset)
{:ok, activity} = Repo.insert(changeset)
create = ActivityPub.create(note)
create_changeset = Activity.changeset_for_creating(create, true)
{:ok, activity} = Repo.insert(create_changeset)
%{id: activity.id, actor_id: current_user.actor.id}
|> Clacks.Worker.Federate.new()