# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.OAuth.Token.Query do
from(q in query, where: q.user_id == ^user_id)
end
+ def get_unexpired(query) do
+ now = NaiveDateTime.utc_now()
+ from(q in query, where: q.valid_until > ^now)
+ end
+
+ def limit(query, limit) do
+ from(q in query, limit: ^limit)
+ end
+
+ def sort_by_inserted_at(query) do
+ from(q in query, order_by: [desc: :updated_at])
+ end
+
@spec preload(query, any) :: query
def preload(query \\ Token, assoc_preload \\ [])