Compare commits
5 Commits
11.0.0-bet
...
11.0.0-bet
Author | SHA1 | Date | |
---|---|---|---|
2927fb1597 | |||
8c72e011d2 | |||
69662e24c3 | |||
96099ffe98 | |||
ae16b45c11 |
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "misskey",
|
"name": "misskey",
|
||||||
"author": "syuilo <i@syuilo.com>",
|
"author": "syuilo <i@syuilo.com>",
|
||||||
"version": "11.0.0-beta.7",
|
"version": "11.0.0-beta.9",
|
||||||
"codename": "daybreak",
|
"codename": "daybreak",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -19,3 +19,8 @@ export function extractDbHost(uri: string) {
|
|||||||
export function toPuny(host: string) {
|
export function toPuny(host: string) {
|
||||||
return toASCII(host.toLowerCase());
|
return toASCII(host.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function toPunyNullable(host: string | null | undefined): string | null {
|
||||||
|
if (host == null) return null;
|
||||||
|
return toASCII(host.toLowerCase());
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { EntityRepository, Repository } from 'typeorm';
|
import { EntityRepository, Repository } from 'typeorm';
|
||||||
import { UserList } from '../entities/user-list';
|
import { UserList } from '../entities/user-list';
|
||||||
import { ensure } from '../../prelude/ensure';
|
import { ensure } from '../../prelude/ensure';
|
||||||
|
import { UserListJoinings } from '..';
|
||||||
|
|
||||||
@EntityRepository(UserList)
|
@EntityRepository(UserList)
|
||||||
export class UserListRepository extends Repository<UserList> {
|
export class UserListRepository extends Repository<UserList> {
|
||||||
@ -9,9 +10,14 @@ export class UserListRepository extends Repository<UserList> {
|
|||||||
) {
|
) {
|
||||||
const userList = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
const userList = typeof src === 'object' ? src : await this.findOne(src).then(ensure);
|
||||||
|
|
||||||
|
const users = await UserListJoinings.find({
|
||||||
|
userListId: userList.id
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: userList.id,
|
id: userList.id,
|
||||||
name: userList.name
|
name: userList.name,
|
||||||
|
userIds: users.map(x => x.userId)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import { Instances, Users, UserPublickeys } from '../../models';
|
|||||||
import { instanceChart } from '../../services/chart';
|
import { instanceChart } from '../../services/chart';
|
||||||
import { UserPublickey } from '../../models/entities/user-publickey';
|
import { UserPublickey } from '../../models/entities/user-publickey';
|
||||||
import fetchMeta from '../../misc/fetch-meta';
|
import fetchMeta from '../../misc/fetch-meta';
|
||||||
import { toPuny } from '../../misc/convert-host';
|
import { toPuny, toPunyNullable } from '../../misc/convert-host';
|
||||||
import { validActor } from '../../remote/activitypub/type';
|
import { validActor } from '../../remote/activitypub/type';
|
||||||
import { ensure } from '../../prelude/ensure';
|
import { ensure } from '../../prelude/ensure';
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ export default async (job: Bull.Job): Promise<void> => {
|
|||||||
|
|
||||||
if (keyIdLower.startsWith('acct:')) {
|
if (keyIdLower.startsWith('acct:')) {
|
||||||
const acct = parseAcct(keyIdLower.slice('acct:'.length));
|
const acct = parseAcct(keyIdLower.slice('acct:'.length));
|
||||||
const host = acct.host ? toPuny(acct.host) : null;
|
const host = toPunyNullable(acct.host);
|
||||||
const username = toPuny(acct.username);
|
const username = toPuny(acct.username);
|
||||||
|
|
||||||
if (host === null) {
|
if (host === null) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { Emojis } from '../../../../../models';
|
import { Emojis } from '../../../../../models';
|
||||||
import { toPuny } from '../../../../../misc/convert-host';
|
import { toPunyNullable } from '../../../../../misc/convert-host';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
@ -23,7 +23,7 @@ export const meta = {
|
|||||||
|
|
||||||
export default define(meta, async (ps) => {
|
export default define(meta, async (ps) => {
|
||||||
const emojis = await Emojis.find({
|
const emojis = await Emojis.find({
|
||||||
host: ps.host ? toPuny(ps.host) : null
|
host: toPunyNullable(ps.host)
|
||||||
});
|
});
|
||||||
|
|
||||||
return emojis.map(e => ({
|
return emojis.map(e => ({
|
||||||
|
@ -124,7 +124,7 @@ export default define(meta, async (ps, user) => {
|
|||||||
|
|
||||||
// Increment votes count
|
// Increment votes count
|
||||||
const index = ps.choice + 1; // In SQL, array index is 1 based
|
const index = ps.choice + 1; // In SQL, array index is 1 based
|
||||||
await Polls.query(`UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE noteId = '${poll.noteId}'`);
|
await Polls.query(`UPDATE poll SET votes[${index}] = votes[${index}] + 1 WHERE "noteId" = '${poll.noteId}'`);
|
||||||
|
|
||||||
publishNoteStream(note.id, 'pollVoted', {
|
publishNoteStream(note.id, 'pollVoted', {
|
||||||
choice: ps.choice,
|
choice: ps.choice,
|
||||||
|
@ -4,7 +4,7 @@ import define from '../../define';
|
|||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { Users, Followings } from '../../../../models';
|
import { Users, Followings } from '../../../../models';
|
||||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||||
import { toPuny } from '../../../../misc/convert-host';
|
import { toPunyNullable } from '../../../../misc/convert-host';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
@ -66,7 +66,7 @@ export const meta = {
|
|||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, async (ps, me) => {
|
||||||
const user = await Users.findOne(ps.userId != null
|
const user = await Users.findOne(ps.userId != null
|
||||||
? { id: ps.userId }
|
? { id: ps.userId }
|
||||||
: { usernameLower: ps.username!.toLowerCase(), host: toPuny(ps.host!) });
|
: { usernameLower: ps.username!.toLowerCase(), host: toPunyNullable(ps.host) });
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new ApiError(meta.errors.noSuchUser);
|
throw new ApiError(meta.errors.noSuchUser);
|
||||||
|
@ -4,7 +4,7 @@ import define from '../../define';
|
|||||||
import { ApiError } from '../../error';
|
import { ApiError } from '../../error';
|
||||||
import { Users, Followings } from '../../../../models';
|
import { Users, Followings } from '../../../../models';
|
||||||
import { makePaginationQuery } from '../../common/make-pagination-query';
|
import { makePaginationQuery } from '../../common/make-pagination-query';
|
||||||
import { toPuny } from '../../../../misc/convert-host';
|
import { toPunyNullable } from '../../../../misc/convert-host';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
desc: {
|
desc: {
|
||||||
@ -66,7 +66,7 @@ export const meta = {
|
|||||||
export default define(meta, async (ps, me) => {
|
export default define(meta, async (ps, me) => {
|
||||||
const user = await Users.findOne(ps.userId != null
|
const user = await Users.findOne(ps.userId != null
|
||||||
? { id: ps.userId }
|
? { id: ps.userId }
|
||||||
: { usernameLower: ps.username!.toLowerCase(), host: toPuny(ps.host!) });
|
: { usernameLower: ps.username!.toLowerCase(), host: toPunyNullable(ps.host) });
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new ApiError(meta.errors.noSuchUser);
|
throw new ApiError(meta.errors.noSuchUser);
|
||||||
|
@ -10,7 +10,7 @@ import { genId } from '../../../misc/gen-id';
|
|||||||
import { usersChart } from '../../../services/chart';
|
import { usersChart } from '../../../services/chart';
|
||||||
import { User } from '../../../models/entities/user';
|
import { User } from '../../../models/entities/user';
|
||||||
import { UserKeypair } from '../../../models/entities/user-keypair';
|
import { UserKeypair } from '../../../models/entities/user-keypair';
|
||||||
import { toPuny } from '../../../misc/convert-host';
|
import { toPunyNullable } from '../../../misc/convert-host';
|
||||||
import { UserProfile } from '../../../models/entities/user-profile';
|
import { UserProfile } from '../../../models/entities/user-profile';
|
||||||
import { getConnection } from 'typeorm';
|
import { getConnection } from 'typeorm';
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ export default async (ctx: Koa.BaseContext) => {
|
|||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
username: username,
|
username: username,
|
||||||
usernameLower: username.toLowerCase(),
|
usernameLower: username.toLowerCase(),
|
||||||
host: host ? toPuny(host) : null,
|
host: toPunyNullable(host),
|
||||||
token: secret,
|
token: secret,
|
||||||
isAdmin: config.autoAdmin && usersCount === 0,
|
isAdmin: config.autoAdmin && usersCount === 0,
|
||||||
}));
|
}));
|
||||||
|
Reference in New Issue
Block a user