Fix getting unread topics, and add support for posting replies

This commit is contained in:
Nick Thomas
2013-09-27 18:29:52 +01:00
parent 3c99bfbf6e
commit 6718017505

View File

@@ -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