+ def to_for_user_and_mentions(user, mentions, inReplyTo, "public") do
+ mentioned_users = Enum.map(mentions, fn {_, %{ap_id: ap_id}} -> ap_id end)
+
+ to = ["https://www.w3.org/ns/activitystreams#Public" | mentioned_users]
+ cc = [user.follower_address]
+
+ if inReplyTo do
+ {Enum.uniq([inReplyTo.data["actor"] | to]), cc}
+ else
+ {to, cc}
+ end
+ end
+
+ def to_for_user_and_mentions(user, mentions, inReplyTo, "unlisted") do
+ mentioned_users = Enum.map(mentions, fn {_, %{ap_id: ap_id}} -> ap_id end)
+
+ to = [user.follower_address | mentioned_users]
+ cc = ["https://www.w3.org/ns/activitystreams#Public"]
+
+ if inReplyTo do
+ {Enum.uniq([inReplyTo.data["actor"] | to]), cc}
+ else
+ {to, cc}
+ end
+ end
+
+ def to_for_user_and_mentions(user, mentions, inReplyTo, "private") do
+ {to, cc} = to_for_user_and_mentions(user, mentions, inReplyTo, "direct")
+ {[user.follower_address | to], cc}
+ end
+
+ def to_for_user_and_mentions(_user, mentions, inReplyTo, "direct") do
+ mentioned_users = Enum.map(mentions, fn {_, %{ap_id: ap_id}} -> ap_id end)