Skip to content

Commit

Permalink
Fix #7212 (#7215)
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Feb 19, 2021
1 parent 7a8ae8a commit 399685c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/remote/activitypub/models/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { extractApHashtags } from './tag';
import { apLogger } from '../logger';
import { Note } from '../../../models/entities/note';
import { updateUsertags } from '../../../services/update-hashtag';
import { Users, UserNotePinings, Instances, DriveFiles, Followings, UserProfiles, UserPublickeys } from '../../../models';
import { Users, Instances, DriveFiles, Followings, UserProfiles, UserPublickeys } from '../../../models';
import { User, IRemoteUser } from '../../../models/entities/user';
import { Emoji } from '../../../models/entities/emoji';
import { UserNotePining } from '../../../models/entities/user-note-pinings';
Expand Down Expand Up @@ -435,18 +435,19 @@ export async function updateFeatured(userId: User['id']) {
.slice(0, 5)
.map(item => limit(() => resolveNote(item, resolver))));

// delete
await UserNotePinings.delete({ userId: user.id });

// とりあえずidを別の時間で生成して順番を維持
let td = 0;
for (const note of featuredNotes.filter(note => note != null)) {
td -= 1000;
UserNotePinings.save({
id: genId(new Date(Date.now() + td)),
createdAt: new Date(),
userId: user.id,
noteId: note!.id
} as UserNotePining);
}
await getConnection().transaction(async transactionalEntityManager => {
await transactionalEntityManager.delete(UserNotePining, { userId: user.id });

// とりあえずidを別の時間で生成して順番を維持
let td = 0;
for (const note of featuredNotes.filter(note => note != null)) {
td -= 1000;
transactionalEntityManager.insert(UserNotePining, {
id: genId(new Date(Date.now() + td)),
createdAt: new Date(),
userId: user.id,
noteId: note!.id
});
}
});
}

0 comments on commit 399685c

Please sign in to comment.