mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-12-14 04:05:14 +00:00
WIP: add user posts page
This commit is contained in:
@@ -62,6 +62,17 @@ export const fetchComments = async (galleryID: string): Promise<Comment[]> => {
|
||||
/* eslint-enable max-len */
|
||||
}
|
||||
|
||||
export const fetchUserPosts = async (userID: string, sort: Sorting = 'newest'): Promise<Comment[]> => {
|
||||
/* eslint-disable max-len */
|
||||
// https://api.imgur.com/3/account/mombotnumber5/submissions/0/newest?album_previews=1&client_id=${CLIENT_ID}
|
||||
const response = await got(
|
||||
`https://api.imgur.com/3/account/${userID.toLowerCase()}/submissions/0/newest?album_previews=1&client_id=${CONFIG.imgur_client_id}`,
|
||||
{ agent }
|
||||
);
|
||||
return JSON.parse(response.body).data;
|
||||
/* eslint-enable max-len */
|
||||
}
|
||||
|
||||
export const fetchGallery = async (galleryID: string): Promise<Gallery> => {
|
||||
// https://imgur.com/gallery/g1bk7CB
|
||||
const response = await got(`https://imgur.com/gallery/${galleryID}`, { agent });
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Hapi = require('@hapi/hapi');
|
||||
import '@hapi/vision';
|
||||
import { fetchAlbum, fetchAlbumURL, fetchComments, fetchGallery, fetchMedia } from './fetchers';
|
||||
import { fetchAlbum, fetchAlbumURL, fetchComments, fetchGallery, fetchMedia, fetchUserPosts } from './fetchers';
|
||||
import * as util from './util';
|
||||
|
||||
import CONFIG from './config';
|
||||
@@ -35,9 +35,18 @@ export const handleAlbum = async (request: Hapi.Request, h: Hapi.ResponseToolkit
|
||||
});
|
||||
};
|
||||
|
||||
export const handleUser = (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
||||
export const handleUser = async (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
||||
// https://imgur.com/user/MomBotNumber5
|
||||
throw new Error('not implemented');
|
||||
if (!CONFIG.use_api) {
|
||||
return 'User page disabled. Rimgu administrator needs to enable API for this to work.';
|
||||
}
|
||||
const userID = request.params.userID;
|
||||
const userPosts = await fetchUserPosts(userID);
|
||||
return h.view('user-posts', {
|
||||
userPosts,
|
||||
pageTitle: CONFIG.page_title,
|
||||
util,
|
||||
});
|
||||
};
|
||||
|
||||
export const handleTag = (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
||||
|
||||
1
src/types/index.d.ts
vendored
1
src/types/index.d.ts
vendored
@@ -8,6 +8,7 @@ interface Account {
|
||||
type MediaMimeType = 'image/jpeg' | 'image/png' | 'image/gif';
|
||||
type MediaType = 'image';
|
||||
type MediaExt = 'jpeg' | 'png' | 'gif';
|
||||
type Sorting = 'newest' | 'oldest' | 'best';
|
||||
|
||||
interface Tag {
|
||||
tag: string;
|
||||
|
||||
Reference in New Issue
Block a user