Fixed 267U.pre2
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { db } from "../../db/postgre.js";
|
||||
import { Users } from "../index.js";
|
||||
import { Following } from "../entities/following.js";
|
||||
import { awaitAll } from "../../prelude/await-all.js";
|
||||
export const FollowingRepository = db.getRepository(Following).extend({
|
||||
isLocalFollower (following) {
|
||||
return following.followerHost == null;
|
||||
},
|
||||
isRemoteFollower (following) {
|
||||
return following.followerHost != null;
|
||||
},
|
||||
isLocalFollowee (following) {
|
||||
return following.followeeHost == null;
|
||||
},
|
||||
isRemoteFollowee (following) {
|
||||
return following.followeeHost != null;
|
||||
},
|
||||
async pack (src, me, opts) {
|
||||
const following = typeof src === "object" ? src : await this.findOneByOrFail({
|
||||
id: src
|
||||
});
|
||||
if (opts == null) opts = {};
|
||||
return await awaitAll({
|
||||
id: following.id,
|
||||
createdAt: following.createdAt.toISOString(),
|
||||
followeeId: following.followeeId,
|
||||
followerId: following.followerId,
|
||||
followee: opts.populateFollowee ? Users.pack(following.followee || following.followeeId, me, {
|
||||
detail: true
|
||||
}) : undefined,
|
||||
follower: opts.populateFollower ? Users.pack(following.follower || following.followerId, me, {
|
||||
detail: true
|
||||
}) : undefined
|
||||
});
|
||||
},
|
||||
packMany (followings, me, opts) {
|
||||
return Promise.all(followings.map((x)=>this.pack(x, me, opts)));
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user