Who imports who · hover a node No overview comment at the top of the file.
Imports no other modules Used by 1 module 2 other Functions & values
Brings the user's synced avatar up to date with their Discord avatar newHash: copies the new avatar to S3 as an image and deletes the previous one. Also copies an unchanged avatar that was never stored (users skipped by the avatar migration). Never throws, a failed copy keeps the previous avatar.
export async function syncForUser ({
user,
discordId,
newHash,
}: {
user: {
id: number ;
discordAvatar: string | null ;
syncedAvatarImgId: number | null ;
};
discordId: string ;
newHash: string | null ;
})Unit tests (6) File name a Discord avatar is stored under, its small copy is next to it.
export function fileNameOf ({ userId, hash }: { userId: number ; hash: string })No overview comment at the top of the file.
Imports no other modules Used by 1 other Types
interface FlaggedRefreshno JSDoc :18 export interface FlaggedRefresh {
userId: number ;
returnTo: string | null ;
}Functions & values
Set-Cookie value marking the next OAuth callback as a profile refresh of the given user instead of a log in.
export function flagCookieHeader (refresh: FlaggedRefresh )export function clearFlagCookieHeader ()function flaggedRefresh:38 The profile refresh in progress, or null if the OAuth flow is a regular log in.
export async function flaggedRefresh (
request: Request ,
): Promise <FlaggedRefresh | null >Whether the user refreshed recently. Each refresh costs Discord API calls shared with log in's rate limit.
export function isOnCooldown (userId: number )function startCooldownno JSDoc :57 export function startCooldown (userId: number )No overview comment at the top of the file.
Imports DiscordAvatar.server Used by 2 other Types
type DiscordProfileno JSDoc :111 export type DiscordProfile = {
user: v.InferOutput <typeof partialDiscordUserSchema>;
connections: v.InferOutput <typeof partialDiscordConnectionsSchema>;
};Functions & values
function DiscordStrategyno JSDoc :38 export const DiscordStrategy = () =>Creates or updates the user (name, avatar, connections) from their Discord profile and returns their id. Unverified Discord accounts can't register.
export async function upsertUser ({ user, connections }: DiscordProfile )