Fixed some things
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
58c22d366f
commit
12964b7290
@ -22,6 +22,7 @@
|
||||
class="hidden-sm-and-down"
|
||||
:items="items"
|
||||
:search-input.sync="searchText"
|
||||
@keyup.enter="enter"
|
||||
v-model="model"
|
||||
return-object
|
||||
>
|
||||
@ -139,7 +140,7 @@ export default {
|
||||
return this.search.map(searchEntry => {
|
||||
switch (searchEntry.__typename) {
|
||||
case 'Actor':
|
||||
searchEntry.label = searchEntry.preferredUsername;
|
||||
searchEntry.label = searchEntry.preferredUsername + (searchEntry.domain === null ? '' : `@${searchEntry.domain}`);
|
||||
break;
|
||||
case 'Event':
|
||||
searchEntry.label = searchEntry.title;
|
||||
@ -148,17 +149,15 @@ export default {
|
||||
return searchEntry;
|
||||
});
|
||||
},
|
||||
displayed_name() {
|
||||
console.log('displayed name', this.actor);
|
||||
if (this.actor) {
|
||||
return this.actor.display_name === null ? this.actor.username : this.actor.display_name;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
username_with_domain(actor) {
|
||||
return actor.preferredUsername + (actor.domain === undefined ? '' : `@${actor.domain}`);
|
||||
return actor.preferredUsername + (actor.domain === null ? '' : `@${actor.domain}`);
|
||||
},
|
||||
enter() {
|
||||
console.log('enter');
|
||||
this.$apollo.queries.search.refetch();
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -88,9 +88,17 @@ export const CREATE_EVENT = gql`
|
||||
$categoryId: Int!,
|
||||
$beginsOn: DateTime!,
|
||||
$addressType: AddressType!,
|
||||
) {
|
||||
createEvent(title: $title, description: $description, beginsOn: $beginsOn, organizerActorId: $organizerActorId, categoryId: $categoryId, addressType: $addressType) {
|
||||
uuid
|
||||
) {
|
||||
createEvent(
|
||||
title: $title,
|
||||
description: $description,
|
||||
beginsOn: $beginsOn,
|
||||
organizerActorId: $organizerActorId,
|
||||
categoryId: $categoryId,
|
||||
addressType: $addressType) {
|
||||
uuid,
|
||||
title,
|
||||
description,
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
@ -9,6 +9,8 @@ query SearchEvents($searchText: String!) {
|
||||
__typename
|
||||
},
|
||||
...on Actor {
|
||||
avatarUrl,
|
||||
domain,
|
||||
preferredUsername,
|
||||
__typename
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ defmodule Mobilizon.Actors do
|
||||
actor =
|
||||
case String.split(name, "@") do
|
||||
[name] ->
|
||||
Repo.get_by(Actor, preferred_username: name)
|
||||
Repo.one(from(a in Actor, where: a.preferred_username == ^name and is_nil(a.domain)))
|
||||
|
||||
[name, domain] ->
|
||||
Repo.get_by(Actor, preferred_username: name, domain: domain)
|
||||
|
@ -2,14 +2,14 @@ defmodule MobilizonWeb.Resolvers.Actor do
|
||||
alias Mobilizon.Actors.Actor, as: ActorSchema
|
||||
alias Mobilizon.Actors.User
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
def find_actor(_parent, %{preferred_username: name}, _resolution) do
|
||||
case Actors.get_actor_by_name_with_everything(name) do
|
||||
nil ->
|
||||
{:error, "Actor with name #{name} not found"}
|
||||
|
||||
actor ->
|
||||
case ActivityPub.find_or_make_actor_from_nickname(name) do
|
||||
{:ok, actor} ->
|
||||
{:ok, actor}
|
||||
_ ->
|
||||
{:error, "Actor with name #{name} not found"}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
defmodule MobilizonWeb.Resolvers.Event do
|
||||
alias Mobilizon.Service.ActivityPub
|
||||
|
||||
def list_events(_parent, _args, _resolution) do
|
||||
{:ok, Mobilizon.Events.list_events()}
|
||||
end
|
||||
@ -28,9 +30,21 @@ defmodule MobilizonWeb.Resolvers.Event do
|
||||
Search events and actors by title
|
||||
"""
|
||||
def search_events_and_actors(_parent, %{search: search, page: page, limit: limit}, _resolution) do
|
||||
search = String.strip(search)
|
||||
found =
|
||||
Mobilizon.Events.find_events_by_name(search, page, limit) ++
|
||||
Mobilizon.Actors.find_actors_by_username_or_name(search, page, limit)
|
||||
case String.contains?(search, "@") do
|
||||
true ->
|
||||
with {:ok, actor} <- ActivityPub.find_or_make_actor_from_nickname(search) do
|
||||
actor
|
||||
else
|
||||
{:error, _err} ->
|
||||
nil
|
||||
end
|
||||
|
||||
_ ->
|
||||
Mobilizon.Events.find_events_by_name(search, page, limit) ++
|
||||
Mobilizon.Actors.find_actors_by_username_or_name(search, page, limit)
|
||||
end
|
||||
|
||||
require Logger
|
||||
Logger.debug(inspect(found))
|
||||
|
@ -49,7 +49,7 @@ defmodule Mobilizon.Service.WebFinger do
|
||||
|
||||
def represent_user(user, "JSON") do
|
||||
%{
|
||||
"subject" => "acct:#{user.preferred_username}@#{MobilizonWeb.Endpoint.host() <> ":4001"}",
|
||||
"subject" => "acct:#{user.preferred_username}@#{MobilizonWeb.Endpoint.host()}",
|
||||
"aliases" => [user.url],
|
||||
"links" => [
|
||||
%{"rel" => "self", "type" => "application/activity+json", "href" => user.url}
|
||||
|
Loading…
Reference in New Issue
Block a user