From b5e872a670e59841cab3b533ee66edb3ab74342d Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 19 Nov 2019 10:46:54 +0100 Subject: [PATCH 1/4] Handle missing geolix database Close #313 Signed-off-by: Thomas Citharel --- lib/mobilizon_web/resolvers/config.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mobilizon_web/resolvers/config.ex b/lib/mobilizon_web/resolvers/config.ex index 3f13c968b..73f436f0c 100644 --- a/lib/mobilizon_web/resolvers/config.ex +++ b/lib/mobilizon_web/resolvers/config.ex @@ -15,13 +15,13 @@ defmodule MobilizonWeb.Resolvers.Config do geolix = Geolix.lookup(ip) country_code = - case geolix.city do + case Map.get(geolix, :city) do %{country: %Country{iso_code: country_code}} -> String.downcase(country_code) _ -> nil end location = - case geolix.city do + case Map.get(geolix, :city) do %{location: %Location{} = location} -> Map.from_struct(location) _ -> nil end From 1a82a644110739afbc123a8459b9dde7e5641911 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 19 Nov 2019 11:12:59 +0100 Subject: [PATCH 2/4] Include sender mail in from: emails Closes #277 Signed-off-by: Thomas Citharel --- lib/mobilizon_web/email/email.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mobilizon_web/email/email.ex b/lib/mobilizon_web/email/email.ex index ec12bc792..0bcb221c1 100644 --- a/lib/mobilizon_web/email/email.ex +++ b/lib/mobilizon_web/email/email.ex @@ -13,7 +13,7 @@ defmodule MobilizonWeb.Email do args |> new_email() - |> from(Config.instance_email_from()) + |> from({Config.instance_name(), Config.instance_email_from()}) |> put_header("Reply-To", Config.instance_email_reply_to()) |> assign(:instance, instance) |> put_html_layout({MobilizonWeb.EmailView, "email.html"}) From 4462807edb5dcc6eb729f21765a795cdf735a515 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 19 Nov 2019 12:04:35 +0100 Subject: [PATCH 3/4] Add share to Diaspora* button Related to #227 Signed-off-by: Thomas Citharel --- js/src/assets/diaspora-icon.svg | 4 ++++ js/src/views/Event/Event.vue | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 js/src/assets/diaspora-icon.svg diff --git a/js/src/assets/diaspora-icon.svg b/js/src/assets/diaspora-icon.svg new file mode 100644 index 000000000..7a5b5cf3a --- /dev/null +++ b/js/src/assets/diaspora-icon.svg @@ -0,0 +1,4 @@ + + + + diff --git a/js/src/views/Event/Event.vue b/js/src/views/Event/Event.vue index 50d2e0918..16446921e 100644 --- a/js/src/views/Event/Event.vue +++ b/js/src/views/Event/Event.vue @@ -184,11 +184,17 @@
- + + + + + + diaspora-logo + + -

@@ -591,6 +597,10 @@ export default class Event extends EventMixin { return `mailto:?to=&body=${this.event.url}${encodeURIComponent('\n\n')}${this.textDescription}&subject=${this.event.title}`; } + get diasporaShareUrl(): string { + return `https://share.diasporafoundation.org/?title=${encodeURIComponent(this.event.title)}&url=${encodeURIComponent(this.event.url)}`; + } + get textDescription(): string { const meta = document.querySelector("meta[property='og:description']"); if (!meta) return ''; @@ -899,6 +909,11 @@ export default class Event extends EventMixin { .share { border-bottom: solid 1px #111; + .diaspora span svg { + height: 2rem; + width: 2rem; + } + .columns { & > * { From e2e2e157ddc8cb92e68fc2e7008c6cb6c083df16 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 19 Nov 2019 15:36:25 +0100 Subject: [PATCH 4/4] Fix duplicate tags when editing an event with tags in description Signed-off-by: Thomas Citharel --- lib/service/activity_pub/converter/utils.ex | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/service/activity_pub/converter/utils.ex b/lib/service/activity_pub/converter/utils.ex index 54e815e9c..ba2f3a2af 100644 --- a/lib/service/activity_pub/converter/utils.ex +++ b/lib/service/activity_pub/converter/utils.ex @@ -15,7 +15,7 @@ defmodule Mobilizon.Service.ActivityPub.Converter.Utils do def fetch_tags(tags) when is_list(tags) do Logger.debug("fetching tags") - Enum.reduce(tags, [], &fetch_tag/2) + tags |> Enum.flat_map(&fetch_tag/1) |> Enum.uniq() |> Enum.map(&existing_tag_or_data/1) end @spec fetch_mentions([map()]) :: [map()] @@ -64,23 +64,20 @@ defmodule Mobilizon.Service.ActivityPub.Converter.Utils do } end - defp fetch_tag(tag, acc) when is_map(tag) do + defp fetch_tag(tag) when is_map(tag) do case tag["type"] do "Hashtag" -> - acc ++ [existing_tag_or_data(tag["name"])] + [tag_without_hash(tag["name"])] _err -> - acc + [] end end - defp fetch_tag(tag, acc) when is_bitstring(tag) do - acc ++ [existing_tag_or_data(tag)] - end + defp fetch_tag(tag) when is_bitstring(tag), do: [tag_without_hash(tag)] - defp existing_tag_or_data("#" <> tag_title) do - existing_tag_or_data(tag_title) - end + defp tag_without_hash("#" <> tag_title), do: tag_title + defp tag_without_hash(tag_title), do: tag_title defp existing_tag_or_data(tag_title) do case Events.get_tag_by_title(tag_title) do