mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:16:38 -06:00
FEATURE: iCalendar feed for Bookmark reminders
This commit is contained in:
parent
1c7680c568
commit
d6838608ff
@ -1397,15 +1397,23 @@ class UsersController < ApplicationController
|
||||
|
||||
def bookmarks
|
||||
user = fetch_user_from_params
|
||||
bookmarks = BookmarkQuery.new(user, params).list_all
|
||||
|
||||
if bookmarks.empty?
|
||||
render json: {
|
||||
bookmarks: [],
|
||||
no_results_help: I18n.t("user_activity.no_bookmarks.self")
|
||||
}
|
||||
else
|
||||
render_serialized(bookmarks, UserBookmarkSerializer, root: 'bookmarks')
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
bookmarks = BookmarkQuery.new(user, params).list_all
|
||||
|
||||
if bookmarks.empty?
|
||||
render json: {
|
||||
bookmarks: [],
|
||||
no_results_help: I18n.t("user_activity.no_bookmarks.self")
|
||||
}
|
||||
else
|
||||
render_serialized(bookmarks, UserBookmarkSerializer, root: 'bookmarks')
|
||||
end
|
||||
end
|
||||
format.ics do
|
||||
@bookmark_reminders = Bookmark.where(user_id: user.id).where.not(reminder_at: nil).joins(:topic)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
14
app/views/users/bookmarks.ics.erb
Normal file
14
app/views/users/bookmarks.ics.erb
Normal file
@ -0,0 +1,14 @@
|
||||
BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
PRODID:-//Discourse//<%= Discourse.current_hostname %>//<%= Discourse.full_version %>//EN
|
||||
<% @bookmark_reminders.each do |bookmark| %>
|
||||
BEGIN:VEVENT
|
||||
UID:bookmark_reminder_#<%= bookmark.id %>@<%= Discourse.current_hostname %>
|
||||
DTSTAMP:<%= bookmark.updated_at.strftime("%Y%m%dT%H%M%SZ") %>
|
||||
DTSTART:<%= bookmark.reminder_at.strftime("%Y%m%dT%H%M%SZ") %>
|
||||
DTEND:<%= (bookmark.reminder_at + 1.hour).strftime("%Y%m%dT%H%M%SZ") %>
|
||||
SUMMARY:<%= bookmark.name.presence || bookmark.topic.title %>
|
||||
URL:<%= Discourse.base_url %>/t/-/<%= bookmark.topic_id %>
|
||||
END:VEVENT
|
||||
<% end %>
|
||||
END:VCALENDAR
|
@ -469,7 +469,7 @@ Discourse::Application.routes.draw do
|
||||
get "#{root_path}/:username/activity" => "users#show", constraints: { username: RouteFormat.username }
|
||||
get "#{root_path}/:username/activity/:filter" => "users#show", constraints: { username: RouteFormat.username }
|
||||
get "#{root_path}/:username/badges" => "users#badges", constraints: { username: RouteFormat.username }
|
||||
get "#{root_path}/:username/bookmarks" => "users#bookmarks", constraints: { username: RouteFormat.username }
|
||||
get "#{root_path}/:username/bookmarks" => "users#bookmarks", constraints: { username: RouteFormat.username, format: /(json|ics)/ }
|
||||
get "#{root_path}/:username/notifications" => "users#show", constraints: { username: RouteFormat.username }
|
||||
get "#{root_path}/:username/notifications/:filter" => "users#show", constraints: { username: RouteFormat.username }
|
||||
delete "#{root_path}/:username" => "users#destroy", constraints: { username: RouteFormat.username }
|
||||
|
Loading…
Reference in New Issue
Block a user