Implement new_topic for the XMLRPC interface.
This commit is contained in:
@@ -546,17 +546,29 @@ helpers do
|
|||||||
respond_xmlrpc( result )
|
respond_xmlrpc( result )
|
||||||
end
|
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
|
def csrf_token!
|
||||||
|
# we need one of these to play with the session API, do POSTs, etc.
|
||||||
# we need one of these to play with the session API
|
|
||||||
if discourse.csrf_token.nil?
|
if discourse.csrf_token.nil?
|
||||||
discourse.csrf_token = discourse.session_csrf({}).fetch("csrf")
|
discourse.csrf_token = discourse.session_csrf({}).fetch("csrf")
|
||||||
end
|
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 )
|
rsp = discourse.post_create( :topic_id => topic_id, :title => subject, :raw => text_body )
|
||||||
|
|
||||||
pp rsp
|
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
'result' => true,
|
'result' => true,
|
||||||
'post_id' => rsp["id"].to_s,
|
'post_id' => rsp["id"].to_s,
|
||||||
|
Reference in New Issue
Block a user