Merge branch 'main' into snug.moe

This commit is contained in:
vib 2022-10-17 09:05:03 +03:00
commit a4c9ab8dd1
41 changed files with 285 additions and 231 deletions

View File

@ -11,37 +11,84 @@ Unreleased changes should not be listed in this file.
Instead, run `git shortlog --format='%h %s' --group=trailer:changelog <last tag>..` to see unreleased changes; replace `<last tag>` with the tag you wish to compare from.
If you are a contributor, please read [CONTRIBUTING.md, section "Changelog Trailer"](./CONTRIBUTING.md#changelog-trailer) on what to do instead.
## Unreleased
## 13.0.0-preview2 - 2022-10-16
### Security
- server: Update `multer` dependency to resolve [CVE-2022-24434](https://nvd.nist.gov/vuln/detail/CVE-2022-24434)
- server: Update `file-type`, `got`, and `sharp` dependencies to fix various security issues
### Added
- Client: Show instance info in ticker
- Client: Readded group pages
- Client: add re-collapsing to quoted notes
- allow to mute only renotes of a user
- allow to export only selected custom emoji
- client: improve emoji picker search
- client: Extend Emoji list
- client: show alt text in image viewer
- client: Show instance info in ticker
- client: Readded group pages
- client: add re-collapsing to quoted notes
- server: allow files storage path to be set explicitly
- server: refactor expiring data and expire signins after 60 days
- server: send delete activity to all known instances
- server: add automatic dead instance detection
### Changed
- Client: Use consistent date formatting based on language setting
- Client: Add threshold to reduce occurances of "future" timestamps
- Pages have been considerably simplified, several of the very complex features have been removed.
- foundkey-js: Sync possible endpoints from backend
- foundkey-js: update LiteInstanceMetadata fields
- meta: use parallel and incremental builds
- meta: update WORKDIR to foundkey
- meta: update dependencies
- client: consolidate about & notifications pages
- client: include renote in visibility computation
- client: make emoji amount slider more intuitive
- client: sort emojis by query similarity in fuzzy picker
- client: discard drafts that are just the default state
- client: Use consistent date formatting based on language setting
- client: Add threshold to reduce occurances of "future" timestamps
- server: mute notifications in muted threads
- server: allow for source lang to be overridden in note/translate
- server: allow redis family to be specified as a string
- server: increase image description limit to 2048 characters
- server: Pages have been considerably simplified, several of the very complex features have been removed.
Pages are now MFM only.
**For admins:** There is a migration in place to convert page contents to text, but not everything can be migrated.
You might want to check if you have any more complex pages on your instance and ask users to migrate them by hand.
Or generally advise all users to simplify their pages to only text.
### Removed
- Okteto config and Helm chart
- Client: acrylic styling
- Client: Twitter embeds, the standard URL preview is used instead.
- Promotion entities and endpoints
- Server: The configuration item `signToActivityPubGet` has been removed and will be ignored if set explicitly.
Foundkey will now work as if it was set to `true`.
### Fixed
- Client: Notifications for ended polls can now be turned off
- Client: Emoji picker should load faster now
- Server: Blocking remote accounts
- client: alt text dialog properly handles non-images
- client: Fix style scoping in MkMention
- client: default instance ticker name to instance's domain name
- client: improve error message for empty gallery posts
- client: fix default-selected reply scopes
- client: Make MFM cheatsheet interactive again
- client: Fix reports not showing in control panel
- client: make hard coded strings in emoji admin panel internationalized
- client: Notifications for ended polls can now be turned off
- client: improve emoji picker performance
- server: Blocking remote accounts
- server: fix table name used in toHtml
- server: Fix appendChildren TypeError
- server: ensure only own notifications can be marked as read
- server: render HTML mentions correctly
- server: increase requestId max size for GNU Social
- server: fix HTTP GET parameters in OpenAPI docs
- server: proper error messages for creating accounts
- server: Fix thread muting queries
- docker: add built foundkey-js files to container
- service worker: Remove fetch handler from service worker
### Security
- Server: Update `multer` dependency to resolve [CVE-2022-24434](https://nvd.nist.gov/vuln/detail/CVE-2022-24434)
- Server: Update `file-type`, `got`, and `sharp` dependencies to fix various security issues
### Removed
- remove misskey-assets submodule
- server: remove room data from user
- client: remove ai mode
- client: remove "Disable AiScript on Pages" setting
- client: acrylic styling
- client: Twitter embeds, the standard URL preview is used instead.
- foundkey-js: remove room api endpoints
- server: remove unusable setting to send error reports
- server: ignore detail parameter on meta endpoint
- server: Promotion entities and endpoints
- server: The configuration item `signToActivityPubGet` has been removed and will be ignored if set explicitly.
Foundkey will now work as if it was set to `true`.
## 13.0.0-preview1 - 2022-08-05
### Added

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\
@ -920,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

@ -1,6 +1,6 @@
{
"name": "foundkey",
"version": "13.0.0-preview.1",
"version": "13.0.0-preview2",
"repository": {
"type": "git",
"url": "https://akkoma.dev/FoundKeyGang/FoundKey.git"

View File

@ -1,6 +1,6 @@
{
"name": "backend",
"version": "13.0.0-preview1",
"version": "13.0.0-preview2",
"main": "./index.js",
"private": true,
"type": "module",

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

@ -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

@ -1,5 +1,6 @@
import { beforeShutdown } from '@/misc/before-shutdown.js';
import { MINUTE } from '@/const.js';
import FederationChart from './charts/federation.js';
import NotesChart from './charts/notes.js';
import UsersChart from './charts/users.js';
@ -41,11 +42,11 @@ const charts = [
apRequestChart,
];
// 20分おきにメモリ情報をDBに書き込み
// Write memory information to DB every 20 minutes
setInterval(() => {
for (const chart of charts) {
chart.save();
}
}, 1000 * 60 * 20);
}, 20 * MINUTE);
beforeShutdown(() => Promise.all(charts.map(chart => chart.save())));

View File

@ -16,6 +16,7 @@ import { 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 { DriveFolder } from '@/models/entities/drive-folder.js';
import { deleteFile } from './delete-file.js';
import { GenerateVideoThumbnail } from './generate-video-thumbnail.js';
import { driveLogger } from './logger.js';
@ -153,7 +154,10 @@ async function save(file: DriveFile, path: string, name: string, type: string, h
* @param type Content-Type for original
* @param generateWeb Generate webpublic or not
*/
export async function generateAlts(path: string, type: string, generateWeb: boolean) {
export async function generateAlts(path: string, type: string, generateWeb: boolean): Promise<{
webpublic: IImage | null;
thumbnail: IImage | null;
}> {
if (type.startsWith('video/')) {
try {
const thumbnail = await GenerateVideoThumbnail(path);
@ -256,7 +260,7 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
/**
* Upload to ObjectStorage
*/
async function upload(key: string, stream: fs.ReadStream | Buffer, _type: string, filename?: string) {
async function upload(key: string, stream: fs.ReadStream | Buffer, _type: string, filename?: string): Promise<void> {
const type = (_type === 'image/apng')
? 'image/png'
: (FILE_TYPE_BROWSERSAFE.includes(_type))
@ -286,7 +290,7 @@ async function upload(key: string, stream: fs.ReadStream | Buffer, _type: string
if (result) logger.debug(`Uploaded: ${result.Bucket}/${result.Key} => ${result.Location}`);
}
async function deleteOldFile(user: IRemoteUser) {
async function deleteOldFile(user: IRemoteUser): Promise<void> {
const q = DriveFiles.createQueryBuilder('file')
.where('file.userId = :userId', { userId: user.id })
.andWhere('file.isLink = FALSE');
@ -387,7 +391,7 @@ export async function addFile({
}
//#endregion
const fetchFolder = async () => {
const fetchFolder = async (): Promise<DriveFolder | null> => {
if (!folderId) {
return null;
}
@ -425,7 +429,7 @@ export async function addFile({
file.createdAt = new Date();
file.userId = user ? user.id : null;
file.userHost = user ? user.host : null;
file.folderId = folder?.id;
file.folderId = folder?.id ?? null;
file.comment = comment;
file.properties = properties;
file.blurhash = info.blurhash || null;

View File

@ -7,7 +7,7 @@ import { fetchMeta } from '@/misc/fetch-meta.js';
import { InternalStorage } from './internal-storage.js';
import { getS3 } from './s3.js';
export async function deleteFile(file: DriveFile, isExpired = false) {
export async function deleteFile(file: DriveFile, isExpired = false): Promise<void> {
if (file.storedInternal) {
InternalStorage.del(file.accessKey!);
@ -33,7 +33,7 @@ export async function deleteFile(file: DriveFile, isExpired = false) {
postProcess(file, isExpired);
}
export async function deleteFileSync(file: DriveFile, isExpired = false) {
export async function deleteFileSync(file: DriveFile, isExpired = false): Promise<void> {
if (file.storedInternal) {
InternalStorage.del(file.accessKey!);
@ -63,7 +63,7 @@ export async function deleteFileSync(file: DriveFile, isExpired = false) {
postProcess(file, isExpired);
}
async function postProcess(file: DriveFile, isExpired = false) {
async function postProcess(file: DriveFile, isExpired = false): Promise<void> {
// リモートファイル期限切れ削除後は直リンクにする
if (isExpired && file.userHost !== null && file.uri != null) {
DriveFiles.update(file.id, {
@ -89,7 +89,7 @@ async function postProcess(file: DriveFile, isExpired = false) {
}
}
export async function deleteObjectStorageFile(key: string) {
export async function deleteObjectStorageFile(key: string): Promise<void> {
const meta = await fetchMeta();
const s3 = getS3(meta);

View File

@ -11,7 +11,7 @@ export type IImage = {
* with resize, remove metadata, resolve orientation, stop animation
*/
export async function convertToJpeg(path: string, width: number, height: number): Promise<IImage> {
return convertSharpToJpeg(await sharp(path), width, height);
return convertSharpToJpeg(sharp(path), width, height);
}
export async function convertSharpToJpeg(sharp: sharp.Sharp, width: number, height: number): Promise<IImage> {
@ -39,7 +39,7 @@ export async function convertSharpToJpeg(sharp: sharp.Sharp, width: number, heig
* with resize, remove metadata, resolve orientation, stop animation
*/
export async function convertToWebp(path: string, width: number, height: number, quality = 85): Promise<IImage> {
return convertSharpToWebp(await sharp(path), width, height, quality);
return convertSharpToWebp(sharp(path), width, height, quality);
}
export async function convertSharpToWebp(sharp: sharp.Sharp, width: number, height: number, quality = 85): Promise<IImage> {
@ -66,7 +66,7 @@ export async function convertSharpToWebp(sharp: sharp.Sharp, width: number, heig
* with resize, remove metadata, resolve orientation, stop animation
*/
export async function convertToPng(path: string, width: number, height: number): Promise<IImage> {
return convertSharpToPng(await sharp(path), width, height);
return convertSharpToPng(sharp(path), width, height);
}
export async function convertSharpToPng(sharp: sharp.Sharp, width: number, height: number): Promise<IImage> {

View File

@ -10,25 +10,25 @@ const _dirname = dirname(_filename);
export class InternalStorage {
private static readonly path = config.internalStoragePath || Path.resolve(_dirname, '../../../../../files');
public static resolvePath = (key: string) => Path.resolve(InternalStorage.path, key);
public static resolvePath = (key: string): string => Path.resolve(InternalStorage.path, key);
public static read(key: string) {
public static read(key: string): fs.ReadStream {
return fs.createReadStream(InternalStorage.resolvePath(key));
}
public static saveFromPath(key: string, srcPath: string) {
public static saveFromPath(key: string, srcPath: string): string {
fs.mkdirSync(InternalStorage.path, { recursive: true });
fs.copyFileSync(srcPath, InternalStorage.resolvePath(key));
return `${config.url}/files/${key}`;
}
public static saveFromBuffer(key: string, data: Buffer) {
public static saveFromBuffer(key: string, data: Buffer): string {
fs.mkdirSync(InternalStorage.path, { recursive: true });
fs.writeFileSync(InternalStorage.resolvePath(key), data);
return `${config.url}/files/${key}`;
}
public static del(key: string) {
public static del(key: string): void {
fs.unlink(InternalStorage.resolvePath(key), () => {});
}
}

View File

@ -3,7 +3,7 @@ import S3 from 'aws-sdk/clients/s3.js';
import { Meta } from '@/models/entities/meta.js';
import { getAgentByUrl } from '@/misc/fetch.js';
export function getS3(meta: Meta) {
export function getS3(meta: Meta): S3 {
const u = meta.objectStorageEndpoint != null
? `${meta.objectStorageUseSSL ? 'https://' : 'http://'}${meta.objectStorageEndpoint}`
: `${meta.objectStorageUseSSL ? 'https://' : 'http://'}example.net`;

View File

@ -58,7 +58,7 @@ export async function uploadFromUrl({
sensitive,
});
logger.succ(`Got: ${driveFile.id}`);
return driveFile!;
return driveFile;
} catch (e) {
logger.error(`Failed to create drive file: ${e}`, {
url,

View File

@ -12,11 +12,11 @@ import { deliverToFollowers } from '@/remote/activitypub/deliver-manager.js';
import { deliverToRelays } from '../relay.js';
/**
* 稿
* @param user
* @param noteId
* Pin a given post to a user profile.
* @param user the user to pin the note to
* @param noteId ID of note to pin
*/
export async function addPinned(user: { id: User['id']; host: User['host']; }, noteId: Note['id']) {
export async function addPinned(user: { id: User['id']; host: User['host']; }, noteId: Note['id']): Promise<void> {
// Fetch pinee
const note = await Notes.findOneBy({
id: noteId,
@ -51,11 +51,11 @@ export async function addPinned(user: { id: User['id']; host: User['host']; }, n
}
/**
* 稿
* @param user
* @param noteId
* Unpin a given post from a user profile.
* @param user the user to unpin a note from
* @param noteId ID of note to unpin
*/
export async function removePinned(user: { id: User['id']; host: User['host']; }, noteId: Note['id']) {
export async function removePinned(user: { id: User['id']; host: User['host']; }, noteId: Note['id']): Promise<void> {
// Fetch unpinee
const note = await Notes.findOneBy({
id: noteId,
@ -77,7 +77,13 @@ export async function removePinned(user: { id: User['id']; host: User['host']; }
}
}
export async function deliverPinnedChange(userId: User['id'], noteId: Note['id'], isAddition: boolean) {
/**
* Notify followers and relays when a note is pinned/unpinned.
* @param userId ID of user
* @param noteId ID of note
* @param isAddition whether the note was pinned or unpinned
*/
export async function deliverPinnedChange(userId: User['id'], noteId: Note['id'], isAddition: boolean): Promise<void> {
const user = await Users.findOneBy({ id: userId });
if (user == null) throw new Error('user not found');

View File

@ -6,11 +6,15 @@ import { renderPerson } from '@/remote/activitypub/renderer/person.js';
import { deliverToFollowers } from '@/remote/activitypub/deliver-manager.js';
import { deliverToRelays } from '../relay.js';
export async function publishToFollowers(userId: User['id']) {
/**
* Send an Update activity to a user's followers.
* @param userId ID of user
*/
export async function publishToFollowers(userId: User['id']): Promise<void> {
const user = await Users.findOneBy({ id: userId });
if (user == null) throw new Error('user not found');
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーならUpdateを配信
// Deliver Update if the follower is a remote user and the poster is a local user
if (Users.isLocalUser(user)) {
const content = renderActivity(renderUpdate(await renderPerson(user), user));
deliverToFollowers(user, content);

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';
@ -86,7 +86,7 @@ export default async function(user: { id: User['id']; uri: User['uri']; host: Us
async function findCascadingNotes(note: Note): Promise<Note[]> {
const cascadingNotes: Note[] = [];
const recursive = async (noteId: string) => {
const recursive = async (noteId: string): Promise<void> => {
const query = Notes.createQueryBuilder('note')
.where('note.replyId = :noteId', { noteId })
.orWhere(new Brackets(q => {
@ -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
@ -131,11 +131,23 @@ async function getMentionedRemoteUsers(note: Note): Promise<IRemoteUser[]> {
}) as IRemoteUser[];
}
async function deliverToConcerned(user: { id: ILocalUser['id']; host: null; }, note: Note, content: any) {
deliverToFollowers(user, content);
deliverToRelays(user, content);
async function deliverToConcerned(user: { id: ILocalUser['id']; host: null; }, note: Note, content: any): Promise<void> {
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

@ -1,6 +1,6 @@
{
"name": "client",
"version": "13.0.0-preview1",
"version": "13.0.0-preview2",
"private": true,
"scripts": {
"watch": "vite build --watch --mode development",

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

@ -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

@ -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,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

@ -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>
@ -73,17 +73,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

@ -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

@ -1,6 +1,6 @@
{
"name": "foundkey-js",
"version": "13.0.0-preview1",
"version": "13.0.0-preview2",
"description": "Fork of misskey-js for Foundkey",
"type": "module",
"main": "./built/index.js",

View File

@ -1,6 +1,6 @@
{
"name": "sw",
"version": "13.0.0-preview1",
"version": "13.0.0-preview2",
"private": true,
"scripts": {
"watch": "node build.js watch",