forked from mirror/misskey
Refactoring
This commit is contained in:
parent
1c241776a6
commit
dc69490e3a
@ -61,7 +61,7 @@ import * as mfm from 'mfm-js';
|
|||||||
import { host, url } from '@client/config';
|
import { host, url } from '@client/config';
|
||||||
import { erase, unique } from '../../prelude/array';
|
import { erase, unique } from '../../prelude/array';
|
||||||
import { extractMentions } from '@/misc/extract-mentions';
|
import { extractMentions } from '@/misc/extract-mentions';
|
||||||
import getAcct from '@/misc/acct/render';
|
import { getAcct } from '@/misc/acct';
|
||||||
import { formatTimeString } from '@/misc/format-time-string';
|
import { formatTimeString } from '@/misc/format-time-string';
|
||||||
import { Autocomplete } from '@client/scripts/autocomplete';
|
import { Autocomplete } from '@client/scripts/autocomplete';
|
||||||
import { noteVisibilities } from '../../types';
|
import { noteVisibilities } from '../../types';
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import MkFollowButton from './follow-button.vue';
|
import MkFollowButton from './follow-button.vue';
|
||||||
import { userPage } from '../filters/user';
|
import { userPage } from '../filters/user';
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import MkFollowButton from './follow-button.vue';
|
import MkFollowButton from './follow-button.vue';
|
||||||
import { userPage } from '../filters/user';
|
import { userPage } from '../filters/user';
|
||||||
import * as os from '@client/os';
|
import * as os from '@client/os';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import getAcct from '@/misc/acct/render';
|
import { getAcct } from '@/misc/acct';
|
||||||
import getUserName from '@/misc/get-user-name';
|
import getUserName from '@/misc/get-user-name';
|
||||||
import { url } from '@client/config';
|
import { url } from '@client/config';
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import * as os from '@client/os';
|
import * as os from '@client/os';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
created() {
|
created() {
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import MkButton from '@client/components/ui/button.vue';
|
import MkButton from '@client/components/ui/button.vue';
|
||||||
import MkInput from '@client/components/ui/input.vue';
|
import MkInput from '@client/components/ui/input.vue';
|
||||||
import MkSelect from '@client/components/ui/select.vue';
|
import MkSelect from '@client/components/ui/select.vue';
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineAsyncComponent, defineComponent } from 'vue';
|
import { defineAsyncComponent, defineComponent } from 'vue';
|
||||||
import getAcct from '@/misc/acct/render';
|
import { getAcct } from '@/misc/acct';
|
||||||
import MkButton from '@client/components/ui/button.vue';
|
import MkButton from '@client/components/ui/button.vue';
|
||||||
import { acct } from '../../filters/user';
|
import { acct } from '../../filters/user';
|
||||||
import * as os from '@client/os';
|
import * as os from '@client/os';
|
||||||
|
@ -40,7 +40,7 @@ import { computed, defineComponent } from 'vue';
|
|||||||
import XList from '@client/components/date-separated-list.vue';
|
import XList from '@client/components/date-separated-list.vue';
|
||||||
import XMessage from './messaging-room.message.vue';
|
import XMessage from './messaging-room.message.vue';
|
||||||
import XForm from './messaging-room.form.vue';
|
import XForm from './messaging-room.form.vue';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import { isBottom, onScrollBottom, scroll } from '@client/scripts/scroll';
|
import { isBottom, onScrollBottom, scroll } from '@client/scripts/scroll';
|
||||||
import * as os from '@client/os';
|
import * as os from '@client/os';
|
||||||
import { popout } from '@client/scripts/popout';
|
import { popout } from '@client/scripts/popout';
|
||||||
|
@ -52,7 +52,7 @@ import MkInput from '@client/components/ui/input.vue';
|
|||||||
import MkTextarea from '@client/components/ui/textarea.vue';
|
import MkTextarea from '@client/components/ui/textarea.vue';
|
||||||
import MkSelect from '@client/components/ui/select.vue';
|
import MkSelect from '@client/components/ui/select.vue';
|
||||||
import MkSwitch from '@client/components/ui/switch.vue';
|
import MkSwitch from '@client/components/ui/switch.vue';
|
||||||
import getAcct from '@/misc/acct/render';
|
import { getAcct } from '@/misc/acct';
|
||||||
import * as os from '@client/os';
|
import * as os from '@client/os';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent } from 'vue';
|
import { computed, defineComponent } from 'vue';
|
||||||
import { Room } from '@client/scripts/room/room';
|
import { Room } from '@client/scripts/room/room';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import XPreview from './preview.vue';
|
import XPreview from './preview.vue';
|
||||||
const storeItems = require('@client/scripts/room/furnitures.json5');
|
const storeItems = require('@client/scripts/room/furnitures.json5');
|
||||||
import { query as urlQuery } from '../../../prelude/url';
|
import { query as urlQuery } from '../../../prelude/url';
|
||||||
|
@ -234,7 +234,7 @@ import MkRemoteCaution from '@client/components/remote-caution.vue';
|
|||||||
import MkTab from '@client/components/tab.vue';
|
import MkTab from '@client/components/tab.vue';
|
||||||
import MkInfo from '@client/components/ui/info.vue';
|
import MkInfo from '@client/components/ui/info.vue';
|
||||||
import Progress from '@client/scripts/loading';
|
import Progress from '@client/scripts/loading';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import { getScrollPosition } from '@client/scripts/scroll';
|
import { getScrollPosition } from '@client/scripts/scroll';
|
||||||
import { getUserMenu } from '@client/scripts/get-user-menu';
|
import { getUserMenu } from '@client/scripts/get-user-menu';
|
||||||
import number from '../../filters/number';
|
import number from '../../filters/number';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import { host as localHost } from '@client/config';
|
import { host as localHost } from '@client/config';
|
||||||
|
|
||||||
export async function genSearchQuery(v: any, q: string) {
|
export async function genSearchQuery(v: any, q: string) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { i18n } from '@client/i18n';
|
import { i18n } from '@client/i18n';
|
||||||
import copyToClipboard from '@client/scripts/copy-to-clipboard';
|
import copyToClipboard from '@client/scripts/copy-to-clipboard';
|
||||||
import { host } from '@client/config';
|
import { host } from '@client/config';
|
||||||
import getAcct from '@/misc/acct/render';
|
import { getAcct } from '@/misc/acct';
|
||||||
import * as os from '@client/os';
|
import * as os from '@client/os';
|
||||||
import { userActions } from '@client/store';
|
import { userActions } from '@client/store';
|
||||||
import { router } from '@client/router';
|
import { router } from '@client/router';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import { i18n } from '@client/i18n';
|
import { i18n } from '@client/i18n';
|
||||||
import * as os from '@client/os';
|
import * as os from '@client/os';
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ import * as mfm from 'mfm-js';
|
|||||||
import { host, url } from '@client/config';
|
import { host, url } from '@client/config';
|
||||||
import { erase, unique } from '../../../prelude/array';
|
import { erase, unique } from '../../../prelude/array';
|
||||||
import { extractMentions } from '@/misc/extract-mentions';
|
import { extractMentions } from '@/misc/extract-mentions';
|
||||||
import getAcct from '@/misc/acct/render';
|
import { getAcct } from '@/misc/acct';
|
||||||
import { formatTimeString } from '@/misc/format-time-string';
|
import { formatTimeString } from '@/misc/format-time-string';
|
||||||
import { Autocomplete } from '@client/scripts/autocomplete';
|
import { Autocomplete } from '@client/scripts/autocomplete';
|
||||||
import { noteVisibilities } from '../../../types';
|
import { noteVisibilities } from '../../../types';
|
||||||
|
14
src/misc/acct.ts
Normal file
14
src/misc/acct.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export type Acct = {
|
||||||
|
username: string;
|
||||||
|
host: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getAcct = (user: Acct) => {
|
||||||
|
return user.host == null ? user.username : `${user.username}@${user.host}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const parseAcct = (acct: string): Acct => {
|
||||||
|
if (acct.startsWith('@')) acct = acct.substr(1);
|
||||||
|
const split = acct.split('@', 2);
|
||||||
|
return { username: split[0], host: split[1] || null };
|
||||||
|
};
|
@ -1,7 +0,0 @@
|
|||||||
import Acct from './type';
|
|
||||||
|
|
||||||
export default (acct: string): Acct => {
|
|
||||||
if (acct.startsWith('@')) acct = acct.substr(1);
|
|
||||||
const split = acct.split('@', 2);
|
|
||||||
return { username: split[0], host: split[1] || null };
|
|
||||||
};
|
|
@ -1,5 +0,0 @@
|
|||||||
import Acct from './type';
|
|
||||||
|
|
||||||
export default (user: Acct) => {
|
|
||||||
return user.host == null ? user.username : `${user.username}@${user.host}`;
|
|
||||||
};
|
|
@ -1,6 +0,0 @@
|
|||||||
type Acct = {
|
|
||||||
username: string;
|
|
||||||
host: string | null;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Acct;
|
|
@ -2,7 +2,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';
|
||||||
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, toPuny } from '@/misc/convert-host';
|
import { isSelfHost, toPuny } from '@/misc/convert-host';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as Bull from 'bull';
|
import * as Bull from 'bull';
|
||||||
|
|
||||||
import { queueLogger } from '../../logger';
|
import { queueLogger } from '../../logger';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
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';
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import define from '../define';
|
import define from '../define';
|
||||||
import { Users } from '../../../models';
|
import { Users } from '../../../models';
|
||||||
import { fetchMeta } from '@/misc/fetch-meta';
|
import { fetchMeta } from '@/misc/fetch-meta';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import { User } from '../../../models/entities/user';
|
import { User } from '../../../models/entities/user';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as Limiter from 'ratelimiter';
|
import * as Limiter from 'ratelimiter';
|
||||||
import { redisClient } from '../../db/redis';
|
import { redisClient } from '../../db/redis';
|
||||||
import { IEndpoint } from './endpoints';
|
import { IEndpoint } from './endpoints';
|
||||||
import getAcct from '@/misc/acct/render';
|
import { getAcct } from '@/misc/acct';
|
||||||
import { User } from '../../models/entities/user';
|
import { User } from '../../models/entities/user';
|
||||||
import Logger from '../../services/logger';
|
import Logger from '../../services/logger';
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import { fetchMeta } from '@/misc/fetch-meta';
|
|||||||
import { genOpenapiSpec } from '../api/openapi/gen-spec';
|
import { genOpenapiSpec } from '../api/openapi/gen-spec';
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import { Users, Notes, Emojis, UserProfiles, Pages, Channels, Clips, GalleryPosts } from '../../models';
|
import { Users, Notes, Emojis, UserProfiles, Pages, Channels, Clips, GalleryPosts } from '../../models';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
import { getNoteSummary } from '@/misc/get-note-summary';
|
import { getNoteSummary } from '@/misc/get-note-summary';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
import { redisClient } from '../../db/redis';
|
import { redisClient } from '../../db/redis';
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import * as Router from '@koa/router';
|
import * as Router from '@koa/router';
|
||||||
|
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct, Acct } from '@/misc/acct';
|
||||||
import Acct from '@/misc/acct/type';
|
|
||||||
import { links } from './nodeinfo';
|
import { links } from './nodeinfo';
|
||||||
import { escapeAttribute, escapeValue } from '../prelude/xml';
|
import { escapeAttribute, escapeValue } from '../prelude/xml';
|
||||||
import { Users } from '../models';
|
import { Users } from '../models';
|
||||||
|
@ -3,7 +3,7 @@ import { User } from '../models/entities/user';
|
|||||||
import { sendEmail } from './send-email';
|
import { sendEmail } from './send-email';
|
||||||
import * as locales from '../../locales/';
|
import * as locales from '../../locales/';
|
||||||
import { I18n } from '@/misc/i18n';
|
import { I18n } from '@/misc/i18n';
|
||||||
import acct from '@/misc/acct/render';
|
import { getAcct } from '@/misc/acct';
|
||||||
|
|
||||||
// TODO: locale ファイルをクライアント用とサーバー用で分けたい
|
// TODO: locale ファイルをクライアント用とサーバー用で分けたい
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ async function follow(userId: User['id'], follower: User) {
|
|||||||
const locale = locales[userProfile.lang || 'ja-JP'];
|
const locale = locales[userProfile.lang || 'ja-JP'];
|
||||||
const i18n = new I18n(locale);
|
const i18n = new I18n(locale);
|
||||||
// TODO: render user information html
|
// TODO: render user information html
|
||||||
sendEmail(userProfile.email, i18n.t('_email._follow.title'), `${follower.name} (@${acct(follower)})`, `${follower.name} (@${acct(follower)})`);
|
sendEmail(userProfile.email, i18n.t('_email._follow.title'), `${follower.name} (@${getAcct(follower)})`, `${follower.name} (@${getAcct(follower)})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function receiveFollowRequest(userId: User['id'], args: {}) {
|
async function receiveFollowRequest(userId: User['id'], args: {}) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { initDb } from '@/db/postgre';
|
import { initDb } from '@/db/postgre';
|
||||||
import parseAcct from '@/misc/acct/parse';
|
import { parseAcct } from '@/misc/acct';
|
||||||
|
|
||||||
async function main(acct: string): Promise<any> {
|
async function main(acct: string): Promise<any> {
|
||||||
await initDb();
|
await initDb();
|
||||||
|
Loading…
Reference in New Issue
Block a user