2020-07-09 08:01:29 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
require 'swagger_helper'
|
|
|
|
|
2020-10-26 22:55:22 +08:00
|
|
|
describe 'topics' do
|
2020-07-09 08:01:29 +08:00
|
|
|
|
|
|
|
let(:'Api-Key') { Fabricate(:api_key).key }
|
|
|
|
let(:'Api-Username') { 'system' }
|
|
|
|
|
|
|
|
path '/t/{id}/posts.json' do
|
|
|
|
get 'Get specific posts from a topic' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'getSpecificPostsFromTopic'
|
2020-07-09 08:01:29 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
parameter name: :post_body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
2020-07-09 08:27:19 +08:00
|
|
|
'post_ids[]': { type: :integer }
|
2020-07-09 08:01:29 +08:00
|
|
|
}, required: [ 'post_ids[]' ]
|
|
|
|
}
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'specific posts' do
|
|
|
|
schema type: :object, properties: {
|
|
|
|
post_stream: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
posts: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: { type: :integer },
|
2021-08-13 02:25:17 +08:00
|
|
|
name: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
username: { type: :string },
|
|
|
|
avatar_template: { type: :string },
|
|
|
|
created_at: { type: :string },
|
|
|
|
cooked: { type: :string },
|
|
|
|
post_number: { type: :integer },
|
|
|
|
post_type: { type: :integer },
|
|
|
|
updated_at: { type: :string },
|
|
|
|
reply_count: { type: :integer },
|
2021-08-13 02:25:17 +08:00
|
|
|
reply_to_post_number: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
quote_count: { type: :integer },
|
|
|
|
incoming_link_count: { type: :integer },
|
|
|
|
reads: { type: :integer },
|
|
|
|
readers_count: { type: :integer },
|
|
|
|
score: { type: :integer },
|
|
|
|
yours: { type: :boolean },
|
|
|
|
topic_id: { type: :integer },
|
|
|
|
topic_slug: { type: :string },
|
2021-08-13 02:25:17 +08:00
|
|
|
display_username: { type: [:string, :null] },
|
|
|
|
primary_group_name: { type: [:string, :null] },
|
|
|
|
flair_name: { type: [:string, :null] },
|
|
|
|
flair_url: { type: [:string, :null] },
|
|
|
|
flair_bg_color: { type: [:string, :null] },
|
|
|
|
flair_color: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
version: { type: :integer },
|
|
|
|
can_edit: { type: :boolean },
|
|
|
|
can_delete: { type: :boolean },
|
|
|
|
can_recover: { type: :boolean },
|
|
|
|
can_wiki: { type: :boolean },
|
|
|
|
read: { type: :boolean },
|
2021-08-13 02:25:17 +08:00
|
|
|
user_title: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
actions_summary: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: { type: :integer },
|
|
|
|
can_act: { type: :boolean },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
moderator: { type: :boolean },
|
|
|
|
admin: { type: :boolean },
|
|
|
|
staff: { type: :boolean },
|
|
|
|
user_id: { type: :integer },
|
|
|
|
hidden: { type: :boolean },
|
|
|
|
trust_level: { type: :integer },
|
2021-08-13 02:25:17 +08:00
|
|
|
deleted_at: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
user_deleted: { type: :boolean },
|
2021-08-13 02:25:17 +08:00
|
|
|
edit_reason: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
can_view_edit_history: { type: :boolean },
|
|
|
|
wiki: { type: :boolean },
|
|
|
|
reviewable_id: { type: :integer },
|
|
|
|
reviewable_score_count: { type: :integer },
|
|
|
|
reviewable_score_pending_count: { type: :integer },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
id: { type: :integer },
|
|
|
|
}
|
|
|
|
|
|
|
|
let(:post_body) { { 'post_ids[]': 1 } }
|
|
|
|
let(:id) { Fabricate(:topic).id }
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/t/{id}.json' do
|
|
|
|
get 'Get a single topic' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'getTopic'
|
2020-07-09 08:01:29 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
2022-02-11 10:01:19 +08:00
|
|
|
expected_request_schema = nil
|
2020-07-09 08:01:29 +08:00
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'specific posts' do
|
|
|
|
|
|
|
|
let(:id) { Fabricate(:topic).id }
|
|
|
|
|
2022-02-11 10:01:19 +08:00
|
|
|
expected_response_schema = load_spec_schema('topic_show_response')
|
|
|
|
schema expected_response_schema
|
|
|
|
|
|
|
|
it_behaves_like "a JSON endpoint", 200 do
|
|
|
|
let(:expected_response_schema) { expected_response_schema }
|
|
|
|
let(:expected_request_schema) { expected_request_schema }
|
|
|
|
end
|
2020-07-09 08:01:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
delete 'Remove a topic' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'removeTopic'
|
2020-07-09 08:01:29 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
response '200', 'specific posts' do
|
|
|
|
|
|
|
|
let!(:post) { Fabricate(:post) }
|
|
|
|
let(:id) { post.topic.id }
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/t/-/{id}.json' do
|
|
|
|
put 'Update a topic' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'updateTopic'
|
2020-07-09 08:01:29 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
parameter name: :post_body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
topic: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
title: { type: :string },
|
2020-07-09 08:27:19 +08:00
|
|
|
category_id: { type: :integer },
|
2020-07-09 08:01:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'topic updated' do
|
|
|
|
schema type: :object, properties: {
|
|
|
|
basic_topic: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: { type: :integer },
|
|
|
|
title: { type: :string },
|
|
|
|
fancy_title: { type: :string },
|
|
|
|
slug: { type: :string },
|
|
|
|
posts_count: { type: :integer },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
let(:post_body) { { title: 'New topic title' } }
|
|
|
|
let!(:post) { Fabricate(:post) }
|
|
|
|
let(:id) { post.topic.id }
|
|
|
|
|
|
|
|
run_test! do |response|
|
|
|
|
data = JSON.parse(response.body)
|
|
|
|
expect(data['basic_topic']['title']).to eq("New topic title")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/t/{id}/invite.json' do
|
|
|
|
post 'Invite to topic' do
|
|
|
|
tags 'Topics', 'Invites'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'inviteToTopic'
|
2020-07-09 08:01:29 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
parameter name: :request_body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
user: { type: :string },
|
|
|
|
email: { type: :string },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'topic updated' do
|
|
|
|
schema type: :object, properties: {
|
|
|
|
user: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: { type: :integer },
|
|
|
|
username: { type: :string },
|
|
|
|
name: { type: :string },
|
|
|
|
avatar_template: { type: :string },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
let(:username) { Fabricate(:user).username }
|
|
|
|
let(:request_body) { { user: username } }
|
|
|
|
let(:id) { Fabricate(:topic).id }
|
|
|
|
|
|
|
|
run_test! do |response|
|
|
|
|
data = JSON.parse(response.body)
|
|
|
|
expect(data['user']['username']).to eq(username)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/t/{id}/bookmark.json' do
|
|
|
|
put 'Bookmark topic' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'bookmarkTopic'
|
2020-07-09 08:01:29 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'topic updated' do
|
|
|
|
|
|
|
|
let!(:post) { Fabricate(:post) }
|
|
|
|
let(:id) { post.topic.id }
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/t/{id}/status.json' do
|
|
|
|
put 'Update the status of a topic' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'updateTopicStatus'
|
2020-07-09 08:01:29 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
parameter name: :request_body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
status: {
|
|
|
|
type: :string,
|
|
|
|
enum: ['closed', 'pinned', 'pinned_globally', 'archived', 'visible'],
|
|
|
|
},
|
|
|
|
enabled: {
|
|
|
|
type: :string,
|
|
|
|
enum: ['true', 'false']
|
|
|
|
},
|
|
|
|
until: {
|
|
|
|
type: :string,
|
|
|
|
description: 'Only required for `pinned` and `pinned_globally`',
|
|
|
|
example: '2030-12-31'
|
|
|
|
}
|
|
|
|
}, required: [ 'status', 'enabled' ]
|
|
|
|
}
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'topic updated' do
|
|
|
|
schema type: :object, properties: {
|
2020-10-26 22:55:22 +08:00
|
|
|
success: { type: :string, example: "OK" },
|
2021-08-13 02:25:17 +08:00
|
|
|
topic_status_update: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let(:request_body) { { status: 'closed', enabled: 'true' } }
|
|
|
|
let(:id) { Fabricate(:topic).id }
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/latest.json' do
|
|
|
|
get 'Get the latest topics' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'listLatestTopics'
|
2020-07-09 08:01:29 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
2020-07-09 08:27:19 +08:00
|
|
|
parameter(
|
|
|
|
name: :order,
|
2020-07-09 08:01:29 +08:00
|
|
|
in: :query,
|
|
|
|
type: :string,
|
2020-07-09 08:27:19 +08:00
|
|
|
description: 'Enum: `default`, `created`, `activity`, `views`, `posts`, `category`, `likes`, `op_likes`, `posters`')
|
|
|
|
parameter(
|
|
|
|
name: :ascending,
|
2020-07-09 08:01:29 +08:00
|
|
|
in: :query,
|
|
|
|
type: :string,
|
2020-07-09 08:27:19 +08:00
|
|
|
description: 'Defaults to `desc`, add `ascending=true` to sort asc')
|
2020-07-09 08:01:29 +08:00
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'topic updated' do
|
|
|
|
schema type: :object, properties: {
|
|
|
|
users: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: { type: :integer },
|
|
|
|
username: { type: :string },
|
2021-08-13 02:25:17 +08:00
|
|
|
name: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
avatar_template: { type: :string },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
primary_groups: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
topic_list: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
can_create_topic: { type: :boolean },
|
2021-08-13 02:25:17 +08:00
|
|
|
draft: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
draft_key: { type: :string },
|
|
|
|
draft_sequence: { type: :integer },
|
|
|
|
per_page: { type: :integer },
|
|
|
|
topics: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: { type: :integer },
|
|
|
|
title: { type: :string },
|
|
|
|
fancy_title: { type: :string },
|
|
|
|
slug: { type: :string },
|
|
|
|
posts_count: { type: :integer },
|
|
|
|
reply_count: { type: :integer },
|
|
|
|
highest_post_number: { type: :integer },
|
|
|
|
image_url: { type: :string },
|
|
|
|
created_at: { type: :string },
|
|
|
|
last_posted_at: { type: :string },
|
|
|
|
bumped: { type: :boolean },
|
|
|
|
bumped_at: { type: :string },
|
|
|
|
archetype: { type: :string },
|
|
|
|
unseen: { type: :boolean },
|
|
|
|
last_read_post_number: { type: :integer },
|
2021-07-05 14:17:31 +08:00
|
|
|
unread_posts: { type: :integer },
|
2020-07-09 08:01:29 +08:00
|
|
|
pinned: { type: :boolean },
|
2021-08-13 02:25:17 +08:00
|
|
|
unpinned: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
visible: { type: :boolean },
|
|
|
|
closed: { type: :boolean },
|
|
|
|
archived: { type: :boolean },
|
|
|
|
notification_level: { type: :integer },
|
|
|
|
bookmarked: { type: :boolean },
|
|
|
|
liked: { type: :boolean },
|
|
|
|
views: { type: :integer },
|
|
|
|
like_count: { type: :integer },
|
|
|
|
has_summary: { type: :boolean },
|
|
|
|
last_poster_username: { type: :string },
|
|
|
|
category_id: { type: :integer },
|
|
|
|
op_like_count: { type: :integer },
|
|
|
|
pinned_globally: { type: :boolean },
|
2021-08-13 02:25:17 +08:00
|
|
|
featured_link: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
posters: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
extras: { type: :string },
|
|
|
|
description: { type: :string },
|
|
|
|
user_id: { type: :integer },
|
2021-08-13 02:25:17 +08:00
|
|
|
primary_group_id: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
let(:order) { 'default' }
|
|
|
|
let(:ascending) { 'false' }
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-13 18:22:15 +08:00
|
|
|
path '/top.json' do
|
|
|
|
get 'Get the top topics filtered by period' do
|
2020-07-09 08:01:29 +08:00
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'listTopTopics'
|
2020-07-09 08:01:29 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
2020-07-09 08:27:19 +08:00
|
|
|
parameter(
|
2021-08-13 18:22:15 +08:00
|
|
|
name: :period,
|
|
|
|
in: :query,
|
2020-07-09 08:01:29 +08:00
|
|
|
type: :string,
|
2020-07-09 08:27:19 +08:00
|
|
|
description: 'Enum: `all`, `yearly`, `quarterly`, `monthly`, `weekly`, `daily`')
|
2020-07-09 08:01:29 +08:00
|
|
|
|
|
|
|
produces 'application/json'
|
2020-09-05 06:24:43 +08:00
|
|
|
response '200', 'response' do
|
2020-07-09 08:01:29 +08:00
|
|
|
schema type: :object, properties: {
|
|
|
|
users: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: { type: :integer },
|
|
|
|
username: { type: :string },
|
|
|
|
name: { type: :string },
|
|
|
|
avatar_template: { type: :string },
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
primary_groups: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
topic_list: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
can_create_topic: { type: :boolean },
|
2021-08-13 02:25:17 +08:00
|
|
|
draft: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
draft_key: { type: :string },
|
|
|
|
draft_sequence: { type: :integer },
|
|
|
|
for_period: { type: :string },
|
|
|
|
per_page: { type: :integer },
|
|
|
|
topics: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
id: { type: :integer },
|
|
|
|
title: { type: :string },
|
|
|
|
fancy_title: { type: :string },
|
|
|
|
slug: { type: :string },
|
|
|
|
posts_count: { type: :integer },
|
|
|
|
reply_count: { type: :integer },
|
|
|
|
highest_post_number: { type: :integer },
|
2021-08-13 02:25:17 +08:00
|
|
|
image_url: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
created_at: { type: :string },
|
|
|
|
last_posted_at: { type: :string },
|
|
|
|
bumped: { type: :boolean },
|
|
|
|
bumped_at: { type: :string },
|
|
|
|
archetype: { type: :string },
|
|
|
|
unseen: { type: :boolean },
|
|
|
|
last_read_post_number: { type: :integer },
|
2021-07-05 14:17:31 +08:00
|
|
|
unread_posts: { type: :integer },
|
2020-07-09 08:01:29 +08:00
|
|
|
pinned: { type: :boolean },
|
|
|
|
unpinned: { type: :boolean },
|
|
|
|
visible: { type: :boolean },
|
|
|
|
closed: { type: :boolean },
|
|
|
|
archived: { type: :boolean },
|
|
|
|
notification_level: { type: :integer },
|
|
|
|
bookmarked: { type: :boolean },
|
|
|
|
liked: { type: :boolean },
|
|
|
|
views: { type: :integer },
|
|
|
|
like_count: { type: :integer },
|
|
|
|
has_summary: { type: :boolean },
|
|
|
|
last_poster_username: { type: :string },
|
|
|
|
category_id: { type: :integer },
|
|
|
|
op_like_count: { type: :integer },
|
|
|
|
pinned_globally: { type: :boolean },
|
2021-08-13 02:25:17 +08:00
|
|
|
featured_link: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
posters: {
|
|
|
|
type: :array,
|
|
|
|
items: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
2021-08-13 02:25:17 +08:00
|
|
|
extras: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
description: { type: :string },
|
|
|
|
user_id: { type: :integer },
|
2021-08-13 02:25:17 +08:00
|
|
|
primary_group_id: { type: [:string, :null] },
|
2020-07-09 08:01:29 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-08-13 18:22:15 +08:00
|
|
|
let(:period) { 'all' }
|
2020-07-09 08:01:29 +08:00
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-10 07:39:05 +08:00
|
|
|
path '/t/{id}/notifications.json' do
|
|
|
|
post 'Set notification level' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'setNotificationLevel'
|
2020-07-10 07:39:05 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
parameter name: :request_body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
notification_level: {
|
|
|
|
type: :string,
|
|
|
|
enum: ['0', '1', '2', '3'],
|
|
|
|
}
|
|
|
|
}, required: [ 'notification_level' ]
|
|
|
|
}
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'topic updated' do
|
|
|
|
schema type: :object, properties: {
|
2020-10-26 22:55:22 +08:00
|
|
|
success: { type: :string, example: "OK" }
|
2020-07-10 07:39:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let(:request_body) { { notification_level: '3' } }
|
|
|
|
let(:id) { Fabricate(:topic).id }
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-11 02:06:25 +08:00
|
|
|
path '/t/{id}/change-timestamp.json' do
|
|
|
|
put 'Update topic timestamp' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'updateTopicTimestamp'
|
2020-07-11 02:06:25 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
parameter name: :request_body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
timestamp: {
|
|
|
|
type: :string,
|
|
|
|
example: '1594291380'
|
|
|
|
}
|
|
|
|
}, required: [ 'timestamp' ]
|
|
|
|
}
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'topic updated' do
|
|
|
|
schema type: :object, properties: {
|
2020-10-26 22:55:22 +08:00
|
|
|
success: { type: :string, example: "OK" }
|
2020-07-11 02:06:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
let(:request_body) { { timestamp: '1594291380' } }
|
|
|
|
let!(:post) { Fabricate(:post) }
|
|
|
|
let(:id) { post.topic.id }
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
path '/t/{id}/timer.json' do
|
|
|
|
post 'Create topic timer' do
|
|
|
|
tags 'Topics'
|
2021-09-03 21:39:29 +08:00
|
|
|
operationId 'createTopicTimer'
|
2020-07-11 02:06:25 +08:00
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: 'Api-Key', in: :header, type: :string, required: true
|
|
|
|
parameter name: 'Api-Username', in: :header, type: :string, required: true
|
|
|
|
parameter name: :id, in: :path, schema: { type: :string }
|
|
|
|
|
|
|
|
parameter name: :request_body, in: :body, schema: {
|
|
|
|
type: :object,
|
|
|
|
properties: {
|
|
|
|
time: {
|
|
|
|
type: :string,
|
|
|
|
example: ''
|
|
|
|
},
|
|
|
|
status_type: {
|
|
|
|
type: :string,
|
|
|
|
},
|
|
|
|
based_on_last_post: {
|
|
|
|
type: :boolean,
|
|
|
|
},
|
|
|
|
category_id: {
|
|
|
|
type: :integer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '200', 'topic updated' do
|
|
|
|
schema type: :object, properties: {
|
2020-10-26 22:55:22 +08:00
|
|
|
success: { type: :string, example: "OK" },
|
2020-07-11 02:06:25 +08:00
|
|
|
execute_at: { type: :string },
|
2021-08-13 02:25:17 +08:00
|
|
|
duration: { type: [:string, :null] },
|
2020-07-11 02:06:25 +08:00
|
|
|
based_on_last_post: { type: :boolean },
|
|
|
|
closed: { type: :boolean },
|
2021-08-13 02:25:17 +08:00
|
|
|
category_id: { type: [:string, :null] },
|
2020-07-11 02:06:25 +08:00
|
|
|
}
|
|
|
|
|
2020-12-09 01:13:45 +08:00
|
|
|
let(:request_body) { { time: Time.current + 1.day, status_type: 'close' } }
|
2020-07-11 02:06:25 +08:00
|
|
|
let!(:topic_post) { Fabricate(:post) }
|
|
|
|
let(:id) { topic_post.topic.id }
|
|
|
|
|
|
|
|
run_test!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-02-11 10:01:19 +08:00
|
|
|
path '/t/external_id/{external_id}.json' do
|
|
|
|
get 'Get topic by external_id' do
|
|
|
|
tags 'Topics'
|
|
|
|
operationId 'getTopicByExternalId'
|
|
|
|
consumes 'application/json'
|
|
|
|
parameter name: :external_id, in: :path, type: :string, required: true
|
|
|
|
expected_request_schema = nil
|
|
|
|
|
|
|
|
produces 'application/json'
|
|
|
|
response '301', 'redirects to /t/{topic_id}.json' do
|
|
|
|
expected_response_schema = nil
|
|
|
|
schema expected_response_schema
|
|
|
|
|
|
|
|
let(:topic) { Fabricate(:topic, external_id: 'external_id_1') }
|
|
|
|
let(:external_id) { topic.external_id }
|
|
|
|
|
|
|
|
run_test! do |response|
|
|
|
|
expect(response).to redirect_to(topic.relative_url + ".json?page=")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-09 08:01:29 +08:00
|
|
|
end
|