This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@ -9,7 +9,7 @@ export async function injectPromo(timeline: Note[], user?: User | null) {
// TODO: readやexpireフィルタはクエリ側でやる
const reads = user ? await PromoReads.find({
userId: user.id
userId: user.id,
}) : [];
let promos = await PromoNotes.find();

View File

@ -24,7 +24,7 @@ export async function readUserMessagingMessage(
if (messageIds.length === 0) return;
const messages = await MessagingMessages.find({
id: In(messageIds)
id: In(messageIds),
});
for (const message of messages) {
@ -38,9 +38,9 @@ export async function readUserMessagingMessage(
id: In(messageIds),
userId: otherpartyId,
recipientId: userId,
isRead: false
isRead: false,
}, {
isRead: true
isRead: true,
});
// Publish event
@ -66,7 +66,7 @@ export async function readGroupMessagingMessage(
// check joined
const joining = await UserGroupJoinings.findOne({
userId: userId,
userGroupId: groupId
userGroupId: groupId,
});
if (joining == null) {
@ -74,7 +74,7 @@ export async function readGroupMessagingMessage(
}
const messages = await MessagingMessages.find({
id: In(messageIds)
id: In(messageIds),
});
const reads: MessagingMessage['id'][] = [];
@ -86,7 +86,7 @@ export async function readGroupMessagingMessage(
// Update document
await MessagingMessages.createQueryBuilder().update()
.set({
reads: (() => `array_append("reads", '${joining.userId}')`) as any
reads: (() => `array_append("reads", '${joining.userId}')`) as any,
})
.where('id = :id', { id: message.id })
.execute();
@ -97,7 +97,7 @@ export async function readGroupMessagingMessage(
// Publish event
publishGroupMessagingStream(groupId, 'read', {
ids: reads,
userId: userId
userId: userId,
});
publishMessagingIndexStream(userId, 'read', reads);

View File

@ -11,9 +11,9 @@ export async function readNotification(
// Update documents
await Notifications.update({
id: In(notificationIds),
isRead: false
isRead: false,
}, {
isRead: true
isRead: true,
});
post(userId);
@ -27,9 +27,9 @@ export async function readNotificationByQuery(
await Notifications.update({
...query,
notifieeId: userId,
isRead: false
isRead: false,
}, {
isRead: true
isRead: true,
});
post(userId);

View File

@ -14,7 +14,7 @@ export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
// SEE: https://github.com/koajs/koa/issues/974
// When using a SSL proxy it should be configured to add the "X-Forwarded-Proto: https" header
secure: config.url.startsWith('https'),
httpOnly: false
httpOnly: false,
});
//#endregion
@ -22,7 +22,7 @@ export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
} else {
ctx.body = {
id: user.id,
i: user.token
i: user.token,
};
ctx.status = 200;
}
@ -35,7 +35,7 @@ export default function(ctx: Koa.Context, user: ILocalUser, redirect = false) {
userId: user.id,
ip: ctx.ip,
headers: ctx.headers,
success: true
success: true,
});
// Publish signin event

View File

@ -54,14 +54,14 @@ export async function signup(opts: {
modulusLength: 4096,
publicKeyEncoding: {
type: 'spki',
format: 'pem'
format: 'pem',
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
cipher: undefined,
passphrase: undefined
}
passphrase: undefined,
},
} as any, (err, publicKey, privateKey) =>
err ? rej(err) : res([publicKey, privateKey])
));
@ -72,7 +72,7 @@ export async function signup(opts: {
await getConnection().transaction(async transactionalEntityManager => {
const exist = await transactionalEntityManager.findOne(User, {
usernameLower: username.toLowerCase(),
host: null
host: null,
});
if (exist) throw new Error(' the username is already used');
@ -92,7 +92,7 @@ export async function signup(opts: {
await transactionalEntityManager.save(new UserKeypair({
publicKey: keyPair[0],
privateKey: keyPair[1],
userId: account.id
userId: account.id,
}));
await transactionalEntityManager.save(new UserProfile({