+
+ This is a chat conversation with yourself. Use this space to keep messages, links and texts. Please remember that these messages are not encrypted.
+
+
+ }
+
{
(hasMore && !isLoading) &&
@@ -349,7 +360,11 @@ class ChatMessageScrollingList extends ImmutablePureComponent {
const mapStateToProps = (state, { chatConversationId }) => {
if (!chatConversationId) return {}
+ const otherAccountIds = state.getIn(['chat_conversations', chatConversationId, 'other_account_ids'], null)
+ const amITalkingToMyself = !!otherAccountIds ? otherAccountIds.size == 1 && otherAccountIds.get(0) === me : false
+
return {
+ amITalkingToMyself,
chatMessageIds: state.getIn(['chat_conversation_messages', chatConversationId, 'items'], ImmutableList()),
isLoading: state.getIn(['chat_conversation_messages', chatConversationId, 'isLoading'], true),
isPartial: state.getIn(['chat_conversation_messages', chatConversationId, 'isPartial'], false),
diff --git a/app/javascript/gabsocial/features/messages_settings.js b/app/javascript/gabsocial/features/messages_settings.js
index 50820c5d..b186531d 100644
--- a/app/javascript/gabsocial/features/messages_settings.js
+++ b/app/javascript/gabsocial/features/messages_settings.js
@@ -1,36 +1,25 @@
import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
-import { injectIntl, FormattedMessage } from 'react-intl'
import ImmutablePureComponent from 'react-immutable-pure-component'
import ImmutablePropTypes from 'react-immutable-proptypes'
-import debounce from 'lodash.debounce'
import { me } from '../initial_state'
-import { fetchMutes, expandMutes } from '../actions/mutes'
-import Account from '../components/account'
+import { changeChatSetting } from '../actions/chat_settings'
import BlockHeading from '../components/block_heading'
-import Button from '../components/button'
import Form from '../components/form'
-import Switch from '../components/switch'
-import Text from '../components/text'
+import SettingSwitch from '../components/setting_switch'
import Divider from '../components/divider'
class MessagesSettings extends ImmutablePureComponent {
- componentWillMount() {
- this.props.onFetchMutes()
+ handleOnChange = (key, checked) => {
+ this.props.onSave(key, checked)
}
- handleLoadMore = debounce(() => {
- this.props.onExpandMutes()
- }, 300, { leading: true })
-
render() {
- const {
- accountIds,
- hasMore,
- isLoading,
- } = this.props
+ const { chatSettings } = this.props
+
+ if (!chatSettings) return null
return (
@@ -40,23 +29,34 @@ class MessagesSettings extends ImmutablePureComponent {
@@ -66,22 +66,18 @@ class MessagesSettings extends ImmutablePureComponent {
}
const mapStateToProps = (state) => ({
- accountIds: state.getIn(['user_lists', 'mutes', me, 'items']),
- hasMore: !!state.getIn(['user_lists', 'mutes', me, 'next']),
- isLoading: state.getIn(['user_lists', 'mutes', me, 'isLoading']),
+ chatSettings: state.getIn(['chat_settings']),
})
const mapDispatchToProps = (dispatch) => ({
- onFetchMutes: () => dispatch(fetchMutes()),
- onExpandMutes: () => dispatch(expandMutes()),
+ onSave(key, checked) {
+ // dispatch(changeChatSetting(key, checked))
+ },
})
MessagesSettings.propTypes = {
- accountIds: ImmutablePropTypes.list,
- hasMore: PropTypes.bool,
- isLoading: PropTypes.bool,
- onExpandMutes: PropTypes.func.isRequired,
- onFetchMutes: PropTypes.func.isRequired,
+ chatSettings: ImmutablePropTypes.map,
+ onSave: PropTypes.func.isRequired,
}
-export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(MessagesSettings))
\ No newline at end of file
+export default connect(mapStateToProps, mapDispatchToProps)(MessagesSettings)
\ No newline at end of file
diff --git a/app/javascript/gabsocial/layouts/messages_layout.js b/app/javascript/gabsocial/layouts/messages_layout.js
index d6ace302..87614998 100644
--- a/app/javascript/gabsocial/layouts/messages_layout.js
+++ b/app/javascript/gabsocial/layouts/messages_layout.js
@@ -76,7 +76,7 @@ class MessagesLayout extends React.PureComponent {
actions={[
{
icon: 'add',
- to: `'/messages/new'`,
+ to: '/messages/new',
},
{
icon: 'cog',
diff --git a/app/javascript/gabsocial/layouts/search_layout.js b/app/javascript/gabsocial/layouts/search_layout.js
index c226aafb..76641f54 100644
--- a/app/javascript/gabsocial/layouts/search_layout.js
+++ b/app/javascript/gabsocial/layouts/search_layout.js
@@ -79,10 +79,6 @@ class SearchLayout extends React.PureComponent {
title: intl.formatMessage(messages.links),
to: '/search/links',
},
- {
- title: intl.formatMessage(messages.hashtags),
- to: '/search/hashtags',
- },
]
}
diff --git a/app/javascript/gabsocial/reducers/chat_conversation_lists.js b/app/javascript/gabsocial/reducers/chat_conversation_lists.js
index 371bae18..f12b2788 100644
--- a/app/javascript/gabsocial/reducers/chat_conversation_lists.js
+++ b/app/javascript/gabsocial/reducers/chat_conversation_lists.js
@@ -15,6 +15,13 @@ import {
CHAT_CONVERSATIONS_REQUESTED_EXPAND_FAIL,
CHAT_CONVERSATION_REQUEST_APPROVE_SUCCESS,
+
+ CHAT_CONVERSATIONS_MUTED_FETCH_REQUEST,
+ CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS,
+ CHAT_CONVERSATIONS_MUTED_FETCH_FAIL,
+ CHAT_CONVERSATIONS_MUTED_EXPAND_REQUEST,
+ CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS,
+ CHAT_CONVERSATIONS_MUTED_EXPAND_FAIL,
} from '../actions/chat_conversations'
const initialState = ImmutableMap({
@@ -28,6 +35,11 @@ const initialState = ImmutableMap({
isLoading: false,
items: ImmutableList(),
}),
+ muted: ImmutableMap({
+ next: null,
+ isLoading: false,
+ items: ImmutableList(),
+ }),
})
const normalizeList = (state, source, chatConversations, next) => {
@@ -79,6 +91,18 @@ export default function chat_conversation_lists(state = initialState, action) {
case CHAT_CONVERSATION_REQUEST_APPROVE_SUCCESS:
return removeOneFromList(state, 'requested', action.chatConversation.chat_conversation_id)
+
+ case CHAT_CONVERSATIONS_MUTED_FETCH_REQUEST:
+ case CHAT_CONVERSATIONS_MUTED_EXPAND_REQUEST:
+ return state.setIn(['muted', 'isLoading'], true)
+ case CHAT_CONVERSATIONS_MUTED_FETCH_FAIL:
+ case CHAT_CONVERSATIONS_MUTED_EXPAND_FAIL:
+ return state.setIn(['muted', 'isLoading'], false)
+ case CHAT_CONVERSATIONS_MUTED_FETCH_SUCCESS:
+ return normalizeList(state, 'muted', action.chatConversations, action.next)
+ case CHAT_CONVERSATIONS_MUTED_EXPAND_SUCCESS:
+ return appendToList(state, 'muted', action.chatConversations, action.next)
+
default:
return state
}
diff --git a/app/javascript/gabsocial/reducers/chat_settings.js b/app/javascript/gabsocial/reducers/chat_settings.js
index 58d2b3aa..fa025ad2 100644
--- a/app/javascript/gabsocial/reducers/chat_settings.js
+++ b/app/javascript/gabsocial/reducers/chat_settings.js
@@ -17,9 +17,7 @@ const initialState = ImmutableMap({
export default function chat_settings(state = initialState, action) {
switch(action.type) {
case CHAT_SETTING_CHANGE:
- return state
- .setIn(action.path, action.value)
- .set('saved', false)
+ return state.set(action.path, action.checked).set('saved', false)
default:
return state
}
diff --git a/app/javascript/gabsocial/reducers/hashtags.js b/app/javascript/gabsocial/reducers/hashtags.js
new file mode 100644
index 00000000..651ab3d8
--- /dev/null
+++ b/app/javascript/gabsocial/reducers/hashtags.js
@@ -0,0 +1,20 @@
+import {
+ HASHTAG_FETCH_REQUEST,
+ HASHTAG_FETCH_SUCCESS,
+ HASHTAG_FETCH_FAIL,
+} from '../actions/hashtags'
+import { Map as ImmutableMap, fromJS } from 'immutable'
+
+const importHashtag = (state, hashtag) => state.set(`${hashtag.name}`.toLowerCase(), fromJS(hashtag))
+
+const initialState = ImmutableMap()
+
+export default function hashtags(state = initialState, action) {
+ switch (action.type) {
+ case HASHTAG_FETCH_SUCCESS:
+ console.log("HASHTAG_FETCH_SUCCESS:", action)
+ return importHashtag(state, action.hashtag)
+ default:
+ return state
+ }
+}
diff --git a/app/javascript/gabsocial/reducers/index.js b/app/javascript/gabsocial/reducers/index.js
index 3a2eb9dc..0e8e8f16 100644
--- a/app/javascript/gabsocial/reducers/index.js
+++ b/app/javascript/gabsocial/reducers/index.js
@@ -21,6 +21,7 @@ import group_categories from './group_categories'
import group_editor from './group_editor'
import group_lists from './group_lists'
import group_relationships from './group_relationships'
+import hashtags from './hashtags'
import height_cache from './height_cache'
import links from './links.js'
import lists from './lists'
@@ -75,6 +76,7 @@ const reducers = {
group_editor,
group_lists,
group_relationships,
+ hashtags,
height_cache,
links,
lists,
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index 72d1d2cf..02de4d28 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -17,9 +17,12 @@ class FeedManager
"feed:#{type}:#{id}:#{subtype}"
end
+ # status or chatMessage
def filter?(timeline_type, status, receiver_id)
if timeline_type == :home
filter_from_home?(status, receiver_id)
+ elsif timeline_type == :chat_message
+ filter_from_chat_messages?(status, receiver_id)
elsif timeline_type == :mentions
filter_from_mentions?(status, receiver_id)
else
@@ -140,6 +143,10 @@ class FeedManager
(context == :home ? Mute.where(account_id: receiver_id, target_account_id: account_ids).any? : Mute.where(account_id: receiver_id, target_account_id: account_ids, hide_notifications: true).any?)
end
+ def chat_blocks?(receiver_id, account_ids)
+ ChatBlock.where(account_id: receiver_id, target_account_id: account_ids).any?
+ end
+
def filter_from_home?(status, receiver_id)
return false if receiver_id == status.account_id
return true if status.reply? && (status.in_reply_to_id.nil? || status.in_reply_to_account_id.nil?)
@@ -170,6 +177,18 @@ class FeedManager
false
end
+ def filter_from_chat_messages?(chat_message, receiver_id)
+ return false if receiver_id == chat_message.from_account_id
+ return true if phrase_filtered_from_chat_message?(chat_message, receiver_id, :thread)
+
+ check_for_blocks = [chat_message.from_account_id]
+
+ return true if blocks_or_mutes?(receiver_id, check_for_blocks, :home)
+ return true if chat_blocks?(receiver_id, check_for_blocks)
+
+ false
+ end
+
def filter_from_mentions?(status, receiver_id)
return true if receiver_id == status.account_id
return true if phrase_filtered?(status, receiver_id, :notifications)
@@ -211,6 +230,29 @@ class FeedManager
(status.spoiler_text.present? && !combined_regex.match(status.spoiler_text).nil?)
end
+ def phrase_filtered_from_chat_message?(chat_message, receiver_id, context)
+ active_filters = Rails.cache.fetch("filters:#{receiver_id}") { CustomFilter.where(account_id: receiver_id).active_irreversible.to_a }.to_a
+
+ active_filters.select! { |filter| filter.context.include?(context.to_s) && !filter.expired? }
+
+ active_filters.map! do |filter|
+ if filter.whole_word
+ sb = filter.phrase =~ /\A[[:word:]]/ ? '\b' : ''
+ eb = filter.phrase =~ /[[:word:]]\z/ ? '\b' : ''
+
+ /(?mix:#{sb}#{Regexp.escape(filter.phrase)}#{eb})/
+ else
+ /#{Regexp.escape(filter.phrase)}/i
+ end
+ end
+
+ return false if active_filters.empty?
+
+ combined_regex = active_filters.reduce { |memo, obj| Regexp.union(memo, obj) }
+
+ !combined_regex.match(chat_message.text).nil?
+ end
+
# Adds a status to an account's feed, returning true if a status was
# added, and false if it was not added to the feed. Note that this is
# an internal helper: callers must call trim or push updates if
diff --git a/app/lib/sorting_query_builder.rb b/app/lib/sorting_query_builder.rb
index ad0791e1..67d0ea3d 100644
--- a/app/lib/sorting_query_builder.rb
+++ b/app/lib/sorting_query_builder.rb
@@ -39,6 +39,7 @@ class SortingQueryBuilder < BaseService
query = query.where('statuses.id > ? AND statuses.id <> ?', max_id, max_id) unless max_id.nil? || max_id.empty?
query = query.limit(20)
+ # : todo : reject blocks, etc. in feedmanager
# SELECT "statuses".*
# FROM "statuses"
# INNER JOIN "status_stats" ON "status_stats"."status_id" = "statuses"."id"
diff --git a/app/models/chat_conversation_account.rb b/app/models/chat_conversation_account.rb
index 34191256..f4a84020 100644
--- a/app/models/chat_conversation_account.rb
+++ b/app/models/chat_conversation_account.rb
@@ -37,8 +37,6 @@ class ChatConversationAccount < ApplicationRecord
belongs_to :chat_conversation
belongs_to :last_chat_message, class_name: 'ChatMessage', optional: true
- validate :validate_total_limit
-
def participant_accounts
if participant_account_ids.empty?
[account]
@@ -50,8 +48,4 @@ class ChatConversationAccount < ApplicationRecord
private
- def validate_total_limit
- # errors.add(:base, I18n.t('scheduled_statuses.over_total_limit', limit: PER_ACCOUNT_APPROVED_LIMIT)) if account.scheduled_statuses.count >= PER_ACCOUNT_APPROVED_LIMIT
- end
-
end
diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb
index 48260181..19c265dd 100644
--- a/app/models/media_attachment.rb
+++ b/app/models/media_attachment.rb
@@ -84,8 +84,8 @@ class MediaAttachment < ApplicationRecord
},
}.freeze
- IMAGE_LIMIT = Proc.new { |account| account.is_pro ? 50.megabytes : 8.megabytes }
- VIDEO_LIMIT = Proc.new { |account| account.is_pro ? 1.gigabytes : 40.megabytes}
+ IMAGE_LIMIT = Proc.new { |account| account.is_pro ? 100.megabytes : 20.megabytes }
+ VIDEO_LIMIT = Proc.new { |account| account.is_pro ? 2.gigabytes : 250.megabytes}
belongs_to :account, inverse_of: :media_attachments, optional: true
belongs_to :status, inverse_of: :media_attachments, optional: true
diff --git a/app/services/create_chat_conversation_service.rb b/app/services/create_chat_conversation_service.rb
index 0f65da10..00fef0ca 100644
--- a/app/services/create_chat_conversation_service.rb
+++ b/app/services/create_chat_conversation_service.rb
@@ -15,26 +15,36 @@ class CreateChatConversationService < BaseService
# : todo :
# check if allow anyone to message then create with approved:true
- # unique account id, participants
- chat_conversation = ChatConversation.create
+ @chat_conversation = ChatConversation.create
my_chat = ChatConversationAccount.create!(
- account: current_account,
- participant_account_ids: [@account.id.to_s],
- chat_conversation: chat_conversation,
+ account: @current_account,
+ participant_account_ids: account_ids_as_array,
+ chat_conversation: @chat_conversation,
is_approved: true
)
- # : todo : if multiple ids
- if @account.id != current_account.id
- their_chat = ChatConversationAccount.create!(
- account: @account,
- participant_account_ids: [current_account.id.to_s],
- chat_conversation: chat_conversation,
- is_approved: false # : todo : check if allow all else default as request
- )
+ if @other_accounts.length == 1 && @other_accounts[0].id == @current_account.id
+ # dont create two conversations if you are chatting with yourself
+ else
+ for other_account in @other_accounts
+ this_conversation_participants = @other_accounts.map { |account|
+ account.id.to_s
+ }.reject { |id| id == other_account.id.to_s } << @current_account.id.to_s
+
+ # is_approved = other_account&.user&.setting_chat_messages_restrict_non_followers == true
+
+ ChatConversationAccount.create!(
+ account: other_account,
+ participant_account_ids: this_conversation_participants,
+ chat_conversation: @chat_conversation,
+ is_approved: false
+ )
+ end
end
+
+ my_chat
end
def account_ids_as_array
diff --git a/app/services/post_chat_message_service.rb b/app/services/post_chat_message_service.rb
index 6f9b2481..98033773 100644
--- a/app/services/post_chat_message_service.rb
+++ b/app/services/post_chat_message_service.rb
@@ -54,13 +54,16 @@ class PostChatMessageService < BaseService
# Get not mine
if @account_conversation.id != recipient.id
- recipient.unread_count = recipient.unread_count + 1
- recipient.is_hidden = false
+ # check if recipient is blocking me
+ unless recipient.account.chat_blocking?(@account)
+ recipient.unread_count = recipient.unread_count + 1
+ recipient.is_hidden = false
- # check if muting
- unless recipient.is_muted
- payload = InlineRenderer.render(@chat, recipient.account, :chat_message)
- Redis.current.publish("chat_messages:#{recipient.account.id}", Oj.dump(event: :notification, payload: payload))
+ # check if muting
+ unless recipient.is_muted
+ payload = InlineRenderer.render(@chat, recipient.account, :chat_message)
+ Redis.current.publish("chat_messages:#{recipient.account.id}", Oj.dump(event: :notification, payload: payload))
+ end
end
else
recipient.unread_count = 0
@@ -72,21 +75,7 @@ class PostChatMessageService < BaseService
def set_chat_conversation_recipients!
@account_conversation = ChatConversationAccount.where(account: @account, chat_conversation: @chat_conversation).first
- @chat_conversation_recipients_accounts = ChatConversationAccount.where(chat_conversation: @chat_conversation)
-
- # if 1-to-1 chat, check for blocking and dont allow message to send if blocking
- # if 1-to-many let chat go through but keep is_hidden
- @chat_conversation_recipients_accounts.each do |recipient|
- # : todo :
- # check if chat blocked
- # check if normal blocked
-
- if recipient.account.blocking?(@account) || recipient.account.chat_blocking?(@account)
- raise GabSocial::NotPermittedError
- end
- end
-
-
+ @chat_conversation_recipients_accounts = ChatConversationAccount.where(chat_conversation: @chat_conversation)
rescue ArgumentError
raise ActiveRecord::RecordInvalid
end
diff --git a/config/routes.rb b/config/routes.rb
index 044177db..0d7e5114 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -227,7 +227,7 @@ Rails.application.routes.draw do
end
namespace :chat_conversation_accounts do
- resource :blocked_chat_accounts, only: :show, controller: 'chat_conversation_accounts/blocked_chat_accounts'
+ #
end
resources :chat_conversation_accounts, only: :show do
@@ -256,6 +256,8 @@ Rails.application.routes.draw do
get :count
end
end
+ resources :blocked_chat_accounts, only: :index
+ resources :muted_conversations, only: :index
end
resources :chat_conversation, only: [:show, :create] do
@@ -268,6 +270,7 @@ Rails.application.routes.draw do
end
resources :links, only: :show
+ resources :hashtags, only: :show
resource :popular_links, only: :show
resources :streaming, only: [:index]
resources :custom_emojis, only: [:index]
diff --git a/package.json b/package.json
index e1af2715..b27af978 100644
--- a/package.json
+++ b/package.json
@@ -114,6 +114,7 @@
"react-router-dom": "^4.1.1",
"react-router-scroll-4": "^1.0.0-beta.2",
"react-sortable-hoc": "^1.11.0",
+ "react-sparklines": "^1.7.0",
"react-stickynode": "^3.0.4",
"react-swipeable-views": "^0.13.9",
"react-textarea-autosize": "^7.1.0",
diff --git a/yarn.lock b/yarn.lock
index 77d00a6d..957e27f3 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6618,6 +6618,13 @@ react-sortable-hoc@^1.11.0:
invariant "^2.2.4"
prop-types "^15.5.7"
+react-sparklines@^1.7.0:
+ version "1.7.0"
+ resolved "https://registry.yarnpkg.com/react-sparklines/-/react-sparklines-1.7.0.tgz#9b1d97e8c8610095eeb2ad658d2e1fcf91f91a60"
+ integrity sha512-bJFt9K4c5Z0k44G8KtxIhbG+iyxrKjBZhdW6afP+R7EnIq+iKjbWbEFISrf3WKNFsda+C46XAfnX0StS5fbDcg==
+ dependencies:
+ prop-types "^15.5.10"
+
react-stickynode@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/react-stickynode/-/react-stickynode-3.0.4.tgz#1e9c096cec3613cc8294807eba319ced074c8b21"