mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-30 01:43:03 +00:00
Refactor
This commit is contained in:
parent
fffa32df48
commit
d9780606b3
6 changed files with 9 additions and 9 deletions
|
@ -3,7 +3,7 @@ import * as Bull from 'bull';
|
||||||
import { queueLogger } from '../../logger';
|
import { queueLogger } from '../../logger';
|
||||||
import follow from '../../../services/following/create';
|
import follow from '../../../services/following/create';
|
||||||
import parseAcct from '../../../misc/acct/parse';
|
import parseAcct from '../../../misc/acct/parse';
|
||||||
import resolveUser from '../../../remote/resolve-user';
|
import { resolveUser } from '../../../remote/resolve-user';
|
||||||
import { downloadTextFile } from '../../../misc/download-text-file';
|
import { downloadTextFile } from '../../../misc/download-text-file';
|
||||||
import { isSelfHost, toDbHost } from '../../../misc/convert-host';
|
import { isSelfHost, toDbHost } from '../../../misc/convert-host';
|
||||||
import { Users, DriveFiles } from '../../../models';
|
import { Users, DriveFiles } from '../../../models';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as Bull from 'bull';
|
||||||
|
|
||||||
import { queueLogger } from '../../logger';
|
import { queueLogger } from '../../logger';
|
||||||
import parseAcct from '../../../misc/acct/parse';
|
import parseAcct from '../../../misc/acct/parse';
|
||||||
import resolveUser from '../../../remote/resolve-user';
|
import { resolveUser } from '../../../remote/resolve-user';
|
||||||
import { pushUserToUserList } from '../../../services/user-list/push';
|
import { pushUserToUserList } from '../../../services/user-list/push';
|
||||||
import { downloadTextFile } from '../../../misc/download-text-file';
|
import { downloadTextFile } from '../../../misc/download-text-file';
|
||||||
import { isSelfHost, toDbHost } from '../../../misc/convert-host';
|
import { isSelfHost, toDbHost } from '../../../misc/convert-host';
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { Users } from '../models';
|
||||||
|
|
||||||
const logger = remoteLogger.createSubLogger('resolve-user');
|
const logger = remoteLogger.createSubLogger('resolve-user');
|
||||||
|
|
||||||
export default async (username: string, _host: string, option?: any, resync = false): Promise<User> => {
|
export async function resolveUser(username: string, _host: string, option?: any, resync = false): Promise<User> {
|
||||||
const usernameLower = username.toLowerCase();
|
const usernameLower = username.toLowerCase();
|
||||||
|
|
||||||
if (_host == null) {
|
if (_host == null) {
|
||||||
|
@ -73,7 +73,7 @@ export default async (username: string, _host: string, option?: any, resync = fa
|
||||||
|
|
||||||
logger.info(`return existing remote user: ${acctLower}`);
|
logger.info(`return existing remote user: ${acctLower}`);
|
||||||
return user;
|
return user;
|
||||||
};
|
}
|
||||||
|
|
||||||
async function resolveSelf(acctLower: string) {
|
async function resolveSelf(acctLower: string) {
|
||||||
logger.info(`WebFinger for ${chalk.yellow(acctLower)}`);
|
logger.info(`WebFinger for ${chalk.yellow(acctLower)}`);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import resolveRemoteUser from '../../../../remote/resolve-user';
|
import { resolveUser } from '../../../../remote/resolve-user';
|
||||||
import define from '../../define';
|
import define from '../../define';
|
||||||
import { apiLogger } from '../../logger';
|
import { apiLogger } from '../../logger';
|
||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
|
@ -75,7 +75,7 @@ export default define(meta, async (ps, me) => {
|
||||||
} else {
|
} else {
|
||||||
// Lookup user
|
// Lookup user
|
||||||
if (typeof ps.host === 'string') {
|
if (typeof ps.host === 'string') {
|
||||||
user = await resolveRemoteUser(ps.username, ps.host).catch(e => {
|
user = await resolveUser(ps.username, ps.host).catch(e => {
|
||||||
apiLogger.warn(`failed to resolve remote user: ${e}`);
|
apiLogger.warn(`failed to resolve remote user: ${e}`);
|
||||||
throw new ApiError(meta.errors.failedToResolveRemoteUser);
|
throw new ApiError(meta.errors.failedToResolveRemoteUser);
|
||||||
});
|
});
|
||||||
|
@ -94,7 +94,7 @@ export default define(meta, async (ps, me) => {
|
||||||
// ユーザー情報更新
|
// ユーザー情報更新
|
||||||
if (Users.isRemoteUser(user)) {
|
if (Users.isRemoteUser(user)) {
|
||||||
if (user.lastFetchedAt == null || Date.now() - user.lastFetchedAt.getTime() > 1000 * 60 * 60 * 24) {
|
if (user.lastFetchedAt == null || Date.now() - user.lastFetchedAt.getTime() > 1000 * 60 * 60 * 24) {
|
||||||
resolveRemoteUser(ps.username, ps.host, { }, true);
|
resolveUser(ps.username, ps.host, { }, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import renderAnnounce from '../../remote/activitypub/renderer/announce';
|
||||||
import { renderActivity } from '../../remote/activitypub/renderer';
|
import { renderActivity } from '../../remote/activitypub/renderer';
|
||||||
import watch from './watch';
|
import watch from './watch';
|
||||||
import { parse } from '../../mfm/parse';
|
import { parse } from '../../mfm/parse';
|
||||||
import resolveUser from '../../remote/resolve-user';
|
import { resolveUser } from '../../remote/resolve-user';
|
||||||
import config from '../../config';
|
import config from '../../config';
|
||||||
import { updateHashtag } from '../update-hashtag';
|
import { updateHashtag } from '../update-hashtag';
|
||||||
import { erase, concat } from '../../prelude/array';
|
import { erase, concat } from '../../prelude/array';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import parseAcct from '../misc/acct/parse';
|
import parseAcct from '../misc/acct/parse';
|
||||||
import resolveUser from '../remote/resolve-user';
|
import { resolveUser } from '../remote/resolve-user';
|
||||||
|
|
||||||
async function main(acct: string): Promise<any> {
|
async function main(acct: string): Promise<any> {
|
||||||
const { username, host } = parseAcct(acct);
|
const { username, host } = parseAcct(acct);
|
||||||
|
|
Loading…
Reference in a new issue