diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index a78012e44..9598104d5 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -101,7 +101,7 @@ class Api::V1::StatusesController < Api::BaseController end 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 def set_expire diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb index f8cc1612b..19dc846d2 100644 --- a/app/services/post_status_service.rb +++ b/app/services/post_status_service.rb @@ -75,7 +75,7 @@ class PostStatusService < BaseService @visibility = :unlisted if @visibility&.to_sym == :public && @account.silenced? @visibility = :limited if @circle.present? @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? if @quote_id.nil? && md = @text.match(/QT:\s*\[\s*(https:\/\/.+?)\s*\]/) @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 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 case @options[:expires_action]&.to_sym