mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-26 07:55:14 +00:00
wip #6441
This commit is contained in:
parent
41b491fa7c
commit
c4c20bee7c
28 changed files with 44 additions and 40 deletions
|
@ -23,7 +23,7 @@ export class NoteReaction {
|
||||||
onDelete: 'CASCADE'
|
onDelete: 'CASCADE'
|
||||||
})
|
})
|
||||||
@JoinColumn()
|
@JoinColumn()
|
||||||
public user: User | null;
|
public user?: User | null;
|
||||||
|
|
||||||
@Index()
|
@Index()
|
||||||
@Column(id())
|
@Column(id())
|
||||||
|
@ -33,7 +33,7 @@ export class NoteReaction {
|
||||||
onDelete: 'CASCADE'
|
onDelete: 'CASCADE'
|
||||||
})
|
})
|
||||||
@JoinColumn()
|
@JoinColumn()
|
||||||
public note: Note | null;
|
public note?: Note | null;
|
||||||
|
|
||||||
// TODO: 対象noteのuserIdを非正規化したい(「受け取ったリアクション一覧」のようなものを(JOIN無しで)実装したいため)
|
// TODO: 対象noteのuserIdを非正規化したい(「受け取ったリアクション一覧」のようなものを(JOIN無しで)実装したいため)
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default define(meta, async () => {
|
||||||
chars: '2-9A-HJ-NP-Z', // [0-9A-Z] w/o [01IO] (32 patterns)
|
chars: '2-9A-HJ-NP-Z', // [0-9A-Z] w/o [01IO] (32 patterns)
|
||||||
});
|
});
|
||||||
|
|
||||||
await RegistrationTickets.save({
|
await RegistrationTickets.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
code,
|
code,
|
||||||
|
|
|
@ -53,7 +53,7 @@ export default define(meta, async (ps, user) => {
|
||||||
throw new ApiError(meta.errors.alreadyPromoted);
|
throw new ApiError(meta.errors.alreadyPromoted);
|
||||||
}
|
}
|
||||||
|
|
||||||
await PromoNotes.save({
|
await PromoNotes.insert({
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
expiresAt: new Date(ps.expiresAt),
|
expiresAt: new Date(ps.expiresAt),
|
||||||
|
|
|
@ -58,7 +58,7 @@ export default define(meta, async (ps, user) => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
// Insert access token doc
|
// Insert access token doc
|
||||||
await AccessTokens.save({
|
await AccessTokens.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
lastUsedAt: now,
|
lastUsedAt: now,
|
||||||
|
|
|
@ -37,7 +37,7 @@ export default define(meta, async (ps, user) => {
|
||||||
throw new ApiError(meta.errors.noSuchChannel);
|
throw new ApiError(meta.errors.noSuchChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
await ChannelFollowings.save({
|
await ChannelFollowings.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
followerId: user.id,
|
followerId: user.id,
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default define(meta, async (ps, user) => {
|
||||||
throw new ApiError(meta.errors.alreadyClipped);
|
throw new ApiError(meta.errors.alreadyClipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
await ClipNotes.save({
|
await ClipNotes.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
clipId: clip.id
|
clipId: clip.id
|
||||||
|
|
|
@ -52,7 +52,7 @@ export default define(meta, async (ps, user) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create read
|
// Create read
|
||||||
await AnnouncementReads.save({
|
await AnnouncementReads.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
announcementId: ps.announcementId,
|
announcementId: ps.announcementId,
|
||||||
|
|
|
@ -52,7 +52,7 @@ export default define(meta, async (ps, user) => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
// Insert access token doc
|
// Insert access token doc
|
||||||
await AccessTokens.save({
|
await AccessTokens.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
lastUsedAt: now,
|
lastUsedAt: now,
|
||||||
|
|
|
@ -61,7 +61,7 @@ export default define(meta, async (ps, user) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create favorite
|
// Create favorite
|
||||||
await NoteFavorites.save({
|
await NoteFavorites.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
|
|
|
@ -68,7 +68,7 @@ export default define(meta, async (ps, user) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create like
|
// Create like
|
||||||
await PageLikes.save({
|
await PageLikes.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
pageId: page.id,
|
pageId: page.id,
|
||||||
|
|
|
@ -46,7 +46,7 @@ export default define(meta, async (ps, user) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await PromoReads.save({
|
await PromoReads.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
|
|
|
@ -58,7 +58,7 @@ export default define(meta, async (ps, user) => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
await SwSubscriptions.save({
|
await SwSubscriptions.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default define(meta, async (ps, user) => {
|
||||||
} as UserGroup);
|
} as UserGroup);
|
||||||
|
|
||||||
// Push the owner
|
// Push the owner
|
||||||
await UserGroupJoinings.save({
|
await UserGroupJoinings.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
|
|
@ -52,7 +52,7 @@ export default define(meta, async (ps, user) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push the user
|
// Push the user
|
||||||
await UserGroupJoinings.save({
|
await UserGroupJoinings.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
|
|
@ -53,7 +53,7 @@ export default async (ctx: Koa.Context) => {
|
||||||
|
|
||||||
async function fail(status?: number, failure?: { error: string }) {
|
async function fail(status?: number, failure?: { error: string }) {
|
||||||
// Append signin history
|
// Append signin history
|
||||||
await Signins.save({
|
await Signins.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
@ -198,7 +198,7 @@ export default async (ctx: Koa.Context) => {
|
||||||
|
|
||||||
const challengeId = genId();
|
const challengeId = genId();
|
||||||
|
|
||||||
await AttestationChallenges.save({
|
await AttestationChallenges.insert({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
id: challengeId,
|
id: challengeId,
|
||||||
challenge: hash(Buffer.from(challenge, 'utf-8')).toString('hex'),
|
challenge: hash(Buffer.from(challenge, 'utf-8')).toString('hex'),
|
||||||
|
|
|
@ -10,7 +10,7 @@ export async function addNoteToAntenna(antenna: Antenna, note: Note, noteUser: U
|
||||||
// 通知しない設定になっているか、自分自身の投稿なら既読にする
|
// 通知しない設定になっているか、自分自身の投稿なら既読にする
|
||||||
const read = !antenna.notify || (antenna.userId === noteUser.id);
|
const read = !antenna.notify || (antenna.userId === noteUser.id);
|
||||||
|
|
||||||
AntennaNotes.save({
|
AntennaNotes.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
antennaId: antenna.id,
|
antennaId: antenna.id,
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
|
|
|
@ -18,7 +18,7 @@ export default async function(blocker: User, blockee: User) {
|
||||||
unFollow(blockee, blocker)
|
unFollow(blockee, blocker)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await Blockings.save({
|
await Blockings.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
blockerId: blocker.id,
|
blockerId: blocker.id,
|
||||||
|
|
|
@ -22,7 +22,7 @@ export async function insertFollowingDoc(followee: User, follower: User) {
|
||||||
|
|
||||||
let alreadyFollowed = false;
|
let alreadyFollowed = false;
|
||||||
|
|
||||||
await Followings.save({
|
await Followings.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
followerId: follower.id,
|
followerId: follower.id,
|
||||||
|
|
|
@ -37,7 +37,7 @@ export async function addPinned(user: User, noteId: Note['id']) {
|
||||||
throw new IdentifiableError('23f0cf4e-59a3-4276-a91d-61a5891c1514', 'That note has already been pinned.');
|
throw new IdentifiableError('23f0cf4e-59a3-4276-a91d-61a5891c1514', 'That note has already been pinned.');
|
||||||
}
|
}
|
||||||
|
|
||||||
await UserNotePinings.save({
|
await UserNotePinings.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { ModerationLogs } from '../models';
|
||||||
import { genId } from '../misc/gen-id';
|
import { genId } from '../misc/gen-id';
|
||||||
|
|
||||||
export async function insertModerationLog(moderator: ILocalUser, type: string, info?: Record<string, any>) {
|
export async function insertModerationLog(moderator: ILocalUser, type: string, info?: Record<string, any>) {
|
||||||
await ModerationLogs.save({
|
await ModerationLogs.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
userId: moderator.id,
|
userId: moderator.id,
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { renderActivity } from '../../remote/activitypub/renderer';
|
||||||
import { deliver } from '../../queue';
|
import { deliver } from '../../queue';
|
||||||
|
|
||||||
export async function createMessage(user: User, recipientUser: User | undefined, recipientGroup: UserGroup | undefined, text: string | undefined, file: DriveFile | null, uri?: string) {
|
export async function createMessage(user: User, recipientUser: User | undefined, recipientGroup: UserGroup | undefined, text: string | undefined, file: DriveFile | null, uri?: string) {
|
||||||
const message = await MessagingMessages.save({
|
const message = {
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
fileId: file ? file.id : null,
|
fileId: file ? file.id : null,
|
||||||
|
@ -25,7 +25,9 @@ export async function createMessage(user: User, recipientUser: User | undefined,
|
||||||
isRead: false,
|
isRead: false,
|
||||||
reads: [] as any[],
|
reads: [] as any[],
|
||||||
uri
|
uri
|
||||||
} as MessagingMessage);
|
} as MessagingMessage;
|
||||||
|
|
||||||
|
await MessagingMessages.insert(message);
|
||||||
|
|
||||||
const messageObj = await MessagingMessages.pack(message);
|
const messageObj = await MessagingMessages.pack(message);
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
|
||||||
for (const u of us) {
|
for (const u of us) {
|
||||||
checkWordMute(note, { id: u.userId }, u.mutedWords).then(shouldMute => {
|
checkWordMute(note, { id: u.userId }, u.mutedWords).then(shouldMute => {
|
||||||
if (shouldMute) {
|
if (shouldMute) {
|
||||||
MutedNotes.save({
|
MutedNotes.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
userId: u.userId,
|
userId: u.userId,
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default async function(user: User, note: Note, choice: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create vote
|
// Create vote
|
||||||
await PollVotes.save({
|
await PollVotes.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
|
|
|
@ -18,17 +18,17 @@ export default async (user: User, note: Note, reaction?: string) => {
|
||||||
// TODO: cache
|
// TODO: cache
|
||||||
reaction = await toDbReaction(reaction, user.host);
|
reaction = await toDbReaction(reaction, user.host);
|
||||||
|
|
||||||
let record: NoteReaction;
|
let record: NoteReaction = {
|
||||||
|
id: genId(),
|
||||||
|
createdAt: new Date(),
|
||||||
|
noteId: note.id,
|
||||||
|
userId: user.id,
|
||||||
|
reaction
|
||||||
|
};
|
||||||
|
|
||||||
// Create reaction
|
// Create reaction
|
||||||
try {
|
try {
|
||||||
record = await NoteReactions.save({
|
await NoteReactions.insert(record);
|
||||||
id: genId(),
|
|
||||||
createdAt: new Date(),
|
|
||||||
noteId: note.id,
|
|
||||||
userId: user.id,
|
|
||||||
reaction
|
|
||||||
});
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (isDuplicateKeyValueError(e)) {
|
if (isDuplicateKeyValueError(e)) {
|
||||||
record = await NoteReactions.findOneOrFail({
|
record = await NoteReactions.findOneOrFail({
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default async function(userId: User['id'], note: Note, params: {
|
||||||
if (mute.map(m => m.muteeId).includes(note.userId)) return;
|
if (mute.map(m => m.muteeId).includes(note.userId)) return;
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
const unread = await NoteUnreads.save({
|
const unread = {
|
||||||
id: genId(),
|
id: genId(),
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
@ -25,7 +25,9 @@ export default async function(userId: User['id'], note: Note, params: {
|
||||||
isMentioned: params.isMentioned,
|
isMentioned: params.isMentioned,
|
||||||
noteChannelId: note.channelId,
|
noteChannelId: note.channelId,
|
||||||
noteUserId: note.userId,
|
noteUserId: note.userId,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
await NoteUnreads.insert(unread);
|
||||||
|
|
||||||
// 2秒経っても既読にならなかったら「未読の投稿がありますよ」イベントを発行する
|
// 2秒経っても既読にならなかったら「未読の投稿がありますよ」イベントを発行する
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default async (me: User['id'], note: Note) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await NoteWatchings.save({
|
await NoteWatchings.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
noteId: note.id,
|
noteId: note.id,
|
||||||
|
|
|
@ -86,7 +86,7 @@ export async function updateHashtag(user: User, tag: string, isUserAttached = fa
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isUserAttached) {
|
if (isUserAttached) {
|
||||||
Hashtags.save({
|
Hashtags.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
name: tag,
|
name: tag,
|
||||||
mentionedUserIds: [],
|
mentionedUserIds: [],
|
||||||
|
@ -103,7 +103,7 @@ export async function updateHashtag(user: User, tag: string, isUserAttached = fa
|
||||||
attachedRemoteUsersCount: Users.isRemoteUser(user) ? 1 : 0,
|
attachedRemoteUsersCount: Users.isRemoteUser(user) ? 1 : 0,
|
||||||
} as Hashtag);
|
} as Hashtag);
|
||||||
} else {
|
} else {
|
||||||
Hashtags.save({
|
Hashtags.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
name: tag,
|
name: tag,
|
||||||
mentionedUserIds: [user.id],
|
mentionedUserIds: [user.id],
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { fetchProxyAccount } from '../../misc/fetch-proxy-account';
|
||||||
import createFollowing from '../following/create';
|
import createFollowing from '../following/create';
|
||||||
|
|
||||||
export async function pushUserToUserList(target: User, list: UserList) {
|
export async function pushUserToUserList(target: User, list: UserList) {
|
||||||
await UserListJoinings.save({
|
await UserListJoinings.insert({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
userId: target.id,
|
userId: target.id,
|
||||||
|
|
Loading…
Reference in a new issue