User: Add function to get AP ids from nicknames.
This commit is contained in:
parent
9789e000b0
commit
2b664b048e
|
@ -1441,4 +1441,12 @@ def ensure_keys_present(user) do
|
|||
update_and_set_cache(cng)
|
||||
end
|
||||
end
|
||||
|
||||
def get_ap_ids_by_nicknames(nicknames) do
|
||||
from(u in User,
|
||||
where: u.nickname in ^nicknames,
|
||||
select: u.ap_id
|
||||
)
|
||||
|> Repo.all()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1266,4 +1266,16 @@ test "it doesn't create keys if there already are some" do
|
|||
assert user.info.keys == "xxx"
|
||||
end
|
||||
end
|
||||
|
||||
describe "get_ap_ids_by_nicknames" do
|
||||
test "it returns a list of AP ids for a given set of nicknames" do
|
||||
user = insert(:user)
|
||||
user_two = insert(:user)
|
||||
|
||||
ap_ids = User.get_ap_ids_by_nicknames([user.nickname, user_two.nickname, "nonexistent"])
|
||||
assert length(ap_ids) == 2
|
||||
assert user.ap_id in ap_ids
|
||||
assert user_two.ap_id in ap_ids
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue