Add client-side /connect maxlength and add badge setting on model only (#660)
This commit is contained in:
parent
1dd95b636b
commit
05789f6ef6
6 changed files with 23 additions and 2 deletions
|
|
@ -92,6 +92,7 @@ class ChatChannelsController < ApplicationController
|
|||
@chat_channels_memberships = current_user.
|
||||
chat_channel_memberships.includes(:chat_channel).
|
||||
where("has_unopened_messages = ? OR status = ?", true, "pending").
|
||||
where(show_global_badge_notification: true).
|
||||
order("chat_channel_memberships.updated_at DESC")
|
||||
else
|
||||
@chat_channels_memberships = []
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ export default class Chat extends Component {
|
|||
id="messageform"
|
||||
placeholder="Message goes here"
|
||||
onKeyDown={handleKeyDown}
|
||||
maxLength="1000"
|
||||
/>
|
||||
<button
|
||||
className="messagecomposer__submit"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ class Message < ApplicationRecord
|
|||
belongs_to :chat_channel
|
||||
|
||||
validates :message_html, presence: true
|
||||
validates :message_markdown, presence: true, length: { maximum: 600 }
|
||||
validates :message_markdown, presence: true, length: { maximum: 1024 }
|
||||
validate :channel_permission
|
||||
|
||||
before_save :determine_user_validity
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
class AddBadgeNotificationSettingToChatChannelMemberships < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
add_column :chat_channel_memberships, :show_global_badge_notification, :boolean, default: true
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20180716182629) do
|
||||
ActiveRecord::Schema.define(version: 20180806142338) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
|
@ -168,6 +168,7 @@ ActiveRecord::Schema.define(version: 20180716182629) do
|
|||
t.boolean "has_unopened_messages", default: false
|
||||
t.datetime "last_opened_at", default: "2017-01-01 05:00:00"
|
||||
t.string "role", default: "member"
|
||||
t.boolean "show_global_badge_notification", default: true
|
||||
t.string "status", default: "active"
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "user_id", null: false
|
||||
|
|
@ -377,6 +378,10 @@ ActiveRecord::Schema.define(version: 20180716182629) do
|
|||
create_table "messages", force: :cascade do |t|
|
||||
t.bigint "chat_channel_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.text "encrypted_message_html"
|
||||
t.text "encrypted_message_html_iv"
|
||||
t.text "encrypted_message_markdown"
|
||||
t.text "encrypted_message_markdown_iv"
|
||||
t.string "message_html", null: false
|
||||
t.string "message_markdown", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
|
|
|
|||
|
|
@ -24,4 +24,13 @@ RSpec.describe Message, type: :model do
|
|||
message = build(:message, chat_channel_id: chat_channel.id, user_id: user_2.id)
|
||||
expect(message).to be_valid
|
||||
end
|
||||
|
||||
it "is invalid if over 1024 chars" do
|
||||
long_text = Faker::Hipster.words(1500)
|
||||
p long_text.size
|
||||
message = build(:message, chat_channel_id: chat_channel.id, user_id: user.id, message_markdown: long_text)
|
||||
expect(message).to_not be_valid
|
||||
message.message_markdown = "hello"
|
||||
expect(message).to be_valid
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue