X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fostatus%2Fhandlers%2Fnote_handler.ex;h=38f9fc478e381857a00663472bace236297a4d3e;hb=611ca385dea3d611a97579000311cc42684305e6;hp=dda5c7d5ea5dd15983c3812098fbd1bb355e3944;hpb=16b1fcd2719b744c81851e778df2519dc0131010;p=akkoma diff --git a/lib/pleroma/web/ostatus/handlers/note_handler.ex b/lib/pleroma/web/ostatus/handlers/note_handler.ex index dda5c7d5e..38f9fc478 100644 --- a/lib/pleroma/web/ostatus/handlers/note_handler.ex +++ b/lib/pleroma/web/ostatus/handlers/note_handler.ex @@ -88,12 +88,14 @@ defmodule Pleroma.Web.OStatus.NoteHandler do end end + # TODO: Clean this up a bit. def handle_note(entry, doc \\ nil) do with id <- XML.string_from_xpath("//id", entry), activity when is_nil(activity) <- Activity.get_create_activity_by_object_ap_id(id), [author] <- :xmerl_xpath.string('//author[1]', doc), {:ok, actor} <- OStatus.find_make_or_update_user(author), content_html <- OStatus.get_content(entry), + cw <- OStatus.get_cw(entry), inReplyTo <- XML.string_from_xpath("//thr:in-reply-to[1]/@ref", entry), inReplyToActivity <- fetch_replied_to_activity(entry, inReplyTo), inReplyTo <- (inReplyToActivity && inReplyToActivity.data["object"]["id"]) || inReplyTo, @@ -103,16 +105,19 @@ defmodule Pleroma.Web.OStatus.NoteHandler do mentions <- get_mentions(entry), to <- make_to_list(actor, mentions), date <- XML.string_from_xpath("//published", entry), - note <- CommonAPI.Utils.make_note_data(actor.ap_id, to, context, content_html, attachments, inReplyToActivity, []), + unlisted <- XML.string_from_xpath("//mastodon:scope", entry) == "unlisted", + cc <- if(unlisted, do: ["https://www.w3.org/ns/activitystreams#Public"], else: []), + note <- CommonAPI.Utils.make_note_data(actor.ap_id, to, context, content_html, attachments, inReplyToActivity, [], cw), note <- note |> Map.put("id", id) |> Map.put("tag", tags), note <- note |> Map.put("published", date), note <- note |> Map.put("emoji", get_emoji(entry)), note <- add_external_url(note, entry), + note <- note |> Map.put("cc", cc), # TODO: Handle this case in make_note_data note <- (if inReplyTo && !inReplyToActivity, do: note |> Map.put("inReplyTo", inReplyTo), else: note) do - res = ActivityPub.create(to, actor, context, note, %{}, date, false) - User.update_note_count(actor) + res = ActivityPub.create(%{to: to, actor: actor, context: context, object: note, published: date, local: false, additional: %{"cc" => cc}}) + User.increase_note_count(actor) res else %Activity{} = activity -> {:ok, activity}