show posts on profile page

This commit is contained in:
ari melody 2025-07-14 04:10:16 +01:00
parent d8efaccb30
commit 455679a525
Signed by: ari
GPG key ID: CF99829C92678188
7 changed files with 158 additions and 10 deletions

View file

@ -448,3 +448,51 @@ export async function lookupUser(host, token, handle) {
return data;
}
/**
* GET /api/v1/accounts/{user_id}/statuses
* @param {string} host - The domain of the target server.
* @param {string} token - The application token.
* @param {string} user_id - The ID of the user to fetch.
* @param {string} max_id - If provided, only shows notifications before this ID.
* @param {boolean} replies - If replies should be fetched.
* @param {boolean} boosts - If boosts should be fetched.
* @param {boolean} only_media - If only media should be fetched.
*/
export async function getUserPosts(host, token, user_id, max_id, show_replies, show_boosts, only_media) {
let url = new URL(`https://${host}/api/v1/accounts/${user_id}/statuses`);
let query = [];
if (!show_replies)
query.push('exclude_replies=true');
if (!show_boosts)
query.push('exclude_boosts=true');
if (only_media)
query.push('only_media=true');
if (max_id)
query.push(`max_id=${max_id}`);
url.search = query.join('&');
const data = await fetch(url, {
method: 'GET',
headers: { "Authorization": token ? `Bearer ${token}` : null }
}).then(res => res.json());
return data;
}
/**
* GET /api/v1/accounts/{user_id}/statuses?pinned=true
* @param {string} host - The domain of the target server.
* @param {string} token - The application token.
* @param {string} user_id - The ID of the user to fetch.
*/
export async function getUserPinnedPosts(host, token, user_id) {
let url = `https://${host}/api/v1/accounts/${user_id}/statuses?pinned=true`;
const data = await fetch(url, {
method: 'GET',
headers: { "Authorization": token ? `Bearer ${token}` : null }
}).then(res => res.json());
return data;
}