Merge branch 'develop' into sw-notification-action

This commit is contained in:
tamaina 2021-02-09 20:14:05 +09:00
commit c44a29ebb7
126 changed files with 2668 additions and 1636 deletions

View file

@ -40,7 +40,7 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: U
_note.renote = await Notes.findOne(note.renoteId).then(ensure);
}
if (isMutedUserRelated(_note, mutings.map(x => x.muteeId))) {
if (isMutedUserRelated(_note, new Set<string>(mutings.map(x => x.muteeId)))) {
return;
}

View file

@ -25,7 +25,14 @@ export async function createSystemUser(username: string) {
// Start transaction
await getConnection().transaction(async transactionalEntityManager => {
account = await transactionalEntityManager.save(new User({
const exist = await transactionalEntityManager.findOne(User, {
usernameLower: username.toLowerCase(),
host: null
});
if (exist) throw new Error('the user is already exists');
account = await transactionalEntityManager.insert(User, {
id: genId(),
createdAt: new Date(),
username: username,
@ -36,24 +43,24 @@ export async function createSystemUser(username: string) {
isLocked: true,
isExplorable: false,
isBot: true,
}));
}).then(x => transactionalEntityManager.findOneOrFail(User, x.identifiers[0]));
await transactionalEntityManager.save(new UserKeypair({
await transactionalEntityManager.insert(UserKeypair, {
publicKey: keyPair.publicKey,
privateKey: keyPair.privateKey,
userId: account.id
}));
});
await transactionalEntityManager.save(new UserProfile({
await transactionalEntityManager.insert(UserProfile, {
userId: account.id,
autoAcceptFollowed: false,
password: hash,
}));
});
await transactionalEntityManager.save(new UsedUsername({
await transactionalEntityManager.insert(UsedUsername, {
createdAt: new Date(),
username: username.toLowerCase(),
}));
});
});
return account;

View file

@ -13,7 +13,9 @@ export function getS3(meta: Meta) {
secretAccessKey: meta.objectStorageSecretKey!,
region: meta.objectStorageRegion || undefined,
sslEnabled: meta.objectStorageUseSSL,
s3ForcePathStyle: !!meta.objectStorageEndpoint,
s3ForcePathStyle: !meta.objectStorageEndpoint // AWS with endPoint omitted
? false
: meta.objectStorageS3ForcePathStyle,
httpOptions: {
agent: getAgentByUrl(new URL(u), !meta.objectStorageUseProxy)
}

View file

@ -33,6 +33,7 @@ import { addNoteToAntenna } from '../add-note-to-antenna';
import { countSameRenotes } from '../../misc/count-same-renotes';
import { deliverToRelays } from '../relay';
import { Channel } from '../../models/entities/channel';
import { normalizeForSearch } from '../../misc/normalize-for-search';
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
@ -460,7 +461,7 @@ async function insertNote(user: User, data: Option, tags: string[], emojis: stri
text: data.text,
hasPoll: data.poll != null,
cw: data.cw == null ? null : data.cw,
tags: tags.map(tag => tag.toLowerCase()),
tags: tags.map(tag => normalizeForSearch(tag)),
emojis,
userId: user.id,
viaMobile: data.viaMobile!,
@ -547,7 +548,7 @@ function index(note: Note) {
index: config.elasticsearch.index || 'misskey_note',
id: note.id.toString(),
body: {
text: note.text.toLowerCase(),
text: normalizeForSearch(note.text),
userId: note.userId,
userHost: note.userHost
}

View file

@ -3,6 +3,7 @@ import { Hashtags, Users } from '../models';
import { hashtagChart } from './chart';
import { genId } from '../misc/gen-id';
import { Hashtag } from '../models/entities/hashtag';
import { normalizeForSearch } from '../misc/normalize-for-search';
export async function updateHashtags(user: User, tags: string[]) {
for (const tag of tags) {
@ -21,7 +22,7 @@ export async function updateUsertags(user: User, tags: string[]) {
}
export async function updateHashtag(user: User, tag: string, isUserAttached = false, inc = true) {
tag = tag.toLowerCase();
tag = normalizeForSearch(tag);
const index = await Hashtags.findOne({ name: tag });