@@ -103,32 +103,37 @@ async function getAccountIdByAcct(acct) {
103103 const search_url = `https://${ site } /api/v2/search` ;
104104 const cacheUid = `mastodon_acct_id/${ site } /${ acct } ` ;
105105
106- const account_id = await cache . tryGet ( cacheUid , async ( ) => {
107- const search_response = await got ( {
108- method : 'get' ,
109- url : search_url ,
110- headers : apiHeaders ( site ) ,
111- searchParams : {
112- q : acct ,
113- type : 'accounts' ,
114- } ,
115- } ) ;
116- const [ acctUser , acctHost ] = acct . split ( '@' ) . filter ( Boolean ) ;
117- let acctOnServer ;
118-
119- if ( acctHost ) {
120- acctOnServer = acctHost === acctDomain ? acctUser : acctUser + '@' + acctHost ;
121- } else {
122- acctOnServer = acctUser ;
123- }
106+ const account_id = await cache . tryGet (
107+ cacheUid ,
108+ async ( ) => {
109+ const search_response = await got ( {
110+ method : 'get' ,
111+ url : search_url ,
112+ headers : apiHeaders ( site ) ,
113+ searchParams : {
114+ q : acct ,
115+ type : 'accounts' ,
116+ } ,
117+ } ) ;
118+ const [ acctUser , acctHost ] = acct . split ( '@' ) . filter ( Boolean ) ;
119+ let acctOnServer ;
120+
121+ if ( acctHost ) {
122+ acctOnServer = acctHost === acctDomain ? acctUser : acctUser + '@' + acctHost ;
123+ } else {
124+ acctOnServer = acctUser ;
125+ }
124126
125- const accountData = search_response . data . accounts . filter ( ( item ) => item . acct === acctOnServer ) ;
127+ const accountData = search_response . data . accounts . filter ( ( item ) => item . acct === acctOnServer ) ;
126128
127- if ( accountData . length === 0 ) {
128- throw new Error ( `acct ${ acct } not found` ) ;
129- }
130- return accountData [ 0 ] . id ;
131- } ) ;
129+ if ( accountData . length === 0 ) {
130+ throw new Error ( `acct ${ acct } not found` ) ;
131+ }
132+ return accountData [ 0 ] . id ;
133+ } ,
134+ config . cache . contentExpire ,
135+ false
136+ ) ;
132137 return { site, account_id } ;
133138}
134139
0 commit comments