feat: persist settings and enrich conversation context
This commit is contained in:
1 parent
a36723a325
commit
2c100d72b6
84 files changed
+2248
-644
No files matched your search
@@ -8,6 +8,7 @@ export interface RedditPost {
|
||||
name: string; // fullname like "t3_xxxxx"
|
||||
subreddit: string;
|
||||
author: string;
|
||||
author_fullname?: string; // account fullname like "t2_xxxxx"
|
||||
title: string;
|
||||
url: string;
|
||||
permalink: string;
|
||||
@@ -83,6 +84,26 @@ export class RedditApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
/** Resolve a Reddit username through the authenticated browser session. */
|
||||
async resolveUsernameToT2(username: string): Promise<string | null> {
|
||||
const cookieHeader = await this.getCookieHeader();
|
||||
const headers: Record<string, string> = {};
|
||||
if (cookieHeader) headers.Cookie = cookieHeader;
|
||||
|
||||
try {
|
||||
const response = await this.client.get(
|
||||
`/user/${encodeURIComponent(username)}/about.json`,
|
||||
{ params: { raw_json: 1 }, headers },
|
||||
);
|
||||
const id = response.data?.data?.id;
|
||||
if (typeof id !== 'string' || id.length === 0) return null;
|
||||
return id.startsWith('t2_') ? id : `t2_${id}`;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error) && error.response?.status === 404) return null;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async getNewPosts(subreddit: string, limit = 25, type: 'image' | 'chat' = 'image'): Promise<RedditPost[]> {
|
||||
try {
|
||||
const cookieHeader = await this.getCookieHeader();
|
||||
|
||||
Reference in new issue
Block a user