Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[modify] sns poster : line and twitter (#3908)
* [modify] line poster (#41) * [fix] line poster locale * [modify] line poster : add node setting * [add] line text message placeholder * [modify] line_poster : line_text_message validation * [modify] sns post confirmation * [fix] line post : validate name when line post enabled * [modify] remove line_edit_auto_post * [remove] twitter edit_auto_post * [modify] line post validation * [modify] sns poster : twitter posted_at * [modify] snd poster to twitter poster * [modify] line post when merge branch * [modify] skip_sns_post * [fix] remove edit_auto_post * [fix] line post validation * [modify] logging when merge_to_master failed * [modify] sns post log * [modify] reset line posted * [fix] spec failure * [fix] locale * [fix] remove deleted_twitter_posted * [modify] sns post log views * [modify] line reset_posted permission * [fix] spec/factories/gws/user_presences.rb * [modify] spec * [fix] spec failure * [modify] spec
- Loading branch information
Showing
68 changed files
with
3,013 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class Cms::Apis::SnsPosterController < ApplicationController | ||
include Cms::BaseFilter | ||
include Cms::CrudFilter | ||
|
||
model ::Cms::Page | ||
|
||
public | ||
|
||
def line_reset | ||
set_item | ||
@item = @item.becomes_with_route | ||
@item.reset_line_posted if @item.respond_to?(:reset_line_posted) | ||
redirect_to @item.private_show_path, notice: t("ss.notice.reset_posted") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Cms::SnsPost::LogsController < ApplicationController | ||
include Cms::BaseFilter | ||
include Cms::CrudFilter | ||
|
||
model Cms::SnsPostLog::Base | ||
|
||
navi_view "cms/sns_post/main/navi" | ||
|
||
private | ||
|
||
def set_crumbs | ||
@crumbs << [t("cms.sns_post"), cms_sns_post_logs_path] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module Cms::SnsHelper | ||
def show_line_post_confirm? | ||
return false if !@item.class.include?(Cms::Addon::LinePoster) | ||
|
||
site = @item.site | ||
item = (@item.respond_to?(:master) && @item.master) ? @item.master : @item | ||
|
||
return false if !site.line_token_enabled? | ||
return false if @item.line_auto_post != "active" | ||
return false if item.line_posted.present? | ||
true | ||
end | ||
|
||
def show_twitter_post_confirm? | ||
return false if !@item.class.include?(Cms::Addon::TwitterPoster) | ||
|
||
item = (@item.respond_to?(:master) && @item.master) ? @item.master : @item | ||
|
||
return false if !@item.use_twitter_post? | ||
return false if item.twitter_posted.present? | ||
true | ||
end | ||
|
||
def render_sns_post_confirm | ||
messages = [] | ||
if show_line_post_confirm? | ||
messages << t("cms.confirm.line_post_enabled") | ||
end | ||
if show_twitter_post_confirm? | ||
messages << t("cms.confirm.twitter_post_enabled") | ||
end | ||
|
||
return "" if messages.blank? | ||
|
||
h = [] | ||
h << "<div class=\"sns-post-confirm\">" | ||
h << "<h2>#{t("cms.confirm.when_publish")}</h2>" | ||
h << "<ul>" | ||
messages.each do |message| | ||
h << ("<li>" + message + "</li>") | ||
end | ||
h << "</div>" | ||
|
||
return h.join("\n") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
class Cms::SnsPostLog::Base | ||
extend SS::Translation | ||
include SS::Document | ||
include SS::Reference::Site | ||
include Cms::SitePermission | ||
|
||
store_in collection: 'cms_sns_post_logs' | ||
|
||
set_permission_name "cms_tools", :use | ||
|
||
field :name, type: String | ||
field :action, type: String, default: "unknown" | ||
field :state, type: String, default: "error" | ||
field :error, type: String | ||
|
||
belongs_to :page, class_name: "Cms::Page" | ||
|
||
before_validation :set_name | ||
validates :page_id, presence: true | ||
|
||
default_scope -> { order_by(created: -1) } | ||
|
||
index({ created: -1 }) | ||
|
||
def type | ||
"base" | ||
end | ||
|
||
def state_options | ||
I18n.t("cms.options.sns_post_log_state").map { |k, v| [v, k] } | ||
end | ||
|
||
def type_options | ||
I18n.t("cms.options.sns_post_log_type").map { |k, v| [v, k] } | ||
end | ||
|
||
def set_name | ||
self.name = "[#{label(:state)}] #{label(:type)} #{created.strftime("%Y/%m/%d %H:%M")}" | ||
end | ||
|
||
class << self | ||
def create_with(page) | ||
log = self.new | ||
log.site = page.site | ||
log.page = page | ||
yield(log) | ||
log.save | ||
end | ||
|
||
def search(params) | ||
criteria = self.where({}) | ||
return criteria if params.blank? | ||
|
||
if params[:name].present? | ||
criteria = criteria.search_text params[:name] | ||
end | ||
if params[:keyword].present? | ||
criteria = criteria.keyword_in params[:keyword], :name, :body | ||
end | ||
criteria | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Cms::SnsPostLog::Line < Cms::SnsPostLog::Base | ||
extend SS::Translation | ||
include SS::Document | ||
include Cms::Reference::Site | ||
|
||
field :messages, type: Array, default: [] | ||
field :response_code, type: String | ||
field :response_body, type: String | ||
|
||
def type | ||
"line" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Cms::SnsPostLog::Twitter < Cms::SnsPostLog::Base | ||
extend SS::Translation | ||
include SS::Document | ||
include Cms::Reference::Site | ||
|
||
field :message, type: String | ||
field :media_files, type: Array, default: [] | ||
field :destroy_post_ids, type: Array, default: [] | ||
field :response_tweet, type: String | ||
|
||
def type | ||
"twitter" | ||
end | ||
end |
Oops, something went wrong.