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