Fix scheduled_at without timezone to be UTC

This commit is contained in:
noellabo 2021-08-24 02:42:21 +09:00
parent 9a660db1c5
commit 9292a6d2c8
2 changed files with 3 additions and 3 deletions

View file

@ -101,7 +101,7 @@ class Api::V1::StatusesController < Api::BaseController
end end
def set_schedule def set_schedule
@scheduled_at = status_params[:scheduled_at]&.to_time || (status_params[:scheduled_in].blank? ? nil : Time.now.utc + status_params[:scheduled_in].to_i.seconds) @scheduled_at = status_params[:scheduled_at]&.to_datetime&.to_time || (status_params[:scheduled_in].blank? ? nil : Time.now.utc + status_params[:scheduled_in].to_i.seconds)
end end
def set_expire def set_expire

View file

@ -75,7 +75,7 @@ class PostStatusService < BaseService
@visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced? @visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced?
@visibility = :limited if @circle.present? @visibility = :limited if @circle.present?
@visibility = :limited if @visibility&.to_sym != :direct && @in_reply_to&.limited_visibility? @visibility = :limited if @visibility&.to_sym != :direct && @in_reply_to&.limited_visibility?
@scheduled_at = @options[:scheduled_at].is_a?(Time) ? @options[:scheduled_at] : @options[:scheduled_at]&.to_time @scheduled_at = @options[:scheduled_at].is_a?(Time) ? @options[:scheduled_at] : @options[:scheduled_at]&.to_datetime&.to_time
@scheduled_at = nil if scheduled_in_the_past? @scheduled_at = nil if scheduled_in_the_past?
if @quote_id.nil? && md = @text.match(/QT:\s*\[\s*(https:\/\/.+?)\s*\]/) if @quote_id.nil? && md = @text.match(/QT:\s*\[\s*(https:\/\/.+?)\s*\]/)
@quote_id = quote_from_url(md[1])&.id @quote_id = quote_from_url(md[1])&.id
@ -152,7 +152,7 @@ class PostStatusService < BaseService
@expires_at = @options[:expires_at].is_a?(Time) ? @options[:expires_at] : @options[:expires_at]&.to_time @expires_at = @options[:expires_at].is_a?(Time) ? @options[:expires_at] : @options[:expires_at]&.to_time
raise Mastodon::ValidationError, I18n.t('status_expire.validations.invalid_expire_at') if @expires_at.nil? raise Mastodon::ValidationError, I18n.t('status_expire.validations.invalid_expire_at') if @expires_at.nil?
raise Mastodon::ValidationError, I18n.t('status_expire.validations.expire_in_the_past') if @expires_at <= (@options[:scheduled_at]&.to_time || Time.now.utc) + MIN_EXPIRE_OFFSET raise Mastodon::ValidationError, I18n.t('status_expire.validations.expire_in_the_past') if @expires_at <= (@options[:scheduled_at]&.to_datetime&.to_time || Time.now.utc) + MIN_EXPIRE_OFFSET
@expires_action = begin @expires_action = begin
case @options[:expires_action]&.to_sym case @options[:expires_action]&.to_sym