Move to a non-standard format for dateTime objects returned to Tapatalk clients
This fixes interactions with the iPhone client. Win.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
require 'sinatra'
|
||||
require 'xmlrpc/marshal'
|
||||
require 'xmlrpc/create'
|
||||
require 'discourse_api'
|
||||
require 'json'
|
||||
require 'pp'
|
||||
@@ -8,6 +9,40 @@ require 'base64'
|
||||
require 'net/https'
|
||||
|
||||
|
||||
# TODO: monkey-patch XMLRPC requests to support tapatalk's invalid bools.
|
||||
# The hack below works, ish.
|
||||
|
||||
# We need to monkey-patch our XMLRPC responses to have invalid(!) responses for
|
||||
# dateTime.iso8601 objects
|
||||
|
||||
module Tapatalk
|
||||
|
||||
class Time < ::Time
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module XMLRPC
|
||||
class Create
|
||||
|
||||
private
|
||||
|
||||
alias_method :real_conv2value, :conv2value
|
||||
|
||||
def conv2value( param )
|
||||
if param.is_a?(::Tapatalk::Time )
|
||||
value = @writer.tag( "dateTime.iso8601", param.iso8601 ) # includes the timezone
|
||||
@writer.ele("value", value)
|
||||
else
|
||||
real_conv2value( param )
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
PUSH_TYPES = "ann,conv,pm,sub,like,thank,quote,newtopic,tag"
|
||||
|
||||
CONFIG = YAML.load(
|
||||
@@ -95,8 +130,8 @@ helpers do
|
||||
end
|
||||
|
||||
def make_xmlrpc_datetime( string )
|
||||
obj = Chronic.parse( string )
|
||||
XMLRPC::DateTime.new( obj.year, obj.month, obj.day, obj.hour, obj.min, obj.sec )
|
||||
t = Chronic.parse( string )
|
||||
::Tapatalk::Time.new( t.year, t.month, t.day, t.hour, t.min, t.sec, t.utc_offset )
|
||||
end
|
||||
|
||||
def binary_xmlrpc( string )
|
||||
|
Reference in New Issue
Block a user