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;
|
||||
|
||||
@Column("boolean", {
|
||||
default: true,
|
||||
})
|
||||
public injectFeaturedNote: boolean;
|
||||
|
||||
@Column("boolean", {
|
||||
default: true,
|
||||
})
|
||||
|
|
|
@ -480,7 +480,6 @@ export const UserRepository = db.getRepository(User).extend({
|
|||
? {
|
||||
avatarId: user.avatarId,
|
||||
bannerId: user.bannerId,
|
||||
injectFeaturedNote: profile!.injectFeaturedNote,
|
||||
receiveAnnouncementEmail: profile!.receiveAnnouncementEmail,
|
||||
alwaysMarkNsfw: profile!.alwaysMarkNsfw,
|
||||
autoSensitive: profile!.autoSensitive,
|
||||
|
|
|
@ -359,11 +359,6 @@ export const packedMeDetailedOnlySchema = {
|
|||
optional: false,
|
||||
format: "id",
|
||||
},
|
||||
injectFeaturedNote: {
|
||||
type: "boolean",
|
||||
nullable: true,
|
||||
optional: false,
|
||||
},
|
||||
receiveAnnouncementEmail: {
|
||||
type: "boolean",
|
||||
nullable: true,
|
||||
|
@ -434,11 +429,6 @@ export const packedMeDetailedOnlySchema = {
|
|||
nullable: false,
|
||||
optional: false,
|
||||
},
|
||||
hasUnreadChannel: {
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
optional: false,
|
||||
},
|
||||
hasUnreadNotification: {
|
||||
type: "boolean",
|
||||
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,
|
||||
autoSensitive: profile.autoSensitive,
|
||||
carefulBot: profile.carefulBot,
|
||||
injectFeaturedNote: profile.injectFeaturedNote,
|
||||
receiveAnnouncementEmail: profile.receiveAnnouncementEmail,
|
||||
mutedWords: profile.mutedWords,
|
||||
mutedInstances: profile.mutedInstances,
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import RE2 from "re2";
|
||||
import * as mfm from "mfm-js";
|
||||
import { publishMainStream, publishUserEvent } from "@/services/stream.js";
|
||||
import {publishMainStream, publishUserEvent} from "@/services/stream.js";
|
||||
import acceptAllFollowRequests from "@/services/following/requests/accept-all.js";
|
||||
import { publishToFollowers } from "@/services/i/update.js";
|
||||
import { extractCustomEmojisFromMfm } from "@/misc/extract-custom-emojis-from-mfm.js";
|
||||
import { extractHashtags } from "@/misc/extract-hashtags.js";
|
||||
import { updateUsertags } from "@/services/update-hashtag.js";
|
||||
import { Users, DriveFiles, UserProfiles, Pages } from "@/models/index.js";
|
||||
import type { User } from "@/models/entities/user.js";
|
||||
import type { UserProfile } from "@/models/entities/user-profile.js";
|
||||
import { notificationTypes } from "@/types.js";
|
||||
import { normalizeForSearch } from "@/misc/normalize-for-search.js";
|
||||
import { langmap } from "@/misc/langmap.js";
|
||||
import { ApiError } from "../../error.js";
|
||||
import {publishToFollowers} from "@/services/i/update.js";
|
||||
import {extractCustomEmojisFromMfm} from "@/misc/extract-custom-emojis-from-mfm.js";
|
||||
import {extractHashtags} from "@/misc/extract-hashtags.js";
|
||||
import {updateUsertags} from "@/services/update-hashtag.js";
|
||||
import {DriveFiles, Pages, UserProfiles, Users} from "@/models/index.js";
|
||||
import type {User} from "@/models/entities/user.js";
|
||||
import type {UserProfile} from "@/models/entities/user-profile.js";
|
||||
import {notificationTypes} from "@/types.js";
|
||||
import {normalizeForSearch} from "@/misc/normalize-for-search.js";
|
||||
import {langmap} from "@/misc/langmap.js";
|
||||
import {ApiError} from "../../error.js";
|
||||
import define from "../../define.js";
|
||||
|
||||
export const meta = {
|
||||
|
@ -106,7 +106,6 @@ export const paramDef = {
|
|||
isBot: { type: "boolean" },
|
||||
isCat: { type: "boolean" },
|
||||
speakAsCat: { type: "boolean" },
|
||||
injectFeaturedNote: { type: "boolean" },
|
||||
receiveAnnouncementEmail: { type: "boolean" },
|
||||
alwaysMarkNsfw: { type: "boolean" },
|
||||
autoSensitive: { type: "boolean" },
|
||||
|
@ -193,8 +192,6 @@ export default define(meta, paramDef, async (ps, _user, token) => {
|
|||
profileUpdates.preventAiLearning = ps.preventAiLearning;
|
||||
if (typeof ps.isCat === "boolean") updates.isCat = ps.isCat;
|
||||
if (typeof ps.speakAsCat === "boolean") updates.speakAsCat = ps.speakAsCat;
|
||||
if (typeof ps.injectFeaturedNote === "boolean")
|
||||
profileUpdates.injectFeaturedNote = ps.injectFeaturedNote;
|
||||
if (typeof ps.receiveAnnouncementEmail === "boolean")
|
||||
profileUpdates.receiveAnnouncementEmail = ps.receiveAnnouncementEmail;
|
||||
if (typeof ps.alwaysMarkNsfw === "boolean")
|
||||
|
|
|
@ -1,39 +1,29 @@
|
|||
import * as fs from "node:fs";
|
||||
|
||||
import { v4 as uuid } from "uuid";
|
||||
import {v4 as uuid} from "uuid";
|
||||
|
||||
import type S3 from "aws-sdk/clients/s3.js";
|
||||
import sharp from "sharp";
|
||||
import { IsNull } from "typeorm";
|
||||
import { publishMainStream, publishDriveStream } from "@/services/stream.js";
|
||||
import { fetchMeta } from "@/misc/fetch-meta.js";
|
||||
import { contentDisposition } from "@/misc/content-disposition.js";
|
||||
import { getFileInfo } from "@/misc/get-file-info.js";
|
||||
import {
|
||||
DriveFiles,
|
||||
DriveFolders,
|
||||
Users,
|
||||
Instances,
|
||||
UserProfiles,
|
||||
} from "@/models/index.js";
|
||||
import { DriveFile } from "@/models/entities/drive-file.js";
|
||||
import type { IRemoteUser, User } from "@/models/entities/user.js";
|
||||
import {
|
||||
driveChart,
|
||||
perUserDriveChart,
|
||||
instanceChart,
|
||||
} from "@/services/chart/index.js";
|
||||
import { genId } from "@/misc/gen-id.js";
|
||||
import { isDuplicateKeyValueError } from "@/misc/is-duplicate-key-value-error.js";
|
||||
import { FILE_TYPE_BROWSERSAFE } from "@/const.js";
|
||||
import { IdentifiableError } from "@/misc/identifiable-error.js";
|
||||
import { getS3 } from "./s3.js";
|
||||
import { InternalStorage } from "./internal-storage.js";
|
||||
import type { IImage } from "./image-processor.js";
|
||||
import { convertSharpToWebp } from "./image-processor.js";
|
||||
import { driveLogger } from "./logger.js";
|
||||
import { GenerateVideoThumbnail } from "./generate-video-thumbnail.js";
|
||||
import { deleteFile } from "./delete-file.js";
|
||||
import {IsNull} from "typeorm";
|
||||
import {publishDriveStream, publishMainStream} from "@/services/stream.js";
|
||||
import {fetchMeta} from "@/misc/fetch-meta.js";
|
||||
import {contentDisposition} from "@/misc/content-disposition.js";
|
||||
import {getFileInfo} from "@/misc/get-file-info.js";
|
||||
import {DriveFiles, DriveFolders, UserProfiles, Users,} from "@/models/index.js";
|
||||
import {DriveFile} from "@/models/entities/drive-file.js";
|
||||
import type {IRemoteUser, User} from "@/models/entities/user.js";
|
||||
import {driveChart, instanceChart, perUserDriveChart,} from "@/services/chart/index.js";
|
||||
import {genId} from "@/misc/gen-id.js";
|
||||
import {isDuplicateKeyValueError} from "@/misc/is-duplicate-key-value-error.js";
|
||||
import {FILE_TYPE_BROWSERSAFE} from "@/const.js";
|
||||
import {IdentifiableError} from "@/misc/identifiable-error.js";
|
||||
import {getS3} from "./s3.js";
|
||||
import {InternalStorage} from "./internal-storage.js";
|
||||
import type {IImage} from "./image-processor.js";
|
||||
import {convertSharpToWebp} from "./image-processor.js";
|
||||
import {driveLogger} from "./logger.js";
|
||||
import {GenerateVideoThumbnail} from "./generate-video-thumbnail.js";
|
||||
import {deleteFile} from "./delete-file.js";
|
||||
|
||||
const logger = driveLogger.createSubLogger("register", "yellow");
|
||||
|
||||
|
|
Loading…
Reference in New Issue