parent
ae9e881333
commit
a992caf741
|
@ -910,7 +910,10 @@ a.mention-group {
|
|||
background-color: $tertiary-low;
|
||||
border-top: 1px solid $primary-low;
|
||||
display: flex;
|
||||
max-width: calc(#{$topic-body-width} + #{$topic-avatar-width} - 0.1em);
|
||||
max-width: calc(
|
||||
#{$topic-body-width} + (#{$topic-body-width-padding} * 2) + #{$topic-avatar-width} -
|
||||
(0.8em * 2)
|
||||
);
|
||||
padding: 0.8em;
|
||||
|
||||
&.old {
|
||||
|
|
|
@ -478,8 +478,8 @@ class PostsController < ApplicationController
|
|||
post = find_post_from_params
|
||||
|
||||
if params[:notice].present?
|
||||
post.custom_fields["notice_type"] = Post.notices[:custom]
|
||||
post.custom_fields["notice_args"] = PrettyText.cook(params[:notice], features: { onebox: false })
|
||||
post.custom_fields[Post::NOTICE_TYPE] = Post.notices[:custom]
|
||||
post.custom_fields[Post::NOTICE_ARGS] = PrettyText.cook(params[:notice], features: { onebox: false })
|
||||
post.save_custom_fields
|
||||
else
|
||||
post.delete_post_notices
|
||||
|
|
|
@ -54,11 +54,13 @@ class Post < ActiveRecord::Base
|
|||
# We can pass several creating options to a post via attributes
|
||||
attr_accessor :image_sizes, :quoted_post_numbers, :no_bump, :invalidate_oneboxes, :cooking_options, :skip_unique_check, :skip_validation
|
||||
|
||||
LARGE_IMAGES ||= "large_images".freeze
|
||||
BROKEN_IMAGES ||= "broken_images".freeze
|
||||
DOWNLOADED_IMAGES ||= "downloaded_images".freeze
|
||||
MISSING_UPLOADS ||= "missing uploads".freeze
|
||||
MISSING_UPLOADS_IGNORED ||= "missing uploads ignored".freeze
|
||||
LARGE_IMAGES ||= "large_images"
|
||||
BROKEN_IMAGES ||= "broken_images"
|
||||
DOWNLOADED_IMAGES ||= "downloaded_images"
|
||||
MISSING_UPLOADS ||= "missing uploads"
|
||||
MISSING_UPLOADS_IGNORED ||= "missing uploads ignored"
|
||||
NOTICE_TYPE ||= "notice_type"
|
||||
NOTICE_ARGS ||= "notice_args"
|
||||
|
||||
SHORT_POST_CHARS ||= 1200
|
||||
|
||||
|
@ -422,8 +424,8 @@ class Post < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def delete_post_notices
|
||||
self.custom_fields.delete("notice_type")
|
||||
self.custom_fields.delete("notice_args")
|
||||
self.custom_fields.delete(Post::NOTICE_TYPE)
|
||||
self.custom_fields.delete(Post::NOTICE_ARGS)
|
||||
self.save_custom_fields
|
||||
end
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ class PostSerializer < BasicPostSerializer
|
|||
end
|
||||
|
||||
def notice_type
|
||||
post_custom_fields["notice_type"]
|
||||
post_custom_fields[Post::NOTICE_TYPE]
|
||||
end
|
||||
|
||||
def include_notice_type?
|
||||
|
@ -389,7 +389,7 @@ class PostSerializer < BasicPostSerializer
|
|||
end
|
||||
|
||||
def notice_args
|
||||
post_custom_fields["notice_args"]
|
||||
post_custom_fields[Post::NOTICE_ARGS]
|
||||
end
|
||||
|
||||
def include_notice_args?
|
||||
|
|
|
@ -550,10 +550,10 @@ class PostCreator
|
|||
.first
|
||||
|
||||
if !last_post_time
|
||||
@post.custom_fields["notice_type"] = Post.notices[:new_user]
|
||||
@post.custom_fields[Post::NOTICE_TYPE] = Post.notices[:new_user]
|
||||
elsif SiteSetting.returning_users_days > 0 && last_post_time < SiteSetting.returning_users_days.days.ago
|
||||
@post.custom_fields["notice_type"] = Post.notices[:returning_user]
|
||||
@post.custom_fields["notice_args"] = last_post_time.iso8601
|
||||
@post.custom_fields[Post::NOTICE_TYPE] = Post.notices[:returning_user]
|
||||
@post.custom_fields[Post::NOTICE_ARGS] = last_post_time.iso8601
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class TopicView
|
|||
end
|
||||
|
||||
def self.default_post_custom_fields
|
||||
@default_post_custom_fields ||= ["action_code_who", "notice_type", "notice_args", "requested_group_id"]
|
||||
@default_post_custom_fields ||= [Post::NOTICE_TYPE, Post::NOTICE_ARGS, "action_code_who", "requested_group_id"]
|
||||
end
|
||||
|
||||
def self.post_custom_fields_whitelisters
|
||||
|
|
|
@ -1358,10 +1358,10 @@ describe PostCreator do
|
|||
|
||||
it "generates post notices for new users" do
|
||||
post = PostCreator.create!(user, title: "one of my first topics", raw: "one of my first posts")
|
||||
expect(post.custom_fields["notice_type"]).to eq("new_user")
|
||||
expect(post.custom_fields[Post::NOTICE_TYPE]).to eq(Post.notices[:new_user])
|
||||
|
||||
post = PostCreator.create!(user, title: "another one of my first topics", raw: "another one of my first posts")
|
||||
expect(post.custom_fields["notice_type"]).to eq(nil)
|
||||
expect(post.custom_fields[Post::NOTICE_TYPE]).to eq(nil)
|
||||
end
|
||||
|
||||
it "generates post notices for returning users" do
|
||||
|
@ -1369,12 +1369,12 @@ describe PostCreator do
|
|||
old_post = Fabricate(:post, user: user, created_at: 31.days.ago)
|
||||
|
||||
post = PostCreator.create!(user, title: "this is a returning topic", raw: "this is a post")
|
||||
expect(post.custom_fields["notice_type"]).to eq(Post.notices[:returning_user])
|
||||
expect(post.custom_fields["notice_args"]).to eq(old_post.created_at.iso8601)
|
||||
expect(post.custom_fields[Post::NOTICE_TYPE]).to eq(Post.notices[:returning_user])
|
||||
expect(post.custom_fields[Post::NOTICE_ARGS]).to eq(old_post.created_at.iso8601)
|
||||
|
||||
post = PostCreator.create!(user, title: "this is another topic", raw: "this is my another post")
|
||||
expect(post.custom_fields["notice_type"]).to eq(nil)
|
||||
expect(post.custom_fields["notice_args"]).to eq(nil)
|
||||
expect(post.custom_fields[Post::NOTICE_TYPE]).to eq(nil)
|
||||
expect(post.custom_fields[Post::NOTICE_ARGS]).to eq(nil)
|
||||
end
|
||||
|
||||
it "does not generate for non-human, staged or anonymous users" do
|
||||
|
@ -1383,8 +1383,8 @@ describe PostCreator do
|
|||
[anonymous, Discourse.system_user, staged].each do |user|
|
||||
expect(user.posts.size).to eq(0)
|
||||
post = PostCreator.create!(user, title: "#{user.username}'s first topic", raw: "#{user.name}'s first post")
|
||||
expect(post.custom_fields["notice_type"]).to eq(nil)
|
||||
expect(post.custom_fields["notice_args"]).to eq(nil)
|
||||
expect(post.custom_fields[Post::NOTICE_TYPE]).to eq(nil)
|
||||
expect(post.custom_fields[Post::NOTICE_ARGS]).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -138,8 +138,8 @@ describe Post do
|
|||
context 'a post with notices' do
|
||||
let(:post) {
|
||||
post = Fabricate(:post, post_args)
|
||||
post.custom_fields["notice_type"] = Post.notices[:returning_user]
|
||||
post.custom_fields["notice_args"] = 1.day.ago
|
||||
post.custom_fields[Post::NOTICE_TYPE] = Post.notices[:returning_user]
|
||||
post.custom_fields[Post::NOTICE_ARGS] = 1.day.ago
|
||||
post.save_custom_fields
|
||||
post
|
||||
}
|
||||
|
|
|
@ -1852,16 +1852,16 @@ describe PostsController do
|
|||
|
||||
expect(response.status).to eq(200)
|
||||
public_post.reload
|
||||
expect(public_post.custom_fields['notice_type']).to eq(Post.notices[:custom])
|
||||
expect(public_post.custom_fields['notice_args']).to include('<p>Hello <em>world</em>!</p>')
|
||||
expect(public_post.custom_fields['notice_args']).not_to include('onebox')
|
||||
expect(public_post.custom_fields[Post::NOTICE_TYPE]).to eq(Post.notices[:custom])
|
||||
expect(public_post.custom_fields[Post::NOTICE_ARGS]).to include('<p>Hello <em>world</em>!</p>')
|
||||
expect(public_post.custom_fields[Post::NOTICE_ARGS]).not_to include('onebox')
|
||||
|
||||
put "/posts/#{public_post.id}/notice.json", params: { notice: nil }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
public_post.reload
|
||||
expect(public_post.custom_fields['notice_type']).to eq(nil)
|
||||
expect(public_post.custom_fields['notice_args']).to eq(nil)
|
||||
expect(public_post.custom_fields[Post::NOTICE_TYPE]).to eq(nil)
|
||||
expect(public_post.custom_fields[Post::NOTICE_ARGS]).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -207,8 +207,8 @@ describe PostSerializer do
|
|||
|
||||
let(:post) {
|
||||
post = Fabricate(:post, user: user)
|
||||
post.custom_fields["notice_type"] = Post.notices[:returning_user]
|
||||
post.custom_fields["notice_args"] = 1.day.ago
|
||||
post.custom_fields[Post::NOTICE_TYPE] = Post.notices[:returning_user]
|
||||
post.custom_fields[Post::NOTICE_ARGS] = 1.day.ago
|
||||
post.save_custom_fields
|
||||
post
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue