this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

more timestamp stuff

alice 8d9d5d02 1fbf9ed6

+16 -11
+10 -6
src/helpers/sanitize.ts
··· 13 13 } 14 14 } 15 15 16 - export function sanitizeTimestamp(timestamp: string | undefined | null): { timestamp: string; wasWeird: boolean } { 16 + export function sanitizeTimestamp(timestamp: string | undefined | null): { 17 + timestamp: string; 18 + wasWeird: boolean; 19 + defaulted: boolean; 20 + } { 17 21 const defaultTimestamp = '1970-01-01T00:00:00.000Z'; 18 22 19 23 // If there is no timestamp, return the default timestamp 20 24 if (!timestamp) { 21 - return { timestamp: defaultTimestamp, wasWeird: true }; 25 + return { timestamp: defaultTimestamp, wasWeird: false, defaulted: true }; 22 26 } 23 27 24 28 // No such thing as year 0 in the Gregorian calendar ··· 31 35 32 36 // If the timestamp is not a valid date, return the default timestamp 33 37 if (isNaN(date.getTime())) { 34 - return { timestamp: defaultTimestamp, wasWeird: true }; 38 + return { timestamp: defaultTimestamp, wasWeird: true, defaulted: true }; 35 39 } 36 40 37 41 const LOW_YEAR = 1; // Since Bluesky uses Go, dates don't go back further than 1AD ··· 44 48 if (year >= LOW_YEAR && year <= HIGH_YEAR) { 45 49 if (year >= SANE_LOW_YEAR && year <= SANE_HIGH_YEAR) { 46 50 // sane year, valid date 47 - return { timestamp: date.toISOString(), wasWeird: false }; 51 + return { timestamp: date.toISOString(), wasWeird: false, defaulted: false }; 48 52 } 49 53 50 54 // weird year, but valid date 51 - return { timestamp: date.toISOString(), wasWeird: true }; 55 + return { timestamp: date.toISOString(), wasWeird: true, defaulted: false }; 52 56 } 53 57 54 58 // invalid date in some way 55 - return { timestamp: defaultTimestamp, wasWeird: true }; 59 + return { timestamp: defaultTimestamp, wasWeird: true, defaulted: true }; 56 60 } 57 61 58 62 export function sanitizeString(input: string | undefined | null): string {
+6 -5
src/stages/stage3.ts
··· 67 67 if (rkey === '') { 68 68 rkey = Math.random().toString(36).substring(2, 15); 69 69 } 70 - const { timestamp, wasWeird } = sanitizeTimestamp(postData.createdAt); 70 + const { timestamp, wasWeird, defaulted } = sanitizeTimestamp(postData.createdAt); 71 71 72 72 if (wasWeird) { 73 - console.error(`Weird timestamp for DID: ${did} 73 + console.error(`Weird post timestamp for DID: ${did} 74 74 rkey: ${rkey} 75 75 cid: ${postData.cid} 76 - createdAt: ${timestamp}`); 76 + original createdAt: ${postData.createdAt} 77 + sanitized createdAt: ${timestamp}`); 77 78 } 78 79 79 80 const langs = processLanguages(postData.langs); ··· 108 109 if (rkey === '') { 109 110 rkey = Math.random().toString(36).substring(2, 15); 110 111 } 111 - const { timestamp, wasWeird } = sanitizeTimestamp(profileData.createdAt); 112 + const { timestamp, wasWeird, defaulted } = sanitizeTimestamp(profileData.createdAt); 112 113 113 114 if (wasWeird) { 114 - console.error(`Weird timestamp for DID: ${did} 115 + console.error(`Weird profiletimestamp for DID: ${did} 115 116 rkey: ${rkey} 116 117 cid: ${profileData.cid} 117 118 createdAt: ${timestamp}`);