From 6718017505dc6e5865daeaeb2ea6b0abd0ce377a Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Fri, 27 Sep 2013 18:29:52 +0100 Subject: [PATCH] Fix getting unread topics, and add support for posting replies --- lib/tapatalker.rb | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/tapatalker.rb b/lib/tapatalker.rb index ce2903a..1ec6e9c 100644 --- a/lib/tapatalker.rb +++ b/lib/tapatalker.rb @@ -352,8 +352,6 @@ helpers do tmp } - pp result - respond_xmlrpc( result ) end @@ -380,7 +378,7 @@ helpers do topics = topic_list.fetch( "topics" ) result['topics'] = topics.collect {|hsh| - build_tapatalk_topic( hsh, :users => latest_topics["users"], :categories => latest_topics["categories"] ) + build_tapatalk_topic( hsh, :users => unread_topics["users"], :categories => unread_topics["categories"] ) } result['total_topic_num'] = result['topics'].count # api level 4 @@ -512,6 +510,30 @@ helpers do respond_xmlrpc( result ) end + def xmlrpc_reply_post( forum_id, topic_id, subject, text_body, attachment_id_array = nil, return_html = false ) # attachments, return_html are api level 4 + + # we need one of these to play with the session API + if discourse.csrf_token.nil? + discourse.csrf_token = discourse.session_csrf({}).fetch("csrf") + end + + rsp = discourse.post_create( :topic_id => topic_id, :title => subject, :raw => text_body ) + + pp rsp + + result = { + 'result' => true, + 'post_id' => rsp["id"].to_s, + # 'state' => "1", # if post requires moderation + # post_content # api level 4 + # 'can_edit' => !!rsp['can_edit'] # api level 4 + # 'can_delete' => !!rsp['can_delete'] # api level 4 + # 'post_time' => make_xmlrpc_datetime( rsp['updated_at'] ) # api level 4 + # attachments # api level 4 + } + + respond_xmlrpc( result ) + end # def get_smilies # TODO - not a priority # end