diff options
author | William Pitcock <nenolod@dereferenced.org> | 2018-11-06 23:07:13 +0000 |
---|---|---|
committer | William Pitcock <nenolod@dereferenced.org> | 2018-11-06 23:25:07 +0000 |
commit | b2105a31316d371733a75322bbf60868700f037d (patch) | |
tree | d0fd815defead9118c0c5e046f928a55ef28f2b7 | |
parent | 50bf17465138cbd81117404231b22b3891cb67c3 (diff) | |
download | pleroma-b2105a31316d371733a75322bbf60868700f037d.tar.gz |
twitterapi: add notification read endpoint
-rw-r--r-- | lib/pleroma/web/router.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/twitter_api/twitter_api_controller.ex | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index b461def82..06d0f0623 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -272,6 +272,10 @@ defmodule Pleroma.Web.Router do get("/statuses/mentions_timeline", TwitterAPI.Controller, :mentions_timeline) get("/qvitter/statuses/notifications", TwitterAPI.Controller, :notifications) + # XXX: this is really a pleroma API, but we want to keep the pleroma namespace clean + # for now. + post("/qvitter/statuses/notifications/read", TwitterAPI.Controller, :notifications_read) + post("/statuses/update", TwitterAPI.Controller, :status_update) post("/statuses/retweet/:id", TwitterAPI.Controller, :retweet) post("/statuses/unretweet/:id", TwitterAPI.Controller, :unretweet) diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/twitter_api_controller.ex index 83d725f13..727469a66 100644 --- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex +++ b/lib/pleroma/web/twitter_api/twitter_api_controller.ex @@ -133,6 +133,19 @@ defmodule Pleroma.Web.TwitterAPI.Controller do |> render(NotificationView, "notification.json", %{notifications: notifications, for: user}) end + def notifications_read(%{assigns: %{user: user}} = conn, %{"latest_id" => latest_id} = params) do + Notification.set_read_up_to(user, latest_id) + + notifications = Notification.for_user(user, params) + + conn + |> render(NotificationView, "notification.json", %{notifications: notifications, for: user}) + end + + def notifications_read(%{assigns: %{user: user}} = conn, _) do + bad_request_reply(conn, "You need to specify latest_id") + end + def follow(%{assigns: %{user: user}} = conn, params) do case TwitterAPI.follow(user, params) do {:ok, user, followed, _activity} -> |