diff --git a/lib/tapatalker.rb b/lib/tapatalker.rb index 7cf21a4..960f198 100644 --- a/lib/tapatalker.rb +++ b/lib/tapatalker.rb @@ -546,17 +546,29 @@ 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 + def csrf_token! + # we need one of these to play with the session API, do POSTs, etc. if discourse.csrf_token.nil? discourse.csrf_token = discourse.session_csrf({}).fetch("csrf") end + end + + + # attachments and group id are TODO with uploads in general + def xmlrpc_new_topic( forum_id, subject, text_body, prefix_id = nil, attachment_id_array = nil, group_id = nil ) + csrf_token! + # To make it a topic instead of a post, specify a category instead of a topic_id + rsp = discourse.post_create( :category => forum_id, :title => subject, :raw => text_body ) + + respond_xmlrpc( 'result' => true, 'topic_id' => rsp["id"].to_s ) + end + + # attachments, return_html are api level 4 + def xmlrpc_reply_post( forum_id, topic_id, subject, text_body, attachment_id_array = nil, return_html = false ) + csrf_token! rsp = discourse.post_create( :topic_id => topic_id, :title => subject, :raw => text_body ) - pp rsp - result = { 'result' => true, 'post_id' => rsp["id"].to_s,