Add announcements (#12662)

* Add announcements

Fix #11006

* Add reactions to announcements

* Add admin UI for announcements

* Add unit tests

* Fix issues

- Add `with_dismissed` param to announcements API
- Fix end date not being formatted when time range is given
- Fix announcement delete causing reactions to send streaming updates
- Fix announcements container growing too wide and mascot too small
- Fix `all_day` being settable when no time range is given
- Change text "Update" to "Announcement"

* Fix scheduler unpublishing announcements before they are due

* Fix filter params not being passed to announcements filter
This commit is contained in:
Eugen Rochko
2020-01-23 22:00:13 +01:00
committed by GitHub
parent 81cc86bb1f
commit f52c988e12
65 changed files with 1779 additions and 22 deletions

View File

@ -98,7 +98,7 @@ SimpleForm.setup do |config|
b.use :html5
b.use :label
b.use :hint, wrap_with: { tag: :span, class: :hint }
b.use :input
b.use :input, wrap_with: { tag: :div, class: :label_input }
b.use :error, wrap_with: { tag: :span, class: :error }
end

View File

@ -198,11 +198,13 @@ en:
change_email_user: "%{name} changed the e-mail address of user %{target}"
confirm_user: "%{name} confirmed e-mail address of user %{target}"
create_account_warning: "%{name} sent a warning to %{target}"
create_announcement: "%{name} created new announcement %{target}"
create_custom_emoji: "%{name} uploaded new emoji %{target}"
create_domain_allow: "%{name} whitelisted domain %{target}"
create_domain_block: "%{name} blocked domain %{target}"
create_email_domain_block: "%{name} blacklisted e-mail domain %{target}"
demote_user: "%{name} demoted user %{target}"
destroy_announcement: "%{name} deleted announcement %{target}"
destroy_custom_emoji: "%{name} destroyed emoji %{target}"
destroy_domain_allow: "%{name} removed domain %{target} from whitelist"
destroy_domain_block: "%{name} unblocked domain %{target}"
@ -224,10 +226,22 @@ en:
unassigned_report: "%{name} unassigned report %{target}"
unsilence_account: "%{name} unsilenced %{target}'s account"
unsuspend_account: "%{name} unsuspended %{target}'s account"
update_announcement: "%{name} updated announcement %{target}"
update_custom_emoji: "%{name} updated emoji %{target}"
update_status: "%{name} updated status by %{target}"
deleted_status: "(deleted status)"
title: Audit log
announcements:
edit:
title: Edit announcement
empty: No announcements found.
live: Live
new:
create: Create announcement
title: New announcement
published: Published
time_range: Time range
title: Announcements
custom_emojis:
assign_category: Assign category
by_domain: Domain
@ -657,6 +671,9 @@ en:
hint_html: "<strong>Tip:</strong> We won't ask you for your password again for the next hour."
invalid_password: Invalid password
prompt: Confirm password to continue
date:
formats:
default: "%b %d, %Y"
datetime:
distance_in_words:
about_x_hours: "%{count}h"
@ -758,6 +775,8 @@ en:
all: All
changes_saved_msg: Changes successfully saved!
copy: Copy
delete: Delete
edit: Edit
no_batch_actions_available: No batch actions available on this page
order_by: Order by
save_changes: Save changes
@ -930,6 +949,9 @@ en:
other: Other
posting_defaults: Posting defaults
public_timelines: Public timelines
reactions:
errors:
unrecognized_emoji: is not a recognized emoji
relationships:
activity: Account activity
dormant: Dormant

View File

@ -14,6 +14,12 @@ en:
text_html: Optional. You can use toot syntax. You can <a href="%{path}">add warning presets</a> to save time
type_html: Choose what to do with <strong>%{acct}</strong>
warning_preset_id: Optional. You can still add custom text to end of the preset
announcement:
all_day: When checked, only the dates of the time range will be displayed
ends_at: Optional. Announcement will be automatically unpublished at this time
scheduled_at: Leave blank to publish the announcement immediately
starts_at: Optional. In case your announcement is bound to a specific time range
text: You can use toot syntax. Please be mindful of the space the announcement will take up on the user's screen
defaults:
autofollow: People who sign up through the invite will automatically follow you
avatar: PNG, GIF or JPG. At most %{size}. Will be downscaled to %{dimensions}px
@ -83,6 +89,12 @@ en:
silence: Silence
suspend: Suspend and irreversibly delete account data
warning_preset_id: Use a warning preset
announcement:
all_day: All-day event
ends_at: End of event
scheduled_at: Schedule publication
starts_at: Begin of event
text: Announcement
defaults:
autofollow: Invite to follow your account
avatar: Avatar

View File

@ -46,6 +46,7 @@ SimpleNavigation::Configuration.run do |navigation|
n.item :admin, safe_join([fa_icon('cogs fw'), t('admin.title')]), admin_dashboard_url, if: proc { current_user.staff? } do |s|
s.item :dashboard, safe_join([fa_icon('tachometer fw'), t('admin.dashboard.title')]), admin_dashboard_url
s.item :settings, safe_join([fa_icon('cogs fw'), t('admin.settings.title')]), edit_admin_settings_url, if: -> { current_user.admin? }, highlights_on: %r{/admin/settings}
s.item :announcements, safe_join([fa_icon('bullhorn fw'), t('admin.announcements.title')]), admin_announcements_path, highlights_on: %r{/admin/announcements}
s.item :custom_emojis, safe_join([fa_icon('smile-o fw'), t('admin.custom_emojis.title')]), admin_custom_emojis_url, highlights_on: %r{/admin/custom_emojis}
s.item :relays, safe_join([fa_icon('exchange fw'), t('admin.relays.title')]), admin_relays_url, if: -> { current_user.admin? && !whitelist_mode? }, highlights_on: %r{/admin/relays}
s.item :sidekiq, safe_join([fa_icon('diamond fw'), 'Sidekiq']), sidekiq_url, link_html: { target: 'sidekiq' }, if: -> { current_user.admin? }

View File

@ -173,9 +173,12 @@ Rails.application.routes.draw do
get :edit
end
end
resources :email_domain_blocks, only: [:index, :new, :create, :destroy]
resources :action_logs, only: [:index]
resources :warning_presets, except: [:new]
resources :announcements, except: [:show]
resource :settings, only: [:edit, :update]
resources :invites, only: [:index, :create, :destroy] do
@ -317,6 +320,16 @@ Rails.application.routes.draw do
resources :scheduled_statuses, only: [:index, :show, :update, :destroy]
resources :preferences, only: [:index]
resources :announcements, only: [:index] do
scope module: :announcements do
resources :reactions, only: [:update, :destroy]
end
member do
post :dismiss
end
end
resources :conversations, only: [:index, :destroy] do
member do
post :read