Merge branch 'hashtag-fixes' into 'main'
Exclude tags with more than 40 characters from being extracted. Closes #939 et #562 See merge request framasoft/mobilizon!1214
This commit is contained in:
commit
e26364f973
@ -1,18 +1,22 @@
|
||||
<template>
|
||||
<label for="navSearchField">
|
||||
<span class="visually-hidden">{{ defaultPlaceHolder }}</span>
|
||||
<b-field label-for="navSearchField" class="-mt-2">
|
||||
<b-input
|
||||
custom-class="searchField"
|
||||
:placeholder="defaultPlaceHolder"
|
||||
type="search"
|
||||
id="navSearchField"
|
||||
icon="magnify"
|
||||
type="search"
|
||||
icon-clickable
|
||||
rounded
|
||||
custom-class="searchField"
|
||||
dir="auto"
|
||||
:placeholder="defaultPlaceHolder"
|
||||
v-model="search"
|
||||
@keyup.native.enter="enter"
|
||||
/>
|
||||
</label>
|
||||
>
|
||||
</b-input>
|
||||
<template #label>
|
||||
<span class="sr-only">{{ defaultPlaceHolder }}</span>
|
||||
</template>
|
||||
</b-field>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from "vue-property-decorator";
|
||||
@ -47,6 +51,7 @@ label span.visually-hidden {
|
||||
input.searchField {
|
||||
box-shadow: none;
|
||||
border-color: #b5b5b5;
|
||||
border-radius: 9999px !important;
|
||||
|
||||
&::placeholder {
|
||||
color: gray;
|
||||
|
@ -6,6 +6,14 @@ module.exports = {
|
||||
// remove the prefetch plugin
|
||||
config.plugins.delete("prefetch");
|
||||
},
|
||||
configureWebpack: (config) => {
|
||||
const miniCssExtractPlugin = config.plugins.find(
|
||||
(plugin) => plugin.constructor.name === "MiniCssExtractPlugin"
|
||||
);
|
||||
if (miniCssExtractPlugin) {
|
||||
miniCssExtractPlugin.options.linkType = false;
|
||||
}
|
||||
},
|
||||
pwa: {
|
||||
themeColor: "#ffd599", //not required for service worker, but place theme color here if manifest.json doesn't change the color
|
||||
workboxPluginMode: "InjectManifest",
|
||||
|
@ -267,12 +267,22 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Events do
|
||||
Map.merge(args, %{
|
||||
description: description,
|
||||
mentions: mentions,
|
||||
tags: tags
|
||||
# Exclude tags with length > 40
|
||||
tags: Enum.filter(tags, &exclude_too_long_tags/1)
|
||||
})
|
||||
else
|
||||
args
|
||||
end
|
||||
|
||||
# Make sure we don't have duplicate (with different casing) tags
|
||||
args =
|
||||
Map.update(
|
||||
args,
|
||||
:tags,
|
||||
[],
|
||||
&Enum.uniq_by(&1, fn tag -> tag |> tag_to_string() |> String.downcase() end)
|
||||
)
|
||||
|
||||
# Check that we can only allow anonymous participation if our instance allows it
|
||||
{_, options} =
|
||||
Map.get_and_update(
|
||||
@ -292,4 +302,16 @@ defmodule Mobilizon.Federation.ActivityPub.Types.Events do
|
||||
|> Map.update(:tags, [], &ConverterUtils.fetch_tags/1)
|
||||
|> Map.update(:contacts, [], &ConverterUtils.fetch_actors/1)
|
||||
end
|
||||
|
||||
@spec exclude_too_long_tags(%{title: String.t()} | String.t()) :: boolean()
|
||||
defp exclude_too_long_tags(tag) do
|
||||
tag
|
||||
|> tag_to_string()
|
||||
|> String.length()
|
||||
|> Kernel.<(40)
|
||||
end
|
||||
|
||||
@spec tag_to_string(%{title: String.t()} | String.t()) :: String.t()
|
||||
defp tag_to_string(%{title: tag}), do: tag
|
||||
defp tag_to_string(tag), do: tag
|
||||
end
|
||||
|
@ -808,6 +808,53 @@ defmodule Mobilizon.Web.Resolvers.EventTest do
|
||||
end
|
||||
end
|
||||
|
||||
describe "create_event/3 with special tags" do
|
||||
test "same tags with different casing", %{conn: conn, actor: actor, user: user} do
|
||||
begins_on = DateTime.utc_now()
|
||||
|
||||
res =
|
||||
conn
|
||||
|> auth_conn(user)
|
||||
|> AbsintheHelpers.graphql_query(
|
||||
query: @create_event_mutation,
|
||||
variables: %{
|
||||
title: "come to my event",
|
||||
description: "it will be fine",
|
||||
begins_on: "#{DateTime.add(begins_on, 3600 * 24)}",
|
||||
organizer_actor_id: "#{actor.id}",
|
||||
tags: ["Hello", "hello"]
|
||||
}
|
||||
)
|
||||
|
||||
assert res["error"] == nil
|
||||
assert res["data"]["createEvent"]["tags"] == [%{"slug" => "hello", "title" => "Hello"}]
|
||||
end
|
||||
|
||||
test "too long tags", %{conn: conn, actor: actor, user: user} do
|
||||
begins_on = DateTime.utc_now()
|
||||
|
||||
res =
|
||||
conn
|
||||
|> auth_conn(user)
|
||||
|> AbsintheHelpers.graphql_query(
|
||||
query: @create_event_mutation,
|
||||
variables: %{
|
||||
title: "come to my event",
|
||||
description:
|
||||
"<p>it will be fine, what do you think? <br>#Detected <br>#ThisIsAVeryLongHashTagThatWillNotBeDetectedByTheParser</p>",
|
||||
begins_on: "#{DateTime.add(begins_on, 3600 * 24)}",
|
||||
organizer_actor_id: "#{actor.id}"
|
||||
}
|
||||
)
|
||||
|
||||
assert res["error"] == nil
|
||||
|
||||
assert res["data"]["createEvent"]["tags"] == [
|
||||
%{"slug" => "detected", "title" => "detected"}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@update_event_mutation """
|
||||
mutation updateEvent(
|
||||
$eventId: ID!
|
||||
|
Loading…
Reference in New Issue
Block a user