about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/v1/lists_controller.rb2
-rw-r--r--app/javascript/flavours/glitch/actions/lists.js4
-rw-r--r--app/javascript/flavours/glitch/features/list_timeline/index.js20
-rw-r--r--app/javascript/mastodon/locales/en.json1
-rw-r--r--app/models/list.rb1
-rw-r--r--app/serializers/rest/list_serializer.rb2
-rw-r--r--app/services/fan_out_on_write_service.rb6
7 files changed, 32 insertions, 4 deletions
diff --git a/app/controllers/api/v1/lists_controller.rb b/app/controllers/api/v1/lists_controller.rb
index e5ac45fef..4ff3f8505 100644
--- a/app/controllers/api/v1/lists_controller.rb
+++ b/app/controllers/api/v1/lists_controller.rb
@@ -38,6 +38,6 @@ class Api::V1::ListsController < Api::BaseController
   end
 
   def list_params
-    params.permit(:title, :replies_policy)
+    params.permit(:title, :replies_policy, :show_self)
   end
 end
diff --git a/app/javascript/flavours/glitch/actions/lists.js b/app/javascript/flavours/glitch/actions/lists.js
index c2309b8c2..30ec6442d 100644
--- a/app/javascript/flavours/glitch/actions/lists.js
+++ b/app/javascript/flavours/glitch/actions/lists.js
@@ -150,10 +150,10 @@ export const createListFail = error => ({
   error,
 });
 
-export const updateList = (id, title, shouldReset, replies_policy) => (dispatch, getState) => {
+export const updateList = (id, title, shouldReset, replies_policy, show_self) => (dispatch, getState) => {
   dispatch(updateListRequest(id));
 
-  api(getState).put(`/api/v1/lists/${id}`, { title, replies_policy }).then(({ data }) => {
+  api(getState).put(`/api/v1/lists/${id}`, { title, replies_policy, show_self }).then(({ data }) => {
     dispatch(updateListSuccess(data));
 
     if (shouldReset) {
diff --git a/app/javascript/flavours/glitch/features/list_timeline/index.js b/app/javascript/flavours/glitch/features/list_timeline/index.js
index ef829b937..c634417ce 100644
--- a/app/javascript/flavours/glitch/features/list_timeline/index.js
+++ b/app/javascript/flavours/glitch/features/list_timeline/index.js
@@ -13,10 +13,12 @@ import { fetchList, deleteList, updateList } from 'flavours/glitch/actions/lists
 import { openModal } from 'flavours/glitch/actions/modal';
 import MissingIndicator from 'flavours/glitch/components/missing_indicator';
 import LoadingIndicator from 'flavours/glitch/components/loading_indicator';
+import Toggle from 'react-toggle';
 
 const messages = defineMessages({
   deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' },
   deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' },
+  show_self:     { id: 'lists.show_self', defaultMessage: 'Include your own toots' },
   all_replies:   { id: 'lists.replies_policy.all_replies', defaultMessage: 'any followed user' },
   no_replies:    { id: 'lists.replies_policy.no_replies', defaultMessage: 'no one' },
   list_replies:  { id: 'lists.replies_policy.list_replies', defaultMessage: 'members of the list' },
@@ -114,6 +116,14 @@ export default class ListTimeline extends React.PureComponent {
     }));
   }
 
+  handleShowSelfChange = ({ target }) => {
+    const { dispatch, list } = this.props;
+    const { id } = this.props.params;
+    const replies_policy = list ? list.get('replies_policy') : undefined;
+    const show_self = list ? list.get('show_self') : false;
+    this.props.dispatch(updateList(id, undefined, false, replies_policy, !show_self));
+  }
+
   handleRepliesPolicyChange = ({ target }) => {
     const { dispatch, list } = this.props;
     const { id } = this.props.params;
@@ -126,6 +136,7 @@ export default class ListTimeline extends React.PureComponent {
     const pinned = !!columnId;
     const title  = list ? list.get('title') : id;
     const replies_policy = list ? list.get('replies_policy') : undefined;
+    const show_self = list ? list.get('show_self') : false;
 
     if (typeof list === 'undefined') {
       return (
@@ -167,6 +178,15 @@ export default class ListTimeline extends React.PureComponent {
             </button>
           </div>
 
+          <div className='column-settings__row'>
+            <div className='setting-toggle'>
+              <Toggle id={['setting', 'toggle', id, 'show_self'].join('-')} checked={show_self === true} onChange={this.handleShowSelfChange} />
+              <label htmlFor={['setting', 'toggle', id, 'show_self'].join('-')} className='setting-toggle__label'>
+                <FormattedMessage id='lists.show_self' defaultMessage='Include your own toots' />
+              </label>
+            </div>
+          </div>
+
           { replies_policy !== undefined && (
             <div>
               <div className='column-settings__row'>
diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json
index 9417a745d..3c628c869 100644
--- a/app/javascript/mastodon/locales/en.json
+++ b/app/javascript/mastodon/locales/en.json
@@ -226,6 +226,7 @@
   "lists.new.title_placeholder": "New list title",
   "lists.search": "Search among monsters in your pack",
   "lists.subheading": "Your lists",
+  "lists.show_self": "Include your own roars",
   "loading_indicator.label": "Loading...",
   "media_gallery.toggle_visible": "Toggle visibility",
   "missing_indicator.label": "Not found",
diff --git a/app/models/list.rb b/app/models/list.rb
index 8493046e5..c3aab9606 100644
--- a/app/models/list.rb
+++ b/app/models/list.rb
@@ -9,6 +9,7 @@
 #  created_at     :datetime         not null
 #  updated_at     :datetime         not null
 #  replies_policy :integer          default("list_replies"), not null
+#  show_self      :boolean          default(FALSE), not null
 #
 
 class List < ApplicationRecord
diff --git a/app/serializers/rest/list_serializer.rb b/app/serializers/rest/list_serializer.rb
index 3e87f7119..86d885b55 100644
--- a/app/serializers/rest/list_serializer.rb
+++ b/app/serializers/rest/list_serializer.rb
@@ -1,7 +1,7 @@
 # frozen_string_literal: true
 
 class REST::ListSerializer < ActiveModel::Serializer
-  attributes :id, :title, :replies_policy
+  attributes :id, :title, :replies_policy, :show_self
 
   def id
     object.id.to_s
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index f2e0415cf..2efd51445 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -64,6 +64,12 @@ class FanOutOnWriteService < BaseService
   def deliver_to_lists(status)
     Rails.logger.debug "Delivering status #{status.id} to lists"
 
+    List.where(account_id: status.account.id, show_self: true).select(:id).reorder(nil).find_in_batches do |lists|
+      FeedInsertWorker.push_bulk(lists) do |list|
+        [status.id, list.id, :list]
+      end
+    end
+
     status.account.lists_for_local_distribution.select(:id).reorder(nil).find_in_batches do |lists|
       FeedInsertWorker.push_bulk(lists) do |list|
         [status.id, list.id, :list]