Compare commits

...

38 Commits

Author SHA1 Message Date
Chloe Kudryavtsev 811d5cd0d7 Merge pull request 'deliver Delete activities to all known instances' (#198) from deliver-delete-everyone into main
Reviewed-on: FoundKeyGang/FoundKey#198
2022-10-16 13:46:23 +00:00
Chloe Kudryavtsev d762143b89 backend: fixup missing deadTime and incorrect import 2022-10-16 09:32:01 -04:00
Chloe Kudryavtsev 21c1e5c06c backend: simplify suspended and dead queries
This should also have better latency due to being a single query.
Furthermore, it's no longer a linear scan, since host is indexed.
Would be cool to simplify it further to a single query for blocks also...
Why exactly are blocks not in the db?
2022-10-16 09:22:05 -04:00
Chloe Kudryavtsev 91a4f38871 backend: add automatic dead instance detection
It works by having a day-long cache of
"when did we last successfully communicate with this instance?"
Anything over a specified threshold (1 month) will act as though the instance
is suspended - all outgoing jobs are dropped on processing.
The day-long cache is in place because the ordering is necessarily a
linear scan.
Once an instance comes back online, we will detect that is the case as soon as
we receive an activity from them (which will update the "last communicated at")
field.

Potential future TODOs:
* Improve the caching system, it's actually pretty inefficient as it is.
  CacheBox with a call override?
* Think of ways to make it not-a-linear-scan, since the instances table can get
  pretty big. It's around 4500 on toast cafe.

ChangeLog: Added
2022-10-16 12:16:04 +00:00
Johann150 756ecbb1f7
fix type error 2022-10-16 04:20:11 +02:00
Johann150 b431471fd1
update SECURITY.md 2022-10-16 00:28:00 +02:00
Johann150 48023a0814
add link to external CSS snippets 2022-10-14 17:11:06 +02:00
Johann150 8721e8844a
client: fix vue warning
> Invalid prop: type check failed for prop "modelValue". Expected String | Number, got Null
2022-10-14 16:55:37 +02:00
Johann150 4b98677141
client: add aliases for beverage box emoji
Every time I want to use it I had to figure out it's called a
"beverage box". And that happened often because I follow Tlapka.
2022-10-14 15:11:47 +02:00
Johann150 177f34b02e
client: remove unused ref 2022-10-12 20:59:26 +02:00
Johann150 79c70c1017
allow to export only selected emoji
Changelog: Added
2022-10-12 01:50:14 +02:00
Johann150 cb0b14ba2d
backend: allow to export only specific emoji 2022-10-12 01:49:53 +02:00
Johann150 7ea6deb19b
client: only show emoji as selected in select mode
When exiting select mode and emoji are selected, the green border was
still being displayed even after exiting select mode again.
2022-10-12 01:48:57 +02:00
Johann150 6d0cfe42f2
client: make hard coded strings in emoji admin panel internationalized
Changelog: Fixed
2022-10-12 01:36:53 +02:00
Johann150 7cd11e7afd
fix function name 2022-10-11 21:26:20 +02:00
Johann150 0b8fa2665c
use DISTINCT instead of GROUP BY
This should have better performance for large recordsets.

Ref: FoundKeyGang/FoundKey#198 (comment)
2022-10-11 20:15:59 +02:00
Johann150 421b42d07d
backend: send delete activity to all known instances
closes FoundKeyGang/FoundKey#190

Changelog: Added
2022-10-11 19:32:26 +02:00
Norm 9a503273fb Merge pull request 'refactor meta API endpoint' (#196) from refactor/api/meta into main 2022-10-11 17:20:51 +00:00
Norm 20a6140e9a Merge pull request 'backend: Cleanup prelude directory' (#199) from backend-cleanup-prelude into main
Reviewed-on: FoundKeyGang/FoundKey#199
2022-10-11 14:47:40 +00:00
Norm c29e24c103 client: Fix reports not showing in control panel
Closes: FoundKeyGang/FoundKey#194
Changelog: Fixed
2022-10-11 14:45:24 +00:00
Chloe Kudryavtsev 6d58d5ed3b fixup: muted-renotes review round 1 2022-10-11 10:42:39 +00:00
Chloe Kudryavtsev 897658c188 import publishUserEvent in mute renote APIs 2022-10-11 10:42:39 +00:00
Chloe Kudryavtsev 590a8b98d9 fixup renoteMuting stream filter being overzealous 2022-10-11 10:42:39 +00:00
Chloe Kudryavtsev dd5100d124 add streaming events for renotemuting and blocking 2022-10-11 10:42:39 +00:00
Chloe Kudryavtsev 3d9df839a5 add down-migration for renote mutes 2022-10-11 10:42:39 +00:00
Hélène c414f24a2c feat: per-user renote muting
Changelog: Added
2022-10-11 10:42:39 +00:00
Johann150 2c411d59f4
client: use cached instance information 2022-10-11 10:46:25 +02:00
Michcio 60600729df
backend: Fix import of sanitize-html
I'm not sure how it managed to work so far, but the function is the default
export, using the namespace like a function should not have worked,
maybe something under the hood was correcting it back
2022-10-11 10:41:50 +02:00
Norm 683b0cfa82
backend: remove unused prelude modules
Much of these modules are no longer used in the backend. They seem to be
from before the code was organized in packages.
2022-10-11 01:53:34 -04:00
Norm c65559872b
backend: add missing return type annotation in array.ts 2022-10-11 01:51:17 -04:00
Norm 02079593d5 client: Switch to upstream browser-image-resizer version
This should reduce package install times since the pre-built version
from npmjs is used instead of having to build from source.
2022-10-11 03:28:11 +00:00
Norm e8ed254e4d
client: fix types in tab.vue 2022-10-10 22:42:17 -04:00
Norm 08c65e9797
client: auto-fix lints in tab and page-header 2022-10-10 18:55:33 -04:00
Norm 13a3581817
Merge branch 'refactor/use-null-coalesce-etc'
Reviewed-on: FoundKeyGang/FoundKey#195
2022-10-10 18:44:19 -04:00
Johann150 808c43377e
refactor: use nullish coalescing & optional chaining
Changes several places to use the afforementioned constructs in favour of
ternary expressions.
2022-10-11 00:39:27 +02:00
Johann150 8920eeb86a
ActivityPub: allow all known shared inboxes to be addressed
This is oriented on this paragraph from the AP spec:

> Additionally, if an object is addressed to the Public special collection,
> a server MAY deliver that object to all known sharedInbox endpoints
> on the network.
2022-10-11 00:27:43 +02:00
Johann150 4f9504d135
client: fetch meta via GET 2022-10-10 17:36:50 +02:00
Johann150 9022ab9f2a
backend: ignore detail parameter on meta endpoint
Also allow meta endpoint to be fetched via GET.

Changelog: Removed
2022-10-10 17:36:13 +02:00
73 changed files with 626 additions and 192 deletions

View File

@ -1,9 +1,9 @@
# Reporting Security Issues
If you discover a security issue in Misskey, please report it by sending an
email to [syuilotan@yahoo.co.jp](mailto:syuilotan@yahoo.co.jp).
If you discover a security issue in Foundkey, please report it by sending an
email to [johann@qwertqwefsday.eu](mailto:johann@qwertqwefsday.eu).
This will allow us to assess the risk, and make a fix available before we add a
bug report to the GitHub repository.
bug report to the repository.
Thanks for helping make Misskey safe for everyone.
Thanks for helping make Foundkey safe for everyone.

View File

@ -65,6 +65,8 @@ directNotes: "Direct notes"
importAndExport: "Import / Export"
import: "Import"
export: "Export"
exportAll: "Export all"
exportSelected: "Export selected"
files: "Files"
download: "Download"
driveFileDeleteConfirm: "Are you sure you want to delete the file \"{name}\"? Notes\
@ -121,6 +123,8 @@ unmarkAsSensitive: "Unmark as NSFW"
enterFileName: "Enter filename"
mute: "Mute"
unmute: "Unmute"
renoteMute: "Hide renotes"
renoteUnmute: "Show renotes"
block: "Block"
unblock: "Unblock"
suspend: "Suspend"
@ -918,6 +922,13 @@ thereIsUnresolvedAbuseReportWarning: "There are unsolved reports."
recommended: "Recommended"
check: "Check"
unlimited: "Unlimited"
selectMode: "Select multiple"
selectAll: "Select all"
setCategory: "Set category"
setTag: "Set tag"
addTag: "Add tag"
removeTag: "Remove tag"
externalCssSnippets: "Some CSS snippets for your inspiration (not managed by FoundKey)"
_emailUnavailable:
used: "This email address is already being used"
format: "The format of this email address is invalid"

View File

@ -0,0 +1,20 @@
export class addRenoteMuting1665091090561 {
constructor() {
this.name = 'addRenoteMuting1665091090561';
}
async up(queryRunner) {
await queryRunner.query(`CREATE TABLE "renote_muting" ("id" character varying(32) NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "muteeId" character varying(32) NOT NULL, "muterId" character varying(32) NOT NULL, CONSTRAINT "PK_renoteMuting_id" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE INDEX "IDX_renote_muting_createdAt" ON "muting" ("createdAt") `);
await queryRunner.query(`CREATE INDEX "IDX_renote_muting_muteeId" ON "muting" ("muteeId") `);
await queryRunner.query(`CREATE INDEX "IDX_renote_muting_muterId" ON "muting" ("muterId") `);
}
async down(queryRunner) {
await queryRunner.query(`DROP INDEX "IDX_renote_muting_createdAt"`);
await queryRunner.query(`DROP INDEX "IDX_renote_muting_muteeId"`);
await queryRunner.query(`DROP INDEX "IDX_renote_muting_muterId"`);
await queryRunner.query(`DROP TABLE "renote_muting"`);
}
}

View File

@ -22,6 +22,7 @@ import { Meta } from '@/models/entities/meta.js';
import { Following } from '@/models/entities/following.js';
import { Instance } from '@/models/entities/instance.js';
import { Muting } from '@/models/entities/muting.js';
import { RenoteMuting } from '@/models/entities/renote-muting.js';
import { SwSubscription } from '@/models/entities/sw-subscription.js';
import { Blocking } from '@/models/entities/blocking.js';
import { UserList } from '@/models/entities/user-list.js';
@ -130,6 +131,7 @@ export const entities = [
Following,
FollowRequest,
Muting,
RenoteMuting,
Blocking,
Note,
NoteFavorite,

View File

@ -16,6 +16,7 @@ import { packedDriveFileSchema } from '@/models/schema/drive-file.js';
import { packedDriveFolderSchema } from '@/models/schema/drive-folder.js';
import { packedFollowingSchema } from '@/models/schema/following.js';
import { packedMutingSchema } from '@/models/schema/muting.js';
import { packedRenoteMutingSchema } from '@/models/schema/renote-muting.js';
import { packedBlockingSchema } from '@/models/schema/blocking.js';
import { packedNoteReactionSchema } from '@/models/schema/note-reaction.js';
import { packedHashtagSchema } from '@/models/schema/hashtag.js';
@ -51,6 +52,7 @@ export const refs = {
DriveFolder: packedDriveFolderSchema,
Following: packedFollowingSchema,
Muting: packedMutingSchema,
RenoteMuting: packedRenoteMutingSchema,
Blocking: packedBlockingSchema,
Hashtag: packedHashtagSchema,
Page: packedPageSchema,

View File

@ -0,0 +1,42 @@
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
import { id } from '../id.js';
import { User } from './user.js';
@Entity()
@Index(['muterId', 'muteeId'], { unique: true })
export class RenoteMuting {
@PrimaryColumn(id())
public id: string;
@Index()
@Column('timestamp with time zone', {
comment: 'The created date of the Muting.',
})
public createdAt: Date;
@Index()
@Column({
...id(),
comment: 'The mutee user ID.',
})
public muteeId: User['id'];
@ManyToOne(type => User, {
onDelete: 'CASCADE',
})
@JoinColumn()
public mutee: User | null;
@Index()
@Column({
...id(),
comment: 'The muter user ID.',
})
public muterId: User['id'];
@ManyToOne(type => User, {
onDelete: 'CASCADE',
})
@JoinColumn()
public muter: User | null;
}

View File

@ -25,6 +25,7 @@ import { UserGroupJoining } from './entities/user-group-joining.js';
import { UserGroupInvitationRepository } from './repositories/user-group-invitation.js';
import { FollowRequestRepository } from './repositories/follow-request.js';
import { MutingRepository } from './repositories/muting.js';
import { RenoteMutingRepository } from './repositories/renote-muting.js';
import { BlockingRepository } from './repositories/blocking.js';
import { NoteReactionRepository } from './repositories/note-reaction.js';
import { NotificationRepository } from './repositories/notification.js';
@ -95,6 +96,7 @@ export const DriveFolders = (DriveFolderRepository);
export const Notifications = (NotificationRepository);
export const Metas = db.getRepository(Meta);
export const Mutings = (MutingRepository);
export const RenoteMutings = (RenoteMutingRepository);
export const Blockings = (BlockingRepository);
export const SwSubscriptions = db.getRepository(SwSubscription);
export const Hashtags = (HashtagRepository);

View File

@ -0,0 +1,31 @@
import { db } from '@/db/postgre.js';
import { Packed } from '@/misc/schema.js';
import { RenoteMuting } from '@/models/entities/renote-muting.js';
import { User } from '@/models/entities/user.js';
import { awaitAll } from '@/prelude/await-all.js';
import { Users } from '../index.js';
export const RenoteMutingRepository = db.getRepository(RenoteMuting).extend({
async pack(
src: RenoteMuting['id'] | RenoteMuting,
me?: { id: User['id'] } | null | undefined,
): Promise<Packed<'RenoteMuting'>> {
const muting = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src });
return await awaitAll({
id: muting.id,
createdAt: muting.createdAt.toISOString(),
muteeId: muting.muteeId,
mutee: Users.pack(muting.muteeId, me, {
detail: true,
}),
});
},
packMany(
mutings: any[],
me: { id: User['id'] },
) {
return Promise.all(mutings.map(x => this.pack(x, me)));
},
});

View File

@ -10,7 +10,7 @@ import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js';
import { Cache } from '@/misc/cache.js';
import { db } from '@/db/postgre.js';
import { Instance } from '../entities/instance.js';
import { Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, UserProfiles, UserSecurityKeys, UserGroupJoinings, Pages, Announcements, AnnouncementReads, AntennaNotes, ChannelFollowings, Instances, DriveFiles } from '../index.js';
import { Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, RenoteMutings, UserProfiles, UserSecurityKeys, UserGroupJoinings, Pages, Announcements, AnnouncementReads, AntennaNotes, ChannelFollowings, Instances, DriveFiles } from '../index.js';
const userInstanceCache = new Cache<Instance | null>(1000 * 60 * 60 * 3);
@ -112,6 +112,13 @@ export const UserRepository = db.getRepository(User).extend({
},
take: 1,
}).then(n => n > 0),
isRenoteMuted: RenoteMutings.count({
where: {
muterId: me,
muteeId: target,
},
take: 1,
}).then(n => n > 0),
});
},
@ -412,6 +419,7 @@ export const UserRepository = db.getRepository(User).extend({
isBlocking: relation.isBlocking,
isBlocked: relation.isBlocked,
isMuted: relation.isMuted,
isRenoteMuted: relation.isRenoteMuted,
} : {}),
} as Promiseable<Packed<'User'>> as Promiseable<IsMeAndIsUserDetailed<ExpectsMe, D>>;

View File

@ -0,0 +1,26 @@
export const packedRenoteMutingSchema = {
type: 'object',
properties: {
id: {
type: 'string',
optional: false, nullable: false,
format: 'id',
example: 'xxxxxxxxxx',
},
createdAt: {
type: 'string',
optional: false, nullable: false,
format: 'date-time',
},
muteeId: {
type: 'string',
optional: false, nullable: false,
format: 'id',
},
mutee: {
type: 'object',
optional: false, nullable: false,
ref: 'UserDetailed',
},
},
} as const;

View File

@ -263,6 +263,10 @@ export const packedUserDetailedNotMeOnlySchema = {
type: 'boolean',
nullable: false, optional: true,
},
isRenoteMuted: {
type: 'boolean',
nullable: false, optional: true,
},
//#endregion
},
} as const;

View File

@ -84,7 +84,7 @@ export function groupOn<T, S>(f: (x: T) => S, xs: T[]): T[][] {
return groupBy((a, b) => f(a) === f(b), xs);
}
export function groupByX<T>(collections: T[], keySelector: (x: T) => string) {
export function groupByX<T>(collections: T[], keySelector: (x: T) => string): Record<string, T[]> {
return collections.reduce((obj: Record<string, T[]>, item: T) => {
const key = keySelector(item);
if (!Object.prototype.hasOwnProperty.call(obj, key)) {

View File

@ -1,3 +0,0 @@
export function gcd(a: number, b: number): number {
return b === 0 ? a : gcd(b, a % b);
}

View File

@ -1,20 +0,0 @@
export interface IMaybe<T> {
isJust(): this is IJust<T>;
}
export interface IJust<T> extends IMaybe<T> {
get(): T;
}
export function just<T>(value: T): IJust<T> {
return {
isJust: () => true,
get: () => value,
};
}
export function nothing<T>(): IMaybe<T> {
return {
isJust: () => false,
};
}

View File

@ -1,15 +0,0 @@
export function concat(xs: string[]): string {
return xs.join('');
}
export function capitalize(s: string): string {
return toUpperCase(s.charAt(0)) + toLowerCase(s.slice(1));
}
export function toUpperCase(s: string): string {
return s.toUpperCase();
}
export function toLowerCase(s: string): string {
return s.toLowerCase();
}

View File

@ -131,9 +131,10 @@ export function createDeleteDriveFilesJob(user: ThinUser) {
});
}
export function createExportCustomEmojisJob(user: ThinUser) {
export function createExportCustomEmojisJob(user: ThinUser, ids: string[] | undefined) {
return dbQueue.add('exportCustomEmojis', {
user,
ids,
}, {
removeOnComplete: true,
removeOnFail: true,

View File

@ -3,7 +3,7 @@ import archiver from 'archiver';
import Bull from 'bull';
import { format as dateFormat } from 'date-fns';
import mime from 'mime-types';
import { IsNull } from 'typeorm';
import { In, IsNull } from 'typeorm';
import config from '@/config/index.js';
import { createTemp, createTempDir } from '@/misc/create-temp.js';
import { downloadUrl } from '@/misc/download-url.js';
@ -50,6 +50,7 @@ export async function exportCustomEmojis(job: Bull.Job, done: () => void): Promi
const customEmojis = await Emojis.find({
where: {
host: IsNull(),
...(job.data.ids ? { id: In(job.data.ids) } : {}),
},
order: {
id: 'ASC',

View File

@ -12,34 +12,32 @@ import { Cache } from '@/misc/cache.js';
import { Instance } from '@/models/entities/instance.js';
import { StatusError } from '@/misc/fetch.js';
import { DeliverJobData } from '@/queue/types.js';
import { LessThan } from 'typeorm';
import { DAY } from '@/const.js';
const logger = new Logger('deliver');
let latest: string | null = null;
const suspendedHostsCache = new Cache<Instance[]>(1000 * 60 * 60);
const deadThreshold = 30 * DAY;
export default async (job: Bull.Job<DeliverJobData>) => {
const { host } = new URL(job.data.to);
const puny = toPuny(host);
// ブロックしてたら中断
const meta = await fetchMeta();
if (meta.blockedHosts.includes(toPuny(host))) {
if (meta.blockedHosts.includes(puny)) {
return 'skip (blocked)';
}
// isSuspendedなら中断
let suspendedHosts = suspendedHostsCache.get(null);
if (suspendedHosts == null) {
suspendedHosts = await Instances.find({
where: {
isSuspended: true,
},
});
suspendedHostsCache.set(null, suspendedHosts);
}
if (suspendedHosts.map(x => x.host).includes(toPuny(host))) {
return 'skip (suspended)';
const deadTime = new Date(Date.now() - deadThreshold);
const isSuspendedOrDead = await Instances.countBy([
{ host: puny, isSuspended: true },
{ host: puny, lastCommunicatedAt: LessThan(deadTime) },
]);
if (isSuspendedOrDead) {
return 'skip (suspended or dead)';
}
try {

View File

@ -8,6 +8,10 @@ interface IRecipe {
type: string;
}
interface IEveryoneRecipe extends IRecipe {
type: 'Everyone';
}
interface IFollowersRecipe extends IRecipe {
type: 'Followers';
}
@ -17,6 +21,9 @@ interface IDirectRecipe extends IRecipe {
to: IRemoteUser;
}
const isEveryone = (recipe: any): recipe is IEveryoneRecipe =>
recipe.type === 'Everyone';
const isFollowers = (recipe: any): recipe is IFollowersRecipe =>
recipe.type === 'Followers';
@ -63,6 +70,13 @@ export default class DeliverManager {
this.addRecipe(recipe);
}
/**
* Add recipe to send this activity to all known sharedInboxes
*/
public addEveryone() {
this.addRecipe({ type: 'Everyone' } as IEveryoneRecipe);
}
/**
* Add recipe
* @param recipe Recipe
@ -82,9 +96,26 @@ export default class DeliverManager {
/*
build inbox list
Process follower recipes first to avoid duplication when processing
direct recipes later.
Processing order matters to avoid duplication.
*/
if (this.recipes.some(r => isEveryone(r))) {
// deliver to all of known network
const sharedInboxes = await Users.createQueryBuilder('users')
.select('users.sharedInbox', 'sharedInbox')
// so we don't have to make our inboxes Set work as hard
.distinct(true)
// can't deliver to unknown shared inbox
.where('users.sharedInbox IS NOT NULL')
// don't deliver to ourselves
.andWhere('users.host IS NOT NULL')
.getRawMany();
for (const inbox of sharedInboxes) {
inboxes.add(inbox.sharedInbox);
}
}
if (this.recipes.some(r => isFollowers(r))) {
// followers deliver
// TODO: SELECT DISTINCT ON ("followerSharedInbox") "followerSharedInbox" みたいな問い合わせにすればよりパフォーマンス向上できそう

View File

@ -0,0 +1,22 @@
import { Brackets, SelectQueryBuilder } from 'typeorm';
import { User } from '@/models/entities/user.js';
import { RenoteMutings } from '@/models/index.js';
export function generateMutedRenotesQuery(q: SelectQueryBuilder<any>, me: { id: User['id'] }): void {
const mutingQuery = RenoteMutings.createQueryBuilder('renote_muting')
.select('renote_muting.muteeId')
.where('renote_muting.muterId = :muterId', { muterId: me.id });
q.andWhere(new Brackets(qb => {
qb
.where(new Brackets(qb => {
qb.where('note.renoteId IS NOT NULL');
qb.andWhere('note.text IS NULL');
qb.andWhere(`note.userId NOT IN (${ mutingQuery.getQuery() })`);
}))
.orWhere('note.renoteId IS NULL')
.orWhere('note.text IS NOT NULL');
}));
q.setParameters(mutingQuery.getParameters());
}

View File

@ -214,6 +214,9 @@ import * as ep___miauth_genToken from './endpoints/miauth/gen-token.js';
import * as ep___mute_create from './endpoints/mute/create.js';
import * as ep___mute_delete from './endpoints/mute/delete.js';
import * as ep___mute_list from './endpoints/mute/list.js';
import * as ep___renote_mute_create from './endpoints/renote-mute/create.js';
import * as ep___renote_mute_delete from './endpoints/renote-mute/delete.js';
import * as ep___renote_mute_list from './endpoints/renote-mute/list.js';
import * as ep___my_apps from './endpoints/my/apps.js';
import * as ep___notes from './endpoints/notes.js';
import * as ep___notes_children from './endpoints/notes/children.js';
@ -521,6 +524,9 @@ const eps = [
['mute/create', ep___mute_create],
['mute/delete', ep___mute_delete],
['mute/list', ep___mute_list],
['renote-mute/create', ep___renote_mute_create],
['renote-mute/delete', ep___renote_mute_delete],
['renote-mute/list', ep___renote_mute_list],
['my/apps', ep___my_apps],
['notes', ep___notes],
['notes/children', ep___notes_children],

View File

@ -87,4 +87,6 @@ export default define(meta, paramDef, async (ps, user) => {
return await Users.pack(blockee.id, blocker, {
detail: true,
});
publishUserEvent(user.id, 'block', blockee);
});

View File

@ -83,4 +83,6 @@ export default define(meta, paramDef, async (ps, user) => {
return await Users.pack(blockee.id, blocker, {
detail: true,
});
publishUserEvent(user.id, 'unblock', blockee);
});

View File

@ -56,7 +56,7 @@ export default define(meta, paramDef, async (ps, user) => {
id: genId(),
createdAt: new Date(),
name: ps.name,
parentId: parent !== null ? parent.id : null,
parentId: parent?.id,
userId: user.id,
}).then(x => DriveFolders.findOneByOrFail(x.identifiers[0]));

View File

@ -13,11 +13,19 @@ export const meta = {
export const paramDef = {
type: 'object',
properties: {},
properties: {
ids: {
description: 'Specific emoji IDs to be exported. Non-local emoji will be ignored. If not provided, all local emoji will be exported.',
type: 'array',
items: { type: 'string' },
minItems: 1,
uniqueItems: true,
},
},
required: [],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
createExportCustomEmojisJob(user);
createExportCustomEmojisJob(user, ps.ids);
});

View File

@ -10,6 +10,9 @@ export const meta = {
requireCredential: false,
allowGet: true,
cacheSec: 60,
res: {
type: 'object',
optional: false, nullable: false,
@ -253,7 +256,12 @@ export const meta = {
export const paramDef = {
type: 'object',
properties: {
detail: { type: 'boolean', default: true },
detail: {
deprecated: true,
description: 'This parameter is ignored. You will always get all details (as if it was `true`).',
type: 'boolean',
default: true,
},
},
required: [],
} as const;
@ -276,7 +284,7 @@ export default define(meta, paramDef, async (ps, me) => {
},
});
const response: any = {
return {
maintainerName: instance.maintainerName,
maintainerEmail: instance.maintainerEmail,
@ -317,21 +325,16 @@ export default define(meta, paramDef, async (ps, me) => {
translatorAvailable: instance.deeplAuthKey != null,
...(ps.detail ? {
pinnedPages: instance.pinnedPages,
pinnedClipId: instance.pinnedClipId,
cacheRemoteFiles: instance.cacheRemoteFiles,
requireSetup: (await Users.countBy({
host: IsNull(),
})) === 0,
} : {}),
};
pinnedPages: instance.pinnedPages,
pinnedClipId: instance.pinnedClipId,
cacheRemoteFiles: instance.cacheRemoteFiles,
requireSetup: (await Users.countBy({
host: IsNull(),
})) === 0,
if (ps.detail) {
const proxyAccount = instance.proxyAccountId ? await Users.pack(instance.proxyAccountId).catch(() => null) : null;
proxyAccountName: instance.proxyAccountId ? (await Users.pack(instance.proxyAccountId).catch(() => null))?.username : null,
response.proxyAccountName = proxyAccount ? proxyAccount.username : null;
response.features = {
features: {
registration: !instance.disableRegistration,
localTimeLine: !instance.disableLocalTimeline,
globalTimeLine: !instance.disableGlobalTimeline,
@ -345,8 +348,6 @@ export default define(meta, paramDef, async (ps, me) => {
discord: instance.enableDiscordIntegration,
serviceWorker: instance.enableServiceWorker,
miauth: true,
};
}
return response;
},
};
});

View File

@ -8,6 +8,7 @@ import { generateMutedUserQuery } from '../../common/generate-muted-user-query.j
import { generateRepliesQuery } from '../../common/generate-replies-query.js';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
import { generateMutedRenotesQuery } from '../../common/generated-muted-renote-query.js';
export const meta = {
tags: ['notes'],
@ -79,6 +80,7 @@ export default define(meta, paramDef, async (ps, user) => {
generateMutedUserQuery(query, user);
generateMutedNoteQuery(query, user);
generateBlockedUserQuery(query, user);
generateMutedRenotesQuery(query, user);
}
if (ps.withFiles) {

View File

@ -11,6 +11,7 @@ import { generateRepliesQuery } from '../../common/generate-replies-query.js';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
import { generateChannelQuery } from '../../common/generate-channel-query.js';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
import { generateMutedRenotesQuery } from '../../common/generated-muted-renote-query.js';
export const meta = {
tags: ['notes'],
@ -93,6 +94,7 @@ export default define(meta, paramDef, async (ps, user) => {
generateMutedUserQuery(query, user);
generateMutedNoteQuery(query, user);
generateBlockedUserQuery(query, user);
generateMutedRenotesQuery(query, user);
if (ps.includeMyRenotes === false) {
query.andWhere(new Brackets(qb => {

View File

@ -11,6 +11,7 @@ import { generateRepliesQuery } from '../../common/generate-replies-query.js';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
import { generateChannelQuery } from '../../common/generate-channel-query.js';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
import { generateMutedRenotesQuery } from '../../common/generated-muted-renote-query.js';
export const meta = {
tags: ['notes'],
@ -86,6 +87,7 @@ export default define(meta, paramDef, async (ps, user) => {
if (user) generateMutedUserQuery(query, user);
if (user) generateMutedNoteQuery(query, user);
if (user) generateBlockedUserQuery(query, user);
if (user) generateMutedRenotesQuery(query, user);
if (ps.withFiles) {
query.andWhere('note.fileIds != \'{}\'');

View File

@ -9,6 +9,7 @@ import { generateRepliesQuery } from '../../common/generate-replies-query.js';
import { generateMutedNoteQuery } from '../../common/generate-muted-note-query.js';
import { generateChannelQuery } from '../../common/generate-channel-query.js';
import { generateBlockedUserQuery } from '../../common/generate-block-query.js';
import { generateMutedRenotesQuery } from '../../common/generated-muted-renote-query.js';
export const meta = {
tags: ['notes'],
@ -85,6 +86,7 @@ export default define(meta, paramDef, async (ps, user) => {
generateMutedUserQuery(query, user);
generateMutedNoteQuery(query, user);
generateBlockedUserQuery(query, user);
generateMutedRenotesQuery(query, user);
if (ps.includeMyRenotes === false) {
query.andWhere(new Brackets(qb => {

View File

@ -0,0 +1,79 @@
import { genId } from '@/misc/gen-id.js';
import { RenoteMutings } from '@/models/index.js';
import { RenoteMuting } from '@/models/entities/renote-muting.js';
import { publishUserEvent } from '@/services/stream.js';
import define from '../../define.js';
import { ApiError } from '../../error.js';
import { getUser } from '../../common/getters.js';
export const meta = {
tags: ['account'],
requireCredential: true,
kind: 'write:mutes',
errors: {
noSuchUser: {
message: 'No such user.',
code: 'NO_SUCH_USER',
id: '6fef56f3-e765-4957-88e5-c6f65329b8a5',
},
muteeIsYourself: {
message: 'Mutee is yourself.',
code: 'MUTEE_IS_YOURSELF',
id: 'a4619cb2-5f23-484b-9301-94c903074e10',
},
alreadyMuting: {
message: 'You are already muting that user.',
code: 'ALREADY_MUTING',
id: '7e7359cb-160c-4956-b08f-4d1c653cd007',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const muter = user;
// Check if the mutee is yourself
if (user.id === ps.userId) {
throw new ApiError(meta.errors.muteeIsYourself);
}
// Get mutee
const mutee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
throw e;
});
// Check if already muting
const exist = await RenoteMutings.findOneBy({
muterId: muter.id,
muteeId: mutee.id,
});
if (exist != null) {
throw new ApiError(meta.errors.alreadyMuting);
}
// Create mute
await RenoteMutings.insert({
id: genId(),
createdAt: new Date(),
muterId: muter.id,
muteeId: mutee.id,
} as RenoteMuting);
publishUserEvent(user.id, 'muteRenote', mutee);
});

View File

@ -0,0 +1,74 @@
import { RenoteMutings } from '@/models/index.js';
import { publishUserEvent } from '@/services/stream.js';
import define from '../../define.js';
import { ApiError } from '../../error.js';
import { getUser } from '../../common/getters.js';
export const meta = {
tags: ['account'],
requireCredential: true,
kind: 'write:mutes',
errors: {
noSuchUser: {
message: 'No such user.',
code: 'NO_SUCH_USER',
id: 'b851d00b-8ab1-4a56-8b1b-e24187cb48ef',
},
muteeIsYourself: {
message: 'Mutee is yourself.',
code: 'MUTEE_IS_YOURSELF',
id: 'f428b029-6b39-4d48-a1d2-cc1ae6dd5cf9',
},
notMuting: {
message: 'You are not muting that user.',
code: 'NOT_MUTING',
id: '5467d020-daa9-4553-81e1-135c0c35a96d',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, user) => {
const muter = user;
// Check if the mutee is yourself
if (user.id === ps.userId) {
throw new ApiError(meta.errors.muteeIsYourself);
}
// Get mutee
const mutee = await getUser(ps.userId).catch(e => {
if (e.id === '15348ddd-432d-49c2-8a5a-8069753becff') throw new ApiError(meta.errors.noSuchUser);
throw e;
});
// Check not muting
const exist = await RenoteMutings.findOneBy({
muterId: muter.id,
muteeId: mutee.id,
});
if (exist == null) {
throw new ApiError(meta.errors.notMuting);
}
// Delete mute
await RenoteMutings.delete({
id: exist.id,
});
publishUserEvent(user.id, 'unmuteRenote', mutee);
});

View File

@ -0,0 +1,43 @@
import { RenoteMutings } from '@/models/index.js';
import define from '../../define.js';
import { makePaginationQuery } from '../../common/make-pagination-query.js';
export const meta = {
tags: ['account'],
requireCredential: true,
kind: 'read:mutes',
res: {
type: 'array',
optional: false, nullable: false,
items: {
type: 'object',
optional: false, nullable: false,
ref: 'RenoteMuting',
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
limit: { type: 'integer', minimum: 1, maximum: 100, default: 30 },
sinceId: { type: 'string', format: 'misskey:id' },
untilId: { type: 'string', format: 'misskey:id' },
},
required: [],
} as const;
// eslint-disable-next-line import/no-default-export
export default define(meta, paramDef, async (ps, me) => {
const query = makePaginationQuery(RenoteMutings.createQueryBuilder('muting'), ps.sinceId, ps.untilId)
.andWhere('muting.muterId = :meId', { meId: me.id });
const mutings = await query
.take(ps.limit)
.getMany();
return await RenoteMutings.packMany(mutings, me);
});

View File

@ -47,6 +47,10 @@ export const meta = {
type: 'boolean',
optional: false, nullable: false,
},
isRenoteMuted: {
type: 'boolean',
optional: false, nullable: false,
},
},
},
{
@ -88,6 +92,10 @@ export const meta = {
type: 'boolean',
optional: false, nullable: false,
},
isRenoteMuted: {
type: 'boolean',
optional: false, nullable: false,
},
},
},
},

View File

@ -1,4 +1,4 @@
import * as sanitizeHtml from 'sanitize-html';
import sanitizeHtml from 'sanitize-html';
import config from '@/config/index.js';
import { publishAdminStream } from '@/services/stream.js';
import { AbuseUserReports, Users } from '@/models/index.js';

View File

@ -30,6 +30,10 @@ export default abstract class Channel {
return this.connection.muting;
}
protected get renoteMuting() {
return this.connection.renoteMuting;
}
protected get blocking() {
return this.connection.blocking;
}

View File

@ -31,6 +31,7 @@ export default class extends Channel {
if (isUserRelated(note, this.muting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.blocking)) return;
if (note.renote && this.renoteMuting.has(note.userId)) return;
this.connection.cacheNote(note);

View File

@ -34,6 +34,7 @@ export default class extends Channel {
if (isUserRelated(note, this.muting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.blocking)) return;
if (note.renote && this.renoteMuting.has(note.userId)) return;
this.connection.cacheNote(note);

View File

@ -43,6 +43,7 @@ export default class extends Channel {
if (isUserRelated(note, this.muting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.blocking)) return;
if (note.renote && this.renoteMuting.has(note.userId)) return;
// 流れてきたNoteがミュートすべきNoteだったら無視する
// TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある)

View File

@ -32,6 +32,7 @@ export default class extends Channel {
if (isUserRelated(note, this.muting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.blocking)) return;
if (note.renote && this.renoteMuting.has(note.userId)) return;
this.connection.cacheNote(note);

View File

@ -41,6 +41,7 @@ export default class extends Channel {
if (isUserRelated(note, this.muting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.blocking)) return;
if (note.renote && this.renoteMuting.has(note.userId)) return;
// 流れてきたNoteがミュートすべきNoteだったら無視する
// TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある)

View File

@ -49,6 +49,7 @@ export default class extends Channel {
if (isUserRelated(note, this.muting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.blocking)) return;
if (note.renote && this.renoteMuting.has(note.userId)) return;
// 流れてきたNoteがミュートすべきNoteだったら無視する
// TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある)

View File

@ -40,6 +40,7 @@ export default class extends Channel {
if (isUserRelated(note, this.muting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.blocking)) return;
if (note.renote && this.renoteMuting.has(note.userId)) return;
// 流れてきたNoteがミュートすべきNoteだったら無視する
// TODO: 将来的には、単にMutedNoteテーブルにレコードがあるかどうかで判定したい(以下の理由により難しそうではある)

View File

@ -55,6 +55,7 @@ export default class extends Channel {
if (isUserRelated(note, this.muting)) return;
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
if (isUserRelated(note, this.blocking)) return;
if (note.renote && this.renoteMuting.has(note.userId)) return;
this.send('note', note);
}

View File

@ -3,7 +3,7 @@ import * as websocket from 'websocket';
import readNote from '@/services/note/read.js';
import { User } from '@/models/entities/user.js';
import { Channel as ChannelModel } from '@/models/entities/channel.js';
import { Followings, Mutings, UserProfiles, ChannelFollowings, Blockings } from '@/models/index.js';
import { Followings, Mutings, RenoteMutings, UserProfiles, ChannelFollowings, Blockings } from '@/models/index.js';
import { AccessToken } from '@/models/entities/access-token.js';
import { UserProfile } from '@/models/entities/user-profile.js';
import { publishChannelStream, publishGroupMessagingStream, publishMessagingStream } from '@/services/stream.js';
@ -22,6 +22,7 @@ export default class Connection {
public userProfile?: UserProfile | null;
public following: Set<User['id']> = new Set();
public muting: Set<User['id']> = new Set();
public renoteMuting: Set<User['id']> = new Set();
public blocking: Set<User['id']> = new Set(); // "被"blocking
public followingChannels: Set<ChannelModel['id']> = new Set();
public token?: AccessToken;
@ -56,6 +57,7 @@ export default class Connection {
if (this.user) {
this.updateFollowing();
this.updateMuting();
this.updateRenoteMuting();
this.updateBlocking();
this.updateFollowingChannels();
this.updateUserProfile();
@ -82,7 +84,21 @@ export default class Connection {
this.muting.delete(data.body.id);
break;
// TODO: block events
case 'block':
this.blocking.add(data.body.id);
break;
case 'unblock':
this.blocking.delete(data.body.id);
break;
case 'muteRenote':
this.renoteMuting.add(data.body.id);
break;
case 'unmuteRenote':
this.renoteMuting.delete(data.body.id);
break;
case 'followChannel':
this.followingChannels.add(data.body.id);
@ -333,6 +349,17 @@ export default class Connection {
this.muting = new Set<string>(mutings.map(x => x.muteeId));
}
private async updateRenoteMuting() {
const renoteMutings = await RenoteMutings.find({
where: {
muterId: this.user!.id,
},
select: ['muteeId'],
});
this.renoteMuting = new Set<string>(renoteMutings.map(x => x.muteeId));
}
private async updateBlocking() { // ここでいうBlockingは被Blockingの意
const blockings = await Blockings.find({
where: {

View File

@ -44,6 +44,10 @@ export interface UserStreamTypes {
updateUserProfile: UserProfile;
mute: User;
unmute: User;
muteRenote: User;
unmuteRenote: User;
block: User;
unblock: User;
follow: Packed<'UserDetailedNotMe'>;
unfollow: Packed<'User'>;
userAdded: Packed<'User'>;

View File

@ -425,7 +425,7 @@ export async function addFile({
file.createdAt = new Date();
file.userId = user ? user.id : null;
file.userHost = user ? user.host : null;
file.folderId = folder !== null ? folder.id : null;
file.folderId = folder?.id;
file.comment = comment;
file.properties = properties;
file.blurhash = info.blurhash || null;

View File

@ -10,7 +10,7 @@ import { User, ILocalUser, IRemoteUser } from '@/models/entities/user.js';
import { Note } from '@/models/entities/note.js';
import { Notes, Users, Instances } from '@/models/index.js';
import { notesChart, perUserNotesChart, instanceChart } from '@/services/chart/index.js';
import { deliverToFollowers, deliverToUser } from '@/remote/activitypub/deliver-manager.js';
import DeliverManager from '@/remote/activitypub/deliver-manager.js';
import { countSameRenotes } from '@/misc/count-same-renotes.js';
import { isPureRenote } from '@/misc/renote.js';
import { registerOrFetchInstanceDoc } from '../register-or-fetch-instance-doc.js';
@ -109,7 +109,7 @@ async function getMentionedRemoteUsers(note: Note): Promise<IRemoteUser[]> {
const where = [] as any[];
// mention / reply / dm
if (note.mentions > 0) {
if (note.mentions.length > 0) {
where.push({
id: In(note.mentions),
// only remote users, local users are on the server and do not need to be notified
@ -132,10 +132,22 @@ async function getMentionedRemoteUsers(note: Note): Promise<IRemoteUser[]> {
}
async function deliverToConcerned(user: { id: ILocalUser['id']; host: null; }, note: Note, content: any) {
deliverToFollowers(user, content);
deliverToRelays(user, content);
const manager = new DeliverManager(user, content);
const remoteUsers = await getMentionedRemoteUsers(note);
for (const remoteUser of remoteUsers) {
deliverToUser(user, content, remoteUser);
manager.addDirectRecipe(remoteUser);
}
if (['public', 'home', 'followers'].includes(note.visibility)) {
manager.addFollowersRecipe();
}
if (['public', 'home'].includes(note.visibility)) {
manager.addEveryone();
}
await manager.execute();
deliverToRelays(user, content);
}

View File

@ -1,18 +0,0 @@
import * as assert from 'assert';
import { just, nothing } from '../../src/prelude/maybe.js';
describe('just', () => {
it('has a value', () => {
assert.deepStrictEqual(just(3).isJust(), true);
});
it('has the inverse called get', () => {
assert.deepStrictEqual(just(3).get(), 3);
});
});
describe('nothing', () => {
it('has no value', () => {
assert.deepStrictEqual(nothing().isJust(), false);
});
});

View File

@ -21,7 +21,7 @@
"autwh": "0.1.0",
"blurhash": "1.1.5",
"broadcast-channel": "4.13.0",
"browser-image-resizer": "git+https://github.com/misskey-dev/browser-image-resizer#v2.2.1-misskey.2",
"browser-image-resizer": "2.4.1",
"chart.js": "3.8.0",
"chartjs-adapter-date-fns": "2.0.0",
"chartjs-plugin-gradient": "0.5.0",

View File

@ -9,7 +9,7 @@
@drop.stop="onDrop"
>
<i v-if="folder == null" class="fas fa-cloud"></i>
<span>{{ folder == null ? i18n.ts.drive : folder.name }}</span>
<span>{{ folder?.name ?? i18n.ts.drive }}</span>
</div>
</template>

View File

@ -1,17 +1,9 @@
<template>
<div v-if="meta" class="xfbouadm" :style="{ backgroundImage: `url(${ meta.backgroundImageUrl })` }"></div>
<div class="xfbouadm" :style="{ backgroundImage: `url(${ instance.backgroundImageUrl })` }"></div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import * as foundkey from 'foundkey-js';
import * as os from '@/os';
const meta = ref<foundkey.entities.DetailedInstanceMetadata>();
os.api('meta', { detail: true }).then(gotMeta => {
meta.value = gotMeta;
});
import { instance } from '@/instance';
</script>
<style lang="scss" scoped>

View File

@ -117,7 +117,7 @@ function showTabsPopup(ev: MouseEvent): void {
},
}));
popupMenu(menu, ev.currentTarget ?? ev.target);
};
}
function preventDrag(ev: TouchEvent): void {
ev.stopPropagation();

View File

@ -34,15 +34,15 @@ const props = withDefaults(defineProps<{
});
const self = props.url.startsWith(local);
const url = new URL(props.url);
const uri = new URL(props.url);
let el: HTMLElement | null = $ref(null);
let schema = $ref(url.protocol);
let hostname = $ref(decodePunycode(url.hostname));
let port = $ref(url.port);
let pathname = $ref(safeURIDecode(url.pathname));
let query = $ref(safeURIDecode(url.search));
let hash = $ref(safeURIDecode(url.hash));
let schema = $ref(uri.protocol);
let hostname = $ref(decodePunycode(uri.hostname));
let port = $ref(uri.port);
let pathname = $ref(safeURIDecode(uri.pathname));
let query = $ref(safeURIDecode(uri.search));
let hash = $ref(safeURIDecode(uri.hash));
let attr = $ref(self ? 'to' : 'href');
let target = $ref(self ? null : '_blank');

View File

@ -60,7 +60,7 @@ const modal = $ref<InstanceType<typeof MkModal>>();
const menu = defaultStore.state.menu;
const items = Object.keys(menuDef).filter(k => !menu.includes(k)).map(k => menuDef[k]).filter(def => def.show == null ? true : def.show).map(def => ({
const items = Object.keys(menuDef).filter(k => !menu.includes(k)).map(k => menuDef[k]).filter(def => def.show ?? true).map(def => ({
type: def.to ? 'link' : 'button',
text: i18n.ts[def.title],
icon: def.icon,

View File

@ -1,5 +1,5 @@
<template>
<div class="pxhvhrfw" v-size="{ max: [500] }">
<div v-size="{ max: [500] }" class="pxhvhrfw">
<button
v-for="option in options"
:key="option.value"
@ -17,12 +17,12 @@ const emit = defineEmits<{
(ev: 'update:modelValue', value: string): void;
}>();
const props = defineProps<{
defineProps<{
modelValue: string;
options: {
value: string;
label: string;
};
}[];
}>();
</script>

View File

@ -750,7 +750,7 @@
{ "category": "food_and_drink", "char": "🫖", "name": "teapot", "keywords": [] },
{ "category": "food_and_drink", "char": "🧋", "name": "bubble_tea", "keywords": ["tapioca"] },
{ "category": "food_and_drink", "char": "🍼", "name": "baby_bottle", "keywords": ["food", "container", "milk"] },
{ "category": "food_and_drink", "char": "🧃", "name": "beverage_box", "keywords": ["food", "drink"] },
{ "category": "food_and_drink", "char": "🧃", "name": "beverage_box", "keywords": ["food", "drink", "juice", "straw"] },
{ "category": "food_and_drink", "char": "🧉", "name": "mate", "keywords": ["food", "drink"] },
{ "category": "food_and_drink", "char": "🧊", "name": "ice_cube", "keywords": ["food"] },
{ "category": "food_and_drink", "char": "🧂", "name": "salt", "keywords": ["condiment", "shaker"] },

View File

@ -1 +1 @@
export default n => n == null ? 'N/A' : n.toLocaleString();
export default n => n?.toLocaleString() ?? 'N/A';

View File

@ -1,6 +1,6 @@
import { computed, reactive } from 'vue';
import * as foundkey from 'foundkey-js';
import { api } from '@/os';
import { apiGet } from '@/os';
// TODO: 他のタブと永続化されたstateを同期
@ -13,13 +13,7 @@ export const instance: foundkey.entities.InstanceMetadata = reactive(instanceDat
});
export async function fetchInstance(): Promise<void> {
const meta = await api('meta', {
detail: false,
});
for (const [k, v] of Object.entries(meta)) {
instance[k] = v;
}
Object.assign(instance, await apiGet('meta'));
localStorage.setItem('instance', JSON.stringify(instance));
}

View File

@ -247,7 +247,7 @@ export function inputText(props: {
input: {
type: props.type,
placeholder: props.placeholder,
default: props.default,
default: props.default ?? '',
},
}, {
done: result => {

View File

@ -4,7 +4,7 @@
<div v-show="loaded" class="mjndxjch">
<img src="https://xn--931a.moe/assets/error.jpg" class="_ghost"/>
<p><b><i class="fas fa-exclamation-triangle"></i> {{ i18n.ts.pageLoadError }}</b></p>
<p v-if="meta && (version === meta.version)">{{ i18n.ts.pageLoadErrorDescription }}</p>
<p v-if="version === instance.version">{{ i18n.ts.pageLoadErrorDescription }}</p>
<p v-else-if="serverIsDead">{{ i18n.ts.serverIsDead }}</p>
<template v-else>
<p>{{ i18n.ts.newVersionOfClientAvailable }}</p>
@ -21,6 +21,7 @@
import * as foundkey from 'foundkey-js';
import MkButton from '@/components/ui/button.vue';
import { version } from '@/config';
import { instance } from '@/instance';
import * as os from '@/os';
import { unisonReload } from '@/scripts/unison-reload';
import { i18n } from '@/i18n';
@ -34,15 +35,11 @@ withDefaults(defineProps<{
let loaded = $ref(false);
let serverIsDead = $ref(false);
let meta = $ref<foundkey.entities.LiteInstanceMetadata | null>(null);
os.api('meta', {
detail: false,
}).then(res => {
// just checking whether the server is alive or dead
os.api('ping').then(() => {
loaded = true;
serverIsDead = false;
meta = res;
localStorage.setItem('v', res.version);
}, () => {
loaded = true;
serverIsDead = true;

View File

@ -10,21 +10,22 @@
<template #label>{{ i18n.ts.search }}</template>
</MkInput>
<MkSwitch v-model="selectMode" style="margin: 8px 0;">
<template #label>Select mode</template>
<template #label>{{ i18n.ts.selectMode }}</template>
</MkSwitch>
<div v-if="selectMode" style="display: flex; gap: var(--margin); flex-wrap: wrap;">
<MkButton inline @click="selectAll">Select all</MkButton>
<MkButton inline @click="setCategoryBulk">Set category</MkButton>
<MkButton inline @click="addTagBulk">Add tag</MkButton>
<MkButton inline @click="removeTagBulk">Remove tag</MkButton>
<MkButton inline @click="setTagBulk">Set tag</MkButton>
<MkButton inline danger @click="delBulk">Delete</MkButton>
<MkButton inline @click="selectAll">{{ i18n.ts.selectAll }}</MkButton>
<MkButton inline @click="setCategoryBulk">{{ i18n.ts.setCategory }}</MkButton>
<MkButton inline @click="addTagBulk">{{ i18n.ts.addTag }}</MkButton>
<MkButton inline @click="removeTagBulk">{{ i18n.ts.removeTag }}</MkButton>
<MkButton inline @click="setTagBulk">{{ i18n.ts.setTag }}</MkButton>
<MkButton inline @click="exportSelected">{{ i18n.ts.exportSelected }}</MkButton>
<MkButton inline danger @click="delBulk">{{ i18n.ts.delete }}</MkButton>
</div>
<MkPagination ref="emojisPaginationComponent" :pagination="pagination">
<template #empty><span>{{ i18n.ts.noCustomEmojis }}</span></template>
<template #default="{items}">
<div class="ldhfsamy">
<button v-for="emoji in items" :key="emoji.id" class="emoji _panel _button" :class="{ selected: selectedEmojis.includes(emoji.id) }" @click="selectMode ? toggleSelect(emoji) : edit(emoji)">
<button v-for="emoji in items" :key="emoji.id" class="emoji _panel _button" :class="{ selected: selectMode && selectedEmojis.includes(emoji.id) }" @click="selectMode ? toggleSelect(emoji) : edit(emoji)">
<img :src="emoji.url" class="img" :alt="emoji.name"/>
<div class="body">
<div class="name _monospace">{{ emoji.name }}</div>
@ -170,7 +171,7 @@ const remoteMenu = (emoji, ev: MouseEvent) => {
const menu = (ev: MouseEvent) => {
os.popupMenu([{
icon: 'fas fa-download',
text: i18n.ts.export,
text: i18n.ts.exportAll,
action: async () => {
os.api('export-custom-emojis', {
})
@ -257,6 +258,23 @@ const setTagBulk = async () => {
emojisPaginationComponent.value.reload();
};
const exportSelected = async () => {
os.api('export-custom-emojis', {
ids: selectedEmojis.value,
})
.then(() => {
os.alert({
type: 'info',
text: i18n.ts.exportRequested,
});
}).catch((err) => {
os.alert({
type: 'error',
text: err.message,
});
});
};
const delBulk = async () => {
const { canceled } = await os.confirm({
type: 'warning',

View File

@ -1,6 +1,6 @@
<template>
<div>
<XDrive ref="drive" @cd="x => folder = x"/>
<XDrive @cd="x => folder = x"/>
</div>
</template>

View File

@ -5,6 +5,8 @@
<FormTextarea v-model="localCustomCss" manual-save tall class="_monospace _formBlock" style="tab-size: 2;">
<template #label>CSS</template>
</FormTextarea>
<a href="https://github.com/JakeMBauer/Misskey-Extras/tree/master/custom-css">{{ i18n.ts.externalCssSnippets }}</a>
</div>
</template>

View File

@ -85,7 +85,7 @@ async function edit(type) {
type: 'enum',
enum: soundsTypes.map(x => ({
value: x,
label: x == null ? i18n.ts.none : x,
label: x ?? i18n.ts.none,
})),
label: i18n.ts.sound,
default: sounds.value[type].type,

View File

@ -1,5 +1,5 @@
<template>
<div v-if="meta" class="rsqzvsbo">
<div class="rsqzvsbo">
<div class="top">
<MkFeaturedPhotos class="bg"/>
<XTimeline class="tl"/>
@ -19,12 +19,12 @@
<div class="fg">
<h1>
<!-- 背景色によってはロゴが見えなくなるのでとりあえず無効に -->
<!-- <img class="logo" v-if="meta.logoImageUrl" :src="meta.logoImageUrl"><span v-else class="text">{{ instanceName }}</span> -->
<!-- <img class="logo" v-if="instance.logoImageUrl" :src="instance.logoImageUrl"><span v-else class="text">{{ instanceName }}</span> -->
<span class="text">{{ instanceName }}</span>
</h1>
<div class="about">
<!-- eslint-disable-next-line vue/no-v-html -->
<div class="desc" v-html="meta.description || i18n.ts.headlineMisskey"></div>
<div class="desc" v-html="instance.description || i18n.ts.headlineMisskey"></div>
</div>
<div class="action">
<MkButton inline rounded gradate data-cy-signup style="margin-right: 12px;" @click="signup()">{{ i18n.ts.signup }}</MkButton>
@ -58,17 +58,13 @@ import { host, instanceName } from '@/config';
import * as os from '@/os';
import number from '@/filters/number';
import { i18n } from '@/i18n';
import { instance } from '@/instance';
let meta = $ref();
let stats = $ref();
let tags = $ref();
let onlineUsersCount = $ref();
let instances = $ref();
os.api('meta', { detail: true }).then(_meta => {
meta = _meta;
});
os.api('stats').then(_stats => {
stats = _stats;
});

View File

@ -1,8 +1,6 @@
<template>
<div v-if="meta">
<XSetup v-if="meta.requireSetup"/>
<XSetup v-if="instance.requireSetup"/>
<XEntrance v-else/>
</div>
</template>
<script lang="ts" setup>
@ -10,15 +8,10 @@ import { computed } from 'vue';
import XSetup from './welcome.setup.vue';
import XEntrance from './welcome.entrance.a.vue';
import { instanceName } from '@/config';
import { instance } from '@/instance';
import * as os from '@/os';
import { definePageMetadata } from '@/scripts/page-metadata';
let meta = $ref(null);
os.api('meta', { detail: true }).then(res => {
meta = res;
});
definePageMetadata(computed(() => ({
title: instanceName,
icon: null,

View File

@ -98,6 +98,14 @@ export function getUserMenu(user) {
}
}
async function toggleRenoteMute(): Promise<void> {
os.apiWithDialog(user.isRenoteMuted ? 'renote-mute/delete' : 'renote-mute/create', {
userId: user.id,
}).then(() => {
user.isRenoteMuted = !user.isRenoteMuted;
});
}
async function toggleBlock(): Promise<void> {
if (!await getConfirmed(user.isBlocking ? i18n.ts.unblockConfirm : i18n.ts.blockConfirm)) return;
@ -187,6 +195,10 @@ export function getUserMenu(user) {
if ($i && meId !== user.id) {
menu = menu.concat([null, {
icon: user.isRenoteMuted ? 'fas fa-eye' : 'fas fa-eye-slash',
text: user.isRenoteMuted ? i18n.ts.renoteUnmute : i18n.ts.renoteMute,
action: toggleRenoteMute,
}, {
icon: user.isMuted ? 'fas fa-eye' : 'fas fa-eye-slash',
text: user.isMuted ? i18n.ts.unmute : i18n.ts.mute,
action: toggleMute,

View File

@ -12,7 +12,7 @@ export function getScrollContainer(el: HTMLElement | null): HTMLElement | null {
export function getScrollPosition(el: Element | null): number {
const container = getScrollContainer(el);
return container == null ? window.scrollY : container.scrollTop;
return container?.scrollTop ?? window.scrollY;
}
export function isTopVisible(el: Element | null): boolean {

View File

@ -80,7 +80,6 @@ const announcements = {
let showMenu = $ref(false);
let isDesktop = $ref(window.innerWidth >= DESKTOP_THRESHOLD);
let narrow = $ref(window.innerWidth < 1280);
let meta = $ref();
const keymap = $computed(() => {
return {
@ -94,10 +93,6 @@ const keymap = $computed(() => {
const root = $computed(() => mainRouter.currentRoute.value.name === 'index');
os.api('meta', { detail: true }).then(res => {
meta = res;
});
function signin() {
os.popup(XSigninDialog, {
autoSet: true,

View File

@ -411,6 +411,9 @@ export type Endpoints = {
'mute/create': { req: TODO; res: TODO; };
'mute/delete': { req: { userId: User['id'] }; res: null; };
'mute/list': { req: TODO; res: TODO; };
'renote-mute/create': { req: TODO; res: TODO; };
'renote-mute/delete': { req: { userId: User['id'] }; res: null; };
'renote-mute/list': { req: TODO; res: TODO; };
'my/apps': { req: TODO; res: TODO; };
'notes': { req: { limit?: number; sinceId?: Note['id']; untilId?: Note['id']; }; res: Note[]; };
'notes/children': { req: { noteId: Note['id']; limit?: number; sinceId?: Note['id']; untilId?: Note['id']; }; res: Note[]; };

View File

@ -53,6 +53,7 @@ export type UserDetailed = UserLite & {
isLocked: boolean;
isModerator: boolean;
isMuted: boolean;
isRenoteMuted: boolean;
isSilenced: boolean;
isSuspended: boolean;
lang: string | null;

View File

@ -3989,10 +3989,10 @@ __metadata:
languageName: node
linkType: hard
"browser-image-resizer@git+https://github.com/misskey-dev/browser-image-resizer#v2.2.1-misskey.2":
version: 2.2.1-misskey.2
resolution: "browser-image-resizer@https://github.com/misskey-dev/browser-image-resizer.git#commit=a58834f5fe2af9f9f31ff115121aef3de6f9d416"
checksum: eb5ddfe7f6a2de96340ef420df9be03a75f2bfd8f568a60be22cc8f2ccdcb754105b7799cf706c09add3f9d82b7ce1c6f963842f80a85f234b26ef6bf1b8da09
"browser-image-resizer@npm:2.4.1":
version: 2.4.1
resolution: "browser-image-resizer@npm:2.4.1"
checksum: b2f705696f2643240880314926f976b473452a7ef1335dcc888993281c8a8e57eba2cda255965843526511a206b722be0031df770bd31ddd944bc8730521ddb6
languageName: node
linkType: hard
@ -4699,7 +4699,7 @@ __metadata:
autwh: 0.1.0
blurhash: 1.1.5
broadcast-channel: 4.13.0
browser-image-resizer: "git+https://github.com/misskey-dev/browser-image-resizer#v2.2.1-misskey.2"
browser-image-resizer: 2.4.1
chart.js: 3.8.0
chartjs-adapter-date-fns: 2.0.0
chartjs-plugin-gradient: 0.5.0