Compare commits
2 commits
main
...
community_
Author | SHA1 | Date | |
---|---|---|---|
8edfc5fcf9 | |||
8dd3c9e429 |
5 changed files with 110 additions and 56 deletions
150
docs/src/contributing_websocket_http_api.md
vendored
150
docs/src/contributing_websocket_http_api.md
vendored
|
@ -28,214 +28,222 @@
|
|||
- [Request](#request-1)
|
||||
- [Response](#response-1)
|
||||
- [HTTP](#http-2)
|
||||
+ [Get User Details](#get-user-details)
|
||||
+ [Get Captcha](#get-captcha)
|
||||
- [Request](#request-2)
|
||||
- [Response](#response-2)
|
||||
- [HTTP](#http-3)
|
||||
+ [Save User Settings](#save-user-settings)
|
||||
+ [Get User Details](#get-user-details)
|
||||
- [Request](#request-3)
|
||||
- [Response](#response-3)
|
||||
- [HTTP](#http-4)
|
||||
+ [Get Replies / Inbox](#get-replies--inbox)
|
||||
+ [Save User Settings](#save-user-settings)
|
||||
- [Request](#request-4)
|
||||
- [Response](#response-4)
|
||||
- [HTTP](#http-5)
|
||||
+ [Get User Mentions](#get-user-mentions)
|
||||
+ [Get Replies / Inbox](#get-replies--inbox)
|
||||
- [Request](#request-5)
|
||||
- [Response](#response-5)
|
||||
- [HTTP](#http-6)
|
||||
+ [Mark User Mention as read](#mark-user-mention-as-read)
|
||||
+ [Get User Mentions](#get-user-mentions)
|
||||
- [Request](#request-6)
|
||||
- [Response](#response-6)
|
||||
- [HTTP](#http-7)
|
||||
+ [Get Private Messages](#get-private-messages)
|
||||
+ [Mark User Mention as read](#mark-user-mention-as-read)
|
||||
- [Request](#request-7)
|
||||
- [Response](#response-7)
|
||||
- [HTTP](#http-8)
|
||||
+ [Create Private Message](#create-private-message)
|
||||
+ [Get Private Messages](#get-private-messages)
|
||||
- [Request](#request-8)
|
||||
- [Response](#response-8)
|
||||
- [HTTP](#http-9)
|
||||
+ [Edit Private Message](#edit-private-message)
|
||||
+ [Create Private Message](#create-private-message)
|
||||
- [Request](#request-9)
|
||||
- [Response](#response-9)
|
||||
- [HTTP](#http-10)
|
||||
+ [Delete Private Message](#delete-private-message)
|
||||
+ [Edit Private Message](#edit-private-message)
|
||||
- [Request](#request-10)
|
||||
- [Response](#response-10)
|
||||
- [HTTP](#http-11)
|
||||
+ [Mark Private Message as Read](#mark-private-message-as-read)
|
||||
+ [Delete Private Message](#delete-private-message)
|
||||
- [Request](#request-11)
|
||||
- [Response](#response-11)
|
||||
- [HTTP](#http-12)
|
||||
+ [Mark All As Read](#mark-all-as-read)
|
||||
+ [Mark Private Message as Read](#mark-private-message-as-read)
|
||||
- [Request](#request-12)
|
||||
- [Response](#response-12)
|
||||
- [HTTP](#http-13)
|
||||
+ [Delete Account](#delete-account)
|
||||
+ [Mark All As Read](#mark-all-as-read)
|
||||
- [Request](#request-13)
|
||||
- [Response](#response-13)
|
||||
- [HTTP](#http-14)
|
||||
+ [Add admin](#add-admin)
|
||||
+ [Delete Account](#delete-account)
|
||||
- [Request](#request-14)
|
||||
- [Response](#response-14)
|
||||
- [HTTP](#http-15)
|
||||
+ [Ban user](#ban-user)
|
||||
+ [Add admin](#add-admin)
|
||||
- [Request](#request-15)
|
||||
- [Response](#response-15)
|
||||
- [HTTP](#http-16)
|
||||
* [Site](#site)
|
||||
+ [List Categories](#list-categories)
|
||||
+ [Ban user](#ban-user)
|
||||
- [Request](#request-16)
|
||||
- [Response](#response-16)
|
||||
- [HTTP](#http-17)
|
||||
+ [Search](#search)
|
||||
* [Site](#site)
|
||||
+ [List Categories](#list-categories)
|
||||
- [Request](#request-17)
|
||||
- [Response](#response-17)
|
||||
- [HTTP](#http-18)
|
||||
+ [Get Modlog](#get-modlog)
|
||||
+ [Search](#search)
|
||||
- [Request](#request-18)
|
||||
- [Response](#response-18)
|
||||
- [HTTP](#http-19)
|
||||
+ [Create Site](#create-site)
|
||||
+ [Get Modlog](#get-modlog)
|
||||
- [Request](#request-19)
|
||||
- [Response](#response-19)
|
||||
- [HTTP](#http-20)
|
||||
+ [Edit Site](#edit-site)
|
||||
+ [Create Site](#create-site)
|
||||
- [Request](#request-20)
|
||||
- [Response](#response-20)
|
||||
- [HTTP](#http-21)
|
||||
+ [Get Site](#get-site)
|
||||
+ [Edit Site](#edit-site)
|
||||
- [Request](#request-21)
|
||||
- [Response](#response-21)
|
||||
- [HTTP](#http-22)
|
||||
+ [Transfer Site](#transfer-site)
|
||||
+ [Get Site](#get-site)
|
||||
- [Request](#request-22)
|
||||
- [Response](#response-22)
|
||||
- [HTTP](#http-23)
|
||||
+ [Get Site Config](#get-site-config)
|
||||
+ [Transfer Site](#transfer-site)
|
||||
- [Request](#request-23)
|
||||
- [Response](#response-23)
|
||||
- [HTTP](#http-24)
|
||||
+ [Save Site Config](#save-site-config)
|
||||
+ [Get Site Config](#get-site-config)
|
||||
- [Request](#request-24)
|
||||
- [Response](#response-24)
|
||||
- [HTTP](#http-25)
|
||||
* [Community](#community)
|
||||
+ [Get Community](#get-community)
|
||||
+ [Save Site Config](#save-site-config)
|
||||
- [Request](#request-25)
|
||||
- [Response](#response-25)
|
||||
- [HTTP](#http-26)
|
||||
+ [Create Community](#create-community)
|
||||
* [Community](#community)
|
||||
+ [Get Community](#get-community)
|
||||
- [Request](#request-26)
|
||||
- [Response](#response-26)
|
||||
- [HTTP](#http-27)
|
||||
+ [List Communities](#list-communities)
|
||||
+ [Create Community](#create-community)
|
||||
- [Request](#request-27)
|
||||
- [Response](#response-27)
|
||||
- [HTTP](#http-28)
|
||||
+ [Ban from Community](#ban-from-community)
|
||||
+ [List Communities](#list-communities)
|
||||
- [Request](#request-28)
|
||||
- [Response](#response-28)
|
||||
- [HTTP](#http-29)
|
||||
+ [Add Mod to Community](#add-mod-to-community)
|
||||
+ [Ban from Community](#ban-from-community)
|
||||
- [Request](#request-29)
|
||||
- [Response](#response-29)
|
||||
- [HTTP](#http-30)
|
||||
+ [Edit Community](#edit-community)
|
||||
+ [Add Mod to Community](#add-mod-to-community)
|
||||
- [Request](#request-30)
|
||||
- [Response](#response-30)
|
||||
- [HTTP](#http-31)
|
||||
+ [Delete Community](#delete-community)
|
||||
+ [Edit Community](#edit-community)
|
||||
- [Request](#request-31)
|
||||
- [Response](#response-31)
|
||||
- [HTTP](#http-32)
|
||||
+ [Remove Community](#remove-community)
|
||||
+ [Delete Community](#delete-community)
|
||||
- [Request](#request-32)
|
||||
- [Response](#response-32)
|
||||
- [HTTP](#http-33)
|
||||
+ [Follow Community](#follow-community)
|
||||
+ [Remove Community](#remove-community)
|
||||
- [Request](#request-33)
|
||||
- [Response](#response-33)
|
||||
- [HTTP](#http-34)
|
||||
+ [Get Followed Communities](#get-followed-communities)
|
||||
+ [Follow Community](#follow-community)
|
||||
- [Request](#request-34)
|
||||
- [Response](#response-34)
|
||||
- [HTTP](#http-35)
|
||||
+ [Transfer Community](#transfer-community)
|
||||
+ [Get Followed Communities](#get-followed-communities)
|
||||
- [Request](#request-35)
|
||||
- [Response](#response-35)
|
||||
- [HTTP](#http-36)
|
||||
* [Post](#post)
|
||||
+ [Create Post](#create-post)
|
||||
+ [Transfer Community](#transfer-community)
|
||||
- [Request](#request-36)
|
||||
- [Response](#response-36)
|
||||
- [HTTP](#http-37)
|
||||
+ [Get Post](#get-post)
|
||||
* [Post](#post)
|
||||
+ [Create Post](#create-post)
|
||||
- [Request](#request-37)
|
||||
- [Response](#response-37)
|
||||
- [HTTP](#http-38)
|
||||
+ [Get Posts](#get-posts)
|
||||
+ [Get Post](#get-post)
|
||||
- [Request](#request-38)
|
||||
- [Response](#response-38)
|
||||
- [HTTP](#http-39)
|
||||
+ [Create Post Like](#create-post-like)
|
||||
+ [Get Posts](#get-posts)
|
||||
- [Request](#request-39)
|
||||
- [Response](#response-39)
|
||||
- [HTTP](#http-40)
|
||||
+ [Edit Post](#edit-post)
|
||||
+ [Create Post Like](#create-post-like)
|
||||
- [Request](#request-40)
|
||||
- [Response](#response-40)
|
||||
- [HTTP](#http-41)
|
||||
+ [Delete Post](#delete-post)
|
||||
+ [Edit Post](#edit-post)
|
||||
- [Request](#request-41)
|
||||
- [Response](#response-41)
|
||||
- [HTTP](#http-42)
|
||||
+ [Remove Post](#remove-post)
|
||||
+ [Delete Post](#delete-post)
|
||||
- [Request](#request-42)
|
||||
- [Response](#response-42)
|
||||
- [HTTP](#http-43)
|
||||
+ [Lock Post](#lock-post)
|
||||
+ [Remove Post](#remove-post)
|
||||
- [Request](#request-43)
|
||||
- [Response](#response-43)
|
||||
- [HTTP](#http-44)
|
||||
+ [Sticky Post](#sticky-post)
|
||||
+ [Lock Post](#lock-post)
|
||||
- [Request](#request-44)
|
||||
- [Response](#response-44)
|
||||
- [HTTP](#http-45)
|
||||
+ [Save Post](#save-post)
|
||||
+ [Sticky Post](#sticky-post)
|
||||
- [Request](#request-45)
|
||||
- [Response](#response-45)
|
||||
- [HTTP](#http-46)
|
||||
* [Comment](#comment)
|
||||
+ [Create Comment](#create-comment)
|
||||
+ [Save Post](#save-post)
|
||||
- [Request](#request-46)
|
||||
- [Response](#response-46)
|
||||
- [HTTP](#http-47)
|
||||
+ [Edit Comment](#edit-comment)
|
||||
* [Comment](#comment)
|
||||
+ [Create Comment](#create-comment)
|
||||
- [Request](#request-47)
|
||||
- [Response](#response-47)
|
||||
- [HTTP](#http-48)
|
||||
+ [Delete Comment](#delete-comment)
|
||||
+ [Edit Comment](#edit-comment)
|
||||
- [Request](#request-48)
|
||||
- [Response](#response-48)
|
||||
- [HTTP](#http-49)
|
||||
+ [Remove Comment](#remove-comment)
|
||||
+ [Delete Comment](#delete-comment)
|
||||
- [Request](#request-49)
|
||||
- [Response](#response-49)
|
||||
- [HTTP](#http-50)
|
||||
+ [Mark Comment as Read](#mark-comment-as-read)
|
||||
+ [Remove Comment](#remove-comment)
|
||||
- [Request](#request-50)
|
||||
- [Response](#response-50)
|
||||
- [HTTP](#http-51)
|
||||
+ [Save Comment](#save-comment)
|
||||
+ [Get Comments](#get-comments)
|
||||
- [Request](#request-51)
|
||||
- [Response](#response-51)
|
||||
- [HTTP](#http-52)
|
||||
+ [Create Comment Like](#create-comment-like)
|
||||
+ [Mark Comment as Read](#mark-comment-as-read)
|
||||
- [Request](#request-52)
|
||||
- [Response](#response-52)
|
||||
- [HTTP](#http-53)
|
||||
+ [Save Comment](#save-comment)
|
||||
- [Request](#request-53)
|
||||
- [Response](#response-53)
|
||||
- [HTTP](#http-54)
|
||||
+ [Create Comment Like](#create-comment-like)
|
||||
- [Request](#request-54)
|
||||
- [Response](#response-54)
|
||||
- [HTTP](#http-55)
|
||||
* [RSS / Atom feeds](#rss--atom-feeds)
|
||||
+ [All](#all)
|
||||
+ [Community](#community-1)
|
||||
|
@ -1787,6 +1795,38 @@ Only a mod or admin can remove the comment.
|
|||
|
||||
`POST /comment/remove`
|
||||
|
||||
#### Get Comments
|
||||
|
||||
Comment listing types are `All, Subscribed, Community`
|
||||
|
||||
##### Request
|
||||
```rust
|
||||
{
|
||||
op: "GetComments",
|
||||
data: {
|
||||
type_: String,
|
||||
sort: String,
|
||||
page: Option<i64>,
|
||||
limit: Option<i64>,
|
||||
community_id: Option<i32>,
|
||||
community_name: Option<String>,
|
||||
auth: Option<String>
|
||||
}
|
||||
}
|
||||
```
|
||||
##### Response
|
||||
```rust
|
||||
{
|
||||
op: "GetComments",
|
||||
data: {
|
||||
comments: Vec<CommentView>,
|
||||
}
|
||||
}
|
||||
```
|
||||
##### HTTP
|
||||
|
||||
`GET /comment/list`
|
||||
|
||||
#### Mark Comment as Read
|
||||
|
||||
Only the recipient can do this.
|
||||
|
|
|
@ -68,6 +68,7 @@ pub struct GetComments {
|
|||
pub page: Option<i64>,
|
||||
pub limit: Option<i64>,
|
||||
pub community_id: Option<i32>,
|
||||
pub community_name: Option<String>,
|
||||
pub auth: Option<String>,
|
||||
}
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ pub struct CommentQueryBuilder<'a> {
|
|||
listing_type: ListingType,
|
||||
sort: &'a SortType,
|
||||
for_community_id: Option<i32>,
|
||||
for_community_name: Option<String>,
|
||||
for_post_id: Option<i32>,
|
||||
for_creator_id: Option<i32>,
|
||||
search_term: Option<String>,
|
||||
|
@ -153,6 +154,7 @@ impl<'a> CommentQueryBuilder<'a> {
|
|||
listing_type: ListingType::All,
|
||||
sort: &SortType::New,
|
||||
for_community_id: None,
|
||||
for_community_name: None,
|
||||
for_post_id: None,
|
||||
for_creator_id: None,
|
||||
search_term: None,
|
||||
|
@ -188,6 +190,11 @@ impl<'a> CommentQueryBuilder<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn for_community_name<T: MaybeOptional<String>>(mut self, for_community_name: T) -> Self {
|
||||
self.for_community_name = for_community_name.get_optional();
|
||||
self
|
||||
}
|
||||
|
||||
pub fn search_term<T: MaybeOptional<String>>(mut self, search_term: T) -> Self {
|
||||
self.search_term = search_term.get_optional();
|
||||
self
|
||||
|
@ -233,6 +240,10 @@ impl<'a> CommentQueryBuilder<'a> {
|
|||
query = query.filter(community_id.eq(for_community_id));
|
||||
}
|
||||
|
||||
if let Some(for_community_name) = self.for_community_name {
|
||||
query = query.filter(community_name.eq(for_community_name));
|
||||
}
|
||||
|
||||
if let Some(for_post_id) = self.for_post_id {
|
||||
query = query.filter(post_id.eq(for_post_id));
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::post_view::post_fast_view::BoxedQuery;
|
||||
use crate::{fuzzy_search, limit_and_offset, ListingType, MaybeOptional, SortType};
|
||||
use diesel::{dsl::*, pg::Pg, result::Error, *};
|
||||
use serde::{Serialize};
|
||||
use serde::Serialize;
|
||||
|
||||
// The faked schema since diesel doesn't do views
|
||||
table! {
|
||||
|
|
|
@ -674,6 +674,7 @@ impl Perform for GetComments {
|
|||
let sort = SortType::from_str(&data.sort)?;
|
||||
|
||||
let community_id = data.community_id;
|
||||
let community_name = data.community_name.to_owned();
|
||||
let page = data.page;
|
||||
let limit = data.limit;
|
||||
let comments = blocking(context.pool(), move |conn| {
|
||||
|
@ -681,6 +682,7 @@ impl Perform for GetComments {
|
|||
.listing_type(type_)
|
||||
.sort(&sort)
|
||||
.for_community_id(community_id)
|
||||
.for_community_name(community_name)
|
||||
.my_user_id(user_id)
|
||||
.page(page)
|
||||
.limit(limit)
|
||||
|
|
Loading…
Reference in a new issue