feat: support concurrent Reddit accounts
This commit is contained in:
1 parent
d819a0f1e6
commit
16a31335d0
51 files changed
+3241
-250
No files matched your search
@@ -6,12 +6,28 @@ export const RedditSessionStateSchema = z.union([
|
||||
z.literal('login-required'),
|
||||
z.literal('unreachable'),
|
||||
]);
|
||||
export const RedditAccountSummarySchema = z.strictObject({
|
||||
accountId: z.string().min(1),
|
||||
redditUsername: z.string().min(1),
|
||||
matrixUserId: z.string().min(1),
|
||||
isRunning: z.boolean(),
|
||||
status: z.union([z.literal('authenticated'), z.literal('login-required')]),
|
||||
createdAt: z.number(),
|
||||
updatedAt: z.number(),
|
||||
lastImportedAt: z.number(),
|
||||
});
|
||||
export const RedditAccountOwnerSchema = RedditAccountSummarySchema.pick({
|
||||
accountId: true,
|
||||
redditUsername: true,
|
||||
});
|
||||
export const RedditAccountsResponseSchema = z.array(RedditAccountSummarySchema);
|
||||
export const LoginStatusResponseSchema = z.union([
|
||||
z.strictObject({ ready: z.literal(false), error: z.string() }),
|
||||
z.strictObject({
|
||||
ready: z.literal(true),
|
||||
loggedIn: z.boolean(),
|
||||
status: RedditSessionStateSchema,
|
||||
accountId: z.string().min(1).nullable().optional(),
|
||||
username: z.string().min(1).nullable().optional(),
|
||||
}),
|
||||
z.strictObject({
|
||||
@@ -39,10 +55,20 @@ export const RedditCookieImportRequestSchema = z.strictObject({
|
||||
}),
|
||||
});
|
||||
export const RedditCookieImportResponseSchema = z.union([
|
||||
z.strictObject({ ok: z.literal(true), status: z.literal('authenticated') }),
|
||||
z.strictObject({
|
||||
ok: z.literal(true),
|
||||
status: z.literal('authenticated'),
|
||||
account: RedditAccountSummarySchema,
|
||||
}),
|
||||
z.strictObject({ ok: z.literal(false), error: z.string() }),
|
||||
]);
|
||||
export const RedditAccountActivationResponseSchema = z.union([
|
||||
z.strictObject({ ok: z.literal(true), account: RedditAccountSummarySchema }),
|
||||
z.strictObject({ ok: z.literal(false), error: z.string() }),
|
||||
]);
|
||||
|
||||
export type RedditSessionState = z.infer<typeof RedditSessionStateSchema>;
|
||||
export type LoginStatusResponse = z.infer<typeof LoginStatusResponseSchema>;
|
||||
export type RedditCookieImportRequest = z.infer<typeof RedditCookieImportRequestSchema>;
|
||||
export type RedditAccountSummary = z.infer<typeof RedditAccountSummarySchema>;
|
||||
export type RedditAccountOwner = z.infer<typeof RedditAccountOwnerSchema>;
|
||||
Reference in new issue
Block a user