Removed the featured note injection dead code
ci/woodpecker/push/ociImageTag Pipeline was successful
Details
ci/woodpecker/push/ociImageTag Pipeline was successful
Details
This commit is contained in:
parent
0409015c96
commit
a1d47e709a
|
@ -179,11 +179,6 @@ export class UserProfile {
|
||||||
})
|
})
|
||||||
public carefulBot: boolean;
|
public carefulBot: boolean;
|
||||||
|
|
||||||
@Column("boolean", {
|
|
||||||
default: true,
|
|
||||||
})
|
|
||||||
public injectFeaturedNote: boolean;
|
|
||||||
|
|
||||||
@Column("boolean", {
|
@Column("boolean", {
|
||||||
default: true,
|
default: true,
|
||||||
})
|
})
|
||||||
|
|
|
@ -480,7 +480,6 @@ export const UserRepository = db.getRepository(User).extend({
|
||||||
? {
|
? {
|
||||||
avatarId: user.avatarId,
|
avatarId: user.avatarId,
|
||||||
bannerId: user.bannerId,
|
bannerId: user.bannerId,
|
||||||
injectFeaturedNote: profile!.injectFeaturedNote,
|
|
||||||
receiveAnnouncementEmail: profile!.receiveAnnouncementEmail,
|
receiveAnnouncementEmail: profile!.receiveAnnouncementEmail,
|
||||||
alwaysMarkNsfw: profile!.alwaysMarkNsfw,
|
alwaysMarkNsfw: profile!.alwaysMarkNsfw,
|
||||||
autoSensitive: profile!.autoSensitive,
|
autoSensitive: profile!.autoSensitive,
|
||||||
|
|
|
@ -359,11 +359,6 @@ export const packedMeDetailedOnlySchema = {
|
||||||
optional: false,
|
optional: false,
|
||||||
format: "id",
|
format: "id",
|
||||||
},
|
},
|
||||||
injectFeaturedNote: {
|
|
||||||
type: "boolean",
|
|
||||||
nullable: true,
|
|
||||||
optional: false,
|
|
||||||
},
|
|
||||||
receiveAnnouncementEmail: {
|
receiveAnnouncementEmail: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
@ -434,11 +429,6 @@ export const packedMeDetailedOnlySchema = {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
optional: false,
|
optional: false,
|
||||||
},
|
},
|
||||||
hasUnreadChannel: {
|
|
||||||
type: "boolean",
|
|
||||||
nullable: false,
|
|
||||||
optional: false,
|
|
||||||
},
|
|
||||||
hasUnreadNotification: {
|
hasUnreadNotification: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
nullable: false,
|
nullable: false,
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
import rndstr from "rndstr";
|
|
||||||
import type { Note } from "@/models/entities/note.js";
|
|
||||||
import type { User } from "@/models/entities/user.js";
|
|
||||||
import { Notes, UserProfiles, NoteReactions } from "@/models/index.js";
|
|
||||||
import { generateMutedUserQuery } from "./generate-muted-user-query.js";
|
|
||||||
import { generateBlockedUserQuery } from "./generate-block-query.js";
|
|
||||||
|
|
||||||
// TODO: リアクション、Renote、返信などをしたノートは除外する
|
|
||||||
|
|
||||||
export async function injectFeatured(timeline: Note[], user?: User | null) {
|
|
||||||
if (timeline.length < 5) return;
|
|
||||||
|
|
||||||
if (user) {
|
|
||||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
|
||||||
if (!profile.injectFeaturedNote) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const max = 30;
|
|
||||||
const day = 1000 * 60 * 60 * 24 * 3; // 3日前まで
|
|
||||||
|
|
||||||
const query = Notes.createQueryBuilder("note")
|
|
||||||
.addSelect("note.score")
|
|
||||||
.where("note.userHost IS NULL")
|
|
||||||
.andWhere("note.score > 0")
|
|
||||||
.andWhere("note.createdAt > :date", { date: new Date(Date.now() - day) })
|
|
||||||
.andWhere(`note.visibility = 'public'`)
|
|
||||||
.innerJoinAndSelect("note.user", "user");
|
|
||||||
|
|
||||||
if (user) {
|
|
||||||
query.andWhere("note.userId != :userId", { userId: user.id });
|
|
||||||
|
|
||||||
generateMutedUserQuery(query, user);
|
|
||||||
generateBlockedUserQuery(query, user);
|
|
||||||
|
|
||||||
const reactionQuery = NoteReactions.createQueryBuilder("reaction")
|
|
||||||
.select("reaction.noteId")
|
|
||||||
.where("reaction.userId = :userId", { userId: user.id });
|
|
||||||
|
|
||||||
query.andWhere(`note.id NOT IN (${reactionQuery.getQuery()})`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const notes = await query.orderBy("note.score", "DESC").take(max).getMany();
|
|
||||||
|
|
||||||
if (notes.length === 0) return;
|
|
||||||
|
|
||||||
// Pick random one
|
|
||||||
const featured = notes[Math.floor(Math.random() * notes.length)];
|
|
||||||
|
|
||||||
(featured as any)._featuredId_ = rndstr("a-z0-9", 8);
|
|
||||||
|
|
||||||
// Inject featured
|
|
||||||
timeline.splice(3, 0, featured);
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
import rndstr from "rndstr";
|
|
||||||
import type { Note } from "@/models/entities/note.js";
|
|
||||||
import type { User } from "@/models/entities/user.js";
|
|
||||||
import { PromoReads, PromoNotes, Notes, Users } from "@/models/index.js";
|
|
||||||
|
|
||||||
export async function injectPromo(timeline: Note[], user?: User | null) {
|
|
||||||
if (timeline.length < 5) return;
|
|
||||||
|
|
||||||
// TODO: readやexpireフィルタはクエリ側でやる
|
|
||||||
|
|
||||||
const reads = user
|
|
||||||
? await PromoReads.findBy({
|
|
||||||
userId: user.id,
|
|
||||||
})
|
|
||||||
: [];
|
|
||||||
|
|
||||||
let promos = await PromoNotes.find();
|
|
||||||
|
|
||||||
promos = promos.filter((n) => n.expiresAt.getTime() > Date.now());
|
|
||||||
promos = promos.filter((n) => !reads.map((r) => r.noteId).includes(n.noteId));
|
|
||||||
|
|
||||||
if (promos.length === 0) return;
|
|
||||||
|
|
||||||
// Pick random promo
|
|
||||||
const promo = promos[Math.floor(Math.random() * promos.length)];
|
|
||||||
|
|
||||||
const note = await Notes.findOneByOrFail({ id: promo.noteId });
|
|
||||||
|
|
||||||
// Join
|
|
||||||
note.user = await Users.findOneByOrFail({ id: note.userId });
|
|
||||||
|
|
||||||
(note as any)._prId_ = rndstr("a-z0-9", 8);
|
|
||||||
|
|
||||||
// Inject promo
|
|
||||||
timeline.splice(3, 0, note);
|
|
||||||
}
|
|
|
@ -57,7 +57,6 @@ export default define(meta, paramDef, async (ps, me) => {
|
||||||
alwaysMarkNsfw: profile.alwaysMarkNsfw,
|
alwaysMarkNsfw: profile.alwaysMarkNsfw,
|
||||||
autoSensitive: profile.autoSensitive,
|
autoSensitive: profile.autoSensitive,
|
||||||
carefulBot: profile.carefulBot,
|
carefulBot: profile.carefulBot,
|
||||||
injectFeaturedNote: profile.injectFeaturedNote,
|
|
||||||
receiveAnnouncementEmail: profile.receiveAnnouncementEmail,
|
receiveAnnouncementEmail: profile.receiveAnnouncementEmail,
|
||||||
mutedWords: profile.mutedWords,
|
mutedWords: profile.mutedWords,
|
||||||
mutedInstances: profile.mutedInstances,
|
mutedInstances: profile.mutedInstances,
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { publishToFollowers } from "@/services/i/update.js";
|
||||||
import {extractCustomEmojisFromMfm} from "@/misc/extract-custom-emojis-from-mfm.js";
|
import {extractCustomEmojisFromMfm} from "@/misc/extract-custom-emojis-from-mfm.js";
|
||||||
import {extractHashtags} from "@/misc/extract-hashtags.js";
|
import {extractHashtags} from "@/misc/extract-hashtags.js";
|
||||||
import {updateUsertags} from "@/services/update-hashtag.js";
|
import {updateUsertags} from "@/services/update-hashtag.js";
|
||||||
import { Users, DriveFiles, UserProfiles, Pages } from "@/models/index.js";
|
import {DriveFiles, Pages, UserProfiles, Users} from "@/models/index.js";
|
||||||
import type {User} from "@/models/entities/user.js";
|
import type {User} from "@/models/entities/user.js";
|
||||||
import type {UserProfile} from "@/models/entities/user-profile.js";
|
import type {UserProfile} from "@/models/entities/user-profile.js";
|
||||||
import {notificationTypes} from "@/types.js";
|
import {notificationTypes} from "@/types.js";
|
||||||
|
@ -106,7 +106,6 @@ export const paramDef = {
|
||||||
isBot: { type: "boolean" },
|
isBot: { type: "boolean" },
|
||||||
isCat: { type: "boolean" },
|
isCat: { type: "boolean" },
|
||||||
speakAsCat: { type: "boolean" },
|
speakAsCat: { type: "boolean" },
|
||||||
injectFeaturedNote: { type: "boolean" },
|
|
||||||
receiveAnnouncementEmail: { type: "boolean" },
|
receiveAnnouncementEmail: { type: "boolean" },
|
||||||
alwaysMarkNsfw: { type: "boolean" },
|
alwaysMarkNsfw: { type: "boolean" },
|
||||||
autoSensitive: { type: "boolean" },
|
autoSensitive: { type: "boolean" },
|
||||||
|
@ -193,8 +192,6 @@ export default define(meta, paramDef, async (ps, _user, token) => {
|
||||||
profileUpdates.preventAiLearning = ps.preventAiLearning;
|
profileUpdates.preventAiLearning = ps.preventAiLearning;
|
||||||
if (typeof ps.isCat === "boolean") updates.isCat = ps.isCat;
|
if (typeof ps.isCat === "boolean") updates.isCat = ps.isCat;
|
||||||
if (typeof ps.speakAsCat === "boolean") updates.speakAsCat = ps.speakAsCat;
|
if (typeof ps.speakAsCat === "boolean") updates.speakAsCat = ps.speakAsCat;
|
||||||
if (typeof ps.injectFeaturedNote === "boolean")
|
|
||||||
profileUpdates.injectFeaturedNote = ps.injectFeaturedNote;
|
|
||||||
if (typeof ps.receiveAnnouncementEmail === "boolean")
|
if (typeof ps.receiveAnnouncementEmail === "boolean")
|
||||||
profileUpdates.receiveAnnouncementEmail = ps.receiveAnnouncementEmail;
|
profileUpdates.receiveAnnouncementEmail = ps.receiveAnnouncementEmail;
|
||||||
if (typeof ps.alwaysMarkNsfw === "boolean")
|
if (typeof ps.alwaysMarkNsfw === "boolean")
|
||||||
|
|
|
@ -5,24 +5,14 @@ import { v4 as uuid } from "uuid";
|
||||||
import type S3 from "aws-sdk/clients/s3.js";
|
import type S3 from "aws-sdk/clients/s3.js";
|
||||||
import sharp from "sharp";
|
import sharp from "sharp";
|
||||||
import {IsNull} from "typeorm";
|
import {IsNull} from "typeorm";
|
||||||
import { publishMainStream, publishDriveStream } from "@/services/stream.js";
|
import {publishDriveStream, publishMainStream} from "@/services/stream.js";
|
||||||
import {fetchMeta} from "@/misc/fetch-meta.js";
|
import {fetchMeta} from "@/misc/fetch-meta.js";
|
||||||
import {contentDisposition} from "@/misc/content-disposition.js";
|
import {contentDisposition} from "@/misc/content-disposition.js";
|
||||||
import {getFileInfo} from "@/misc/get-file-info.js";
|
import {getFileInfo} from "@/misc/get-file-info.js";
|
||||||
import {
|
import {DriveFiles, DriveFolders, UserProfiles, Users,} from "@/models/index.js";
|
||||||
DriveFiles,
|
|
||||||
DriveFolders,
|
|
||||||
Users,
|
|
||||||
Instances,
|
|
||||||
UserProfiles,
|
|
||||||
} from "@/models/index.js";
|
|
||||||
import {DriveFile} from "@/models/entities/drive-file.js";
|
import {DriveFile} from "@/models/entities/drive-file.js";
|
||||||
import type {IRemoteUser, User} from "@/models/entities/user.js";
|
import type {IRemoteUser, User} from "@/models/entities/user.js";
|
||||||
import {
|
import {driveChart, instanceChart, perUserDriveChart,} from "@/services/chart/index.js";
|
||||||
driveChart,
|
|
||||||
perUserDriveChart,
|
|
||||||
instanceChart,
|
|
||||||
} from "@/services/chart/index.js";
|
|
||||||
import {genId} from "@/misc/gen-id.js";
|
import {genId} from "@/misc/gen-id.js";
|
||||||
import {isDuplicateKeyValueError} from "@/misc/is-duplicate-key-value-error.js";
|
import {isDuplicateKeyValueError} from "@/misc/is-duplicate-key-value-error.js";
|
||||||
import {FILE_TYPE_BROWSERSAFE} from "@/const.js";
|
import {FILE_TYPE_BROWSERSAFE} from "@/const.js";
|
||||||
|
|
Loading…
Reference in New Issue