diff options
author | lain <lain@soykaf.club> | 2020-05-04 17:18:17 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-05-04 17:18:17 +0200 |
commit | 0f9bed022fab80f59353597dde82896ef954a678 (patch) | |
tree | 05413547cb438479023e87ef4656e214506562ea /lib | |
parent | e03c301ebeea6687ee7f19d447232864b182d581 (diff) | |
download | pleroma-0f9bed022fab80f59353597dde82896ef954a678.tar.gz |
LikeValidator: Fix up context.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/activity_pub/object_validators/like_validator.ex | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/pleroma/web/activity_pub/object_validators/like_validator.ex b/lib/pleroma/web/activity_pub/object_validators/like_validator.ex index d9ee07995..1bce739bd 100644 --- a/lib/pleroma/web/activity_pub/object_validators/like_validator.ex +++ b/lib/pleroma/web/activity_pub/object_validators/like_validator.ex @@ -44,11 +44,25 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator do def fix_after_cast(cng) do cng |> fix_recipients() + |> fix_context() + end + + def fix_context(cng) do + object = get_field(cng, :object) + + with nil <- get_field(cng, :context), + %Object{data: %{"context" => context}} <- Object.get_cached_by_ap_id(object) do + cng + |> put_change(:context, context) + else + _ -> + cng + end end def fix_recipients(cng) do - to = get_field(cng, :to) || [] - cc = get_field(cng, :cc) || [] + to = get_field(cng, :to) + cc = get_field(cng, :cc) object = get_field(cng, :object) with {[], []} <- {to, cc}, |