chore (backend-rs): update napi-derive
This commit is contained in:
parent
06720578b0
commit
19673c6220
21 changed files with 163 additions and 250 deletions
33
Cargo.lock
generated
33
Cargo.lock
generated
|
@ -213,7 +213,7 @@ dependencies = [
|
|||
"macros",
|
||||
"napi",
|
||||
"napi-build",
|
||||
"napi-derive",
|
||||
"napi-derive 3.0.0-alpha.3",
|
||||
"nom-exif",
|
||||
"once_cell",
|
||||
"openssl",
|
||||
|
@ -1815,7 +1815,7 @@ dependencies = [
|
|||
"bitflags 2.6.0",
|
||||
"chrono",
|
||||
"ctor",
|
||||
"napi-derive",
|
||||
"napi-derive 2.16.8",
|
||||
"napi-sys",
|
||||
"once_cell",
|
||||
"serde",
|
||||
|
@ -1837,7 +1837,21 @@ checksum = "eafd2b920906ea5b1f5f1f9d1eff9cc74e4ff8124dca41b501c1413079589187"
|
|||
dependencies = [
|
||||
"cfg-if",
|
||||
"convert_case",
|
||||
"napi-derive-backend",
|
||||
"napi-derive-backend 1.0.70",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.68",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "napi-derive"
|
||||
version = "3.0.0-alpha.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "823fb2987af2446a2b4055604a920f2c1f1a028743c72adc8872d92da7e30d2b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"convert_case",
|
||||
"napi-derive-backend 2.0.0-alpha.3",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.68",
|
||||
|
@ -1848,6 +1862,19 @@ name = "napi-derive-backend"
|
|||
version = "1.0.70"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b370b784440c65eb9001d839012eb912ee43e3a2d0361e2c30c13052372c39fe"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.68",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "napi-derive-backend"
|
||||
version = "2.0.0-alpha.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abd42151b3c26b5cdde9cf9a8fc5f7240de0919f234e14c6f54e3571d56e4dab"
|
||||
dependencies = [
|
||||
"convert_case",
|
||||
"once_cell",
|
||||
|
|
|
@ -7,7 +7,7 @@ macros = { path = "packages/macro-rs/macros" }
|
|||
macros-impl = { path = "packages/macro-rs/macros-impl" }
|
||||
|
||||
napi = "2.16.8"
|
||||
napi-derive = "2.16.8"
|
||||
napi-derive = "3.0.0-alpha.3"
|
||||
napi-build = "2.1.3"
|
||||
|
||||
argon2 = { version = "0.5.3", default-features = false }
|
||||
|
|
192
packages/backend-rs/index.d.ts
vendored
192
packages/backend-rs/index.d.ts
vendored
|
@ -97,14 +97,12 @@ export interface Antenna {
|
|||
excludeKeywords: Array<string>
|
||||
}
|
||||
|
||||
export enum AntennaSrc {
|
||||
All = 'all',
|
||||
Group = 'group',
|
||||
Home = 'home',
|
||||
Instances = 'instances',
|
||||
List = 'list',
|
||||
Users = 'users'
|
||||
}
|
||||
export type AntennaSrc = 'all'|
|
||||
'group'|
|
||||
'home'|
|
||||
'instances'|
|
||||
'list'|
|
||||
'users';
|
||||
|
||||
export interface App {
|
||||
id: string
|
||||
|
@ -166,17 +164,13 @@ export interface ChannelNotePining {
|
|||
noteId: string
|
||||
}
|
||||
|
||||
export enum ChatEvent {
|
||||
Message = 0,
|
||||
Read = 1,
|
||||
Deleted = 2,
|
||||
Typing = 3
|
||||
}
|
||||
export type ChatEvent = 'message'|
|
||||
'read'|
|
||||
'deleted'|
|
||||
'typing';
|
||||
|
||||
export enum ChatIndexEvent {
|
||||
Message = 0,
|
||||
Read = 1
|
||||
}
|
||||
export type ChatIndexEvent = 'message'|
|
||||
'read';
|
||||
|
||||
/**
|
||||
* Returns whether `note` should be hard-muted.
|
||||
|
@ -330,16 +324,12 @@ export interface DriveFile {
|
|||
usageHint: DriveFileUsageHint | null
|
||||
}
|
||||
|
||||
export enum DriveFileEvent {
|
||||
Create = 0,
|
||||
Update = 1,
|
||||
Delete = 2
|
||||
}
|
||||
export type DriveFileEvent = 'create'|
|
||||
'update'|
|
||||
'delete';
|
||||
|
||||
export enum DriveFileUsageHint {
|
||||
UserAvatar = 'userAvatar',
|
||||
UserBanner = 'userBanner'
|
||||
}
|
||||
export type DriveFileUsageHint = 'userAvatar'|
|
||||
'userBanner';
|
||||
|
||||
export interface DriveFolder {
|
||||
id: string
|
||||
|
@ -349,11 +339,9 @@ export interface DriveFolder {
|
|||
parentId: string | null
|
||||
}
|
||||
|
||||
export enum DriveFolderEvent {
|
||||
Create = 0,
|
||||
Update = 1,
|
||||
Delete = 2
|
||||
}
|
||||
export type DriveFolderEvent = 'create'|
|
||||
'update'|
|
||||
'delete';
|
||||
|
||||
export interface EmailConfig {
|
||||
managed?: boolean
|
||||
|
@ -513,7 +501,7 @@ export interface ImageSize {
|
|||
}
|
||||
|
||||
/** The third party sites this server can retrieve messages from for combined display with regular traffic. */
|
||||
export enum Inbound {
|
||||
export declare enum Inbound {
|
||||
Atom1 = 0,
|
||||
Gnusocial = 1,
|
||||
Imap = 2,
|
||||
|
@ -776,12 +764,10 @@ export interface MutedNote {
|
|||
reason: MutedNoteReason
|
||||
}
|
||||
|
||||
export enum MutedNoteReason {
|
||||
Manual = 'manual',
|
||||
Other = 'other',
|
||||
Spam = 'spam',
|
||||
Word = 'word'
|
||||
}
|
||||
export type MutedNoteReason = 'manual'|
|
||||
'other'|
|
||||
'spam'|
|
||||
'word';
|
||||
|
||||
export interface Muting {
|
||||
id: string
|
||||
|
@ -903,13 +889,11 @@ export interface NoteUnread {
|
|||
noteChannelId: string | null
|
||||
}
|
||||
|
||||
export enum NoteVisibility {
|
||||
Followers = 'followers',
|
||||
Hidden = 'hidden',
|
||||
Home = 'home',
|
||||
Public = 'public',
|
||||
Specified = 'specified'
|
||||
}
|
||||
export type NoteVisibility = 'followers'|
|
||||
'hidden'|
|
||||
'home'|
|
||||
'public'|
|
||||
'specified';
|
||||
|
||||
export interface NoteWatching {
|
||||
id: string
|
||||
|
@ -937,20 +921,18 @@ export interface Notification {
|
|||
appAccessTokenId: string | null
|
||||
}
|
||||
|
||||
export enum NotificationType {
|
||||
App = 'app',
|
||||
Follow = 'follow',
|
||||
FollowRequestAccepted = 'followRequestAccepted',
|
||||
GroupInvited = 'groupInvited',
|
||||
Mention = 'mention',
|
||||
PollEnded = 'pollEnded',
|
||||
PollVote = 'pollVote',
|
||||
Quote = 'quote',
|
||||
Reaction = 'reaction',
|
||||
ReceiveFollowRequest = 'receiveFollowRequest',
|
||||
Renote = 'renote',
|
||||
Reply = 'reply'
|
||||
}
|
||||
export type NotificationType = 'app'|
|
||||
'follow'|
|
||||
'followRequestAccepted'|
|
||||
'groupInvited'|
|
||||
'mention'|
|
||||
'pollEnded'|
|
||||
'pollVote'|
|
||||
'quote'|
|
||||
'reaction'|
|
||||
'receiveFollowRequest'|
|
||||
'renote'|
|
||||
'reply';
|
||||
|
||||
/**
|
||||
* Converts the given text into the cat language.
|
||||
|
@ -989,7 +971,7 @@ export interface ObjectStorageConfig {
|
|||
}
|
||||
|
||||
/** The third party sites this server can publish messages to on the behalf of a user. */
|
||||
export enum Outbound {
|
||||
export declare enum Outbound {
|
||||
Atom1 = 0,
|
||||
Blogger = 1,
|
||||
Buddycloud = 2,
|
||||
|
@ -1060,11 +1042,9 @@ export interface PageLike {
|
|||
pageId: string
|
||||
}
|
||||
|
||||
export enum PageVisibility {
|
||||
Followers = 'followers',
|
||||
Public = 'public',
|
||||
Specified = 'specified'
|
||||
}
|
||||
export type PageVisibility = 'followers'|
|
||||
'public'|
|
||||
'specified';
|
||||
|
||||
export interface PartialNoteToCheckWordMute {
|
||||
fileIds: Array<string>
|
||||
|
@ -1092,12 +1072,10 @@ export interface Poll {
|
|||
userHost: string | null
|
||||
}
|
||||
|
||||
export enum PollNoteVisibility {
|
||||
Followers = 'followers',
|
||||
Home = 'home',
|
||||
Public = 'public',
|
||||
Specified = 'specified'
|
||||
}
|
||||
export type PollNoteVisibility = 'followers'|
|
||||
'home'|
|
||||
'public'|
|
||||
'specified';
|
||||
|
||||
export interface PollVote {
|
||||
id: string
|
||||
|
@ -1120,7 +1098,7 @@ export interface PromoRead {
|
|||
noteId: string
|
||||
}
|
||||
|
||||
export enum Protocol {
|
||||
export declare enum Protocol {
|
||||
Activitypub = 0,
|
||||
Buddycloud = 1,
|
||||
Dfrn = 2,
|
||||
|
@ -1163,15 +1141,13 @@ export interface PugArgs {
|
|||
privateMode: boolean | null
|
||||
}
|
||||
|
||||
export enum PushNotificationKind {
|
||||
Generic = 0,
|
||||
Chat = 1,
|
||||
ReadAllChats = 2,
|
||||
ReadAllChatsInTheRoom = 3,
|
||||
ReadNotifications = 4,
|
||||
ReadAllNotifications = 5,
|
||||
Mastodon = 6
|
||||
}
|
||||
export type PushNotificationKind = 'generic'|
|
||||
'chat'|
|
||||
'readAllChats'|
|
||||
'readAllChatsInTheRoom'|
|
||||
'readNotifications'|
|
||||
'readAllNotifications'|
|
||||
'mastodon';
|
||||
|
||||
export interface RedisConfig {
|
||||
host: string
|
||||
|
@ -1207,11 +1183,9 @@ export interface Relay {
|
|||
status: RelayStatus
|
||||
}
|
||||
|
||||
export enum RelayStatus {
|
||||
Accepted = 'accepted',
|
||||
Rejected = 'rejected',
|
||||
Requesting = 'requesting'
|
||||
}
|
||||
export type RelayStatus = 'accepted'|
|
||||
'rejected'|
|
||||
'requesting';
|
||||
|
||||
/** Delete all entries in the [attestation_challenge] table created at more than 5 minutes ago */
|
||||
export declare function removeOldAttestationChallenges(): Promise<void>
|
||||
|
@ -1425,12 +1399,10 @@ export const USER_ACTIVE_THRESHOLD: number
|
|||
|
||||
export const USER_ONLINE_THRESHOLD: number
|
||||
|
||||
export enum UserEmojiModPerm {
|
||||
Add = 'add',
|
||||
Full = 'full',
|
||||
Mod = 'mod',
|
||||
Unauthorized = 'unauthorized'
|
||||
}
|
||||
export type UserEmojiModPerm = 'add'|
|
||||
'full'|
|
||||
'mod'|
|
||||
'unauthorized';
|
||||
|
||||
export interface UserGroup {
|
||||
id: string
|
||||
|
@ -1542,26 +1514,22 @@ export interface UserProfile {
|
|||
lang: string | null
|
||||
}
|
||||
|
||||
export enum UserProfileFfvisibility {
|
||||
Followers = 'followers',
|
||||
Private = 'private',
|
||||
Public = 'public'
|
||||
}
|
||||
export type UserProfileFfvisibility = 'followers'|
|
||||
'private'|
|
||||
'public';
|
||||
|
||||
export enum UserProfileMutingNotificationTypes {
|
||||
App = 'app',
|
||||
Follow = 'follow',
|
||||
FollowRequestAccepted = 'followRequestAccepted',
|
||||
GroupInvited = 'groupInvited',
|
||||
Mention = 'mention',
|
||||
PollEnded = 'pollEnded',
|
||||
PollVote = 'pollVote',
|
||||
Quote = 'quote',
|
||||
Reaction = 'reaction',
|
||||
ReceiveFollowRequest = 'receiveFollowRequest',
|
||||
Renote = 'renote',
|
||||
Reply = 'reply'
|
||||
}
|
||||
export type UserProfileMutingNotificationTypes = 'app'|
|
||||
'follow'|
|
||||
'followRequestAccepted'|
|
||||
'groupInvited'|
|
||||
'mention'|
|
||||
'pollEnded'|
|
||||
'pollVote'|
|
||||
'quote'|
|
||||
'reaction'|
|
||||
'receiveFollowRequest'|
|
||||
'renote'|
|
||||
'reply';
|
||||
|
||||
export interface UserPublickey {
|
||||
userId: string
|
||||
|
|
|
@ -31,7 +31,7 @@ fn get_client() -> Result<IsahcWebPushClient, Error> {
|
|||
.cloned()?)
|
||||
}
|
||||
|
||||
#[macros::export]
|
||||
#[macros::export(string_enum = "camelCase")]
|
||||
pub enum PushNotificationKind {
|
||||
Generic,
|
||||
Chat,
|
||||
|
|
|
@ -54,7 +54,7 @@ pub enum Stream {
|
|||
},
|
||||
}
|
||||
|
||||
#[macros::export]
|
||||
#[macros::export(string_enum = "camelCase")]
|
||||
pub enum ChatEvent {
|
||||
Message,
|
||||
Read,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::service::stream::{publish_to_stream, Error, Stream};
|
||||
|
||||
#[macros::export]
|
||||
#[macros::export(string_enum = "camelCase")]
|
||||
pub enum ChatIndexEvent {
|
||||
Message,
|
||||
Read,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use crate::service::stream::{publish_to_stream, Error, Stream};
|
||||
|
||||
#[macros::export]
|
||||
#[macros::export(string_enum = "camelCase")]
|
||||
pub enum DriveFileEvent {
|
||||
Create,
|
||||
Update,
|
||||
Delete,
|
||||
}
|
||||
|
||||
#[macros::export]
|
||||
#[macros::export(string_enum = "camelCase")]
|
||||
pub enum DriveFolderEvent {
|
||||
Create,
|
||||
Update,
|
||||
|
|
|
@ -4,9 +4,6 @@ import {
|
|||
publishToGroupChatStream,
|
||||
publishToChatIndexStream,
|
||||
sendPushNotification,
|
||||
ChatEvent,
|
||||
ChatIndexEvent,
|
||||
PushNotificationKind,
|
||||
} from "backend-rs";
|
||||
import type { User, IRemoteUser } from "@/models/entities/user.js";
|
||||
import type { MessagingMessage } from "@/models/entities/messaging-message.js";
|
||||
|
@ -58,14 +55,14 @@ export async function readUserMessagingMessage(
|
|||
|
||||
// Publish event
|
||||
await Promise.all([
|
||||
publishToChatStream(otherpartyId, userId, ChatEvent.Read, messageIds),
|
||||
publishToChatIndexStream(userId, ChatIndexEvent.Read, messageIds),
|
||||
publishToChatStream(otherpartyId, userId, "read", messageIds),
|
||||
publishToChatIndexStream(userId, "read", messageIds),
|
||||
]);
|
||||
|
||||
if (!(await Users.getHasUnreadMessagingMessage(userId))) {
|
||||
// 全ての(いままで未読だった)自分宛てのメッセージを(これで)読みましたよというイベントを発行
|
||||
publishMainStream(userId, "readAllMessagingMessages");
|
||||
await sendPushNotification(userId, PushNotificationKind.ReadAllChats, {});
|
||||
await sendPushNotification(userId, "readAllChats", {});
|
||||
} else {
|
||||
// そのユーザーとのメッセージで未読がなければイベント発行
|
||||
const hasUnread = await MessagingMessages.existsBy({
|
||||
|
@ -75,13 +72,9 @@ export async function readUserMessagingMessage(
|
|||
});
|
||||
|
||||
if (!hasUnread) {
|
||||
await sendPushNotification(
|
||||
userId,
|
||||
PushNotificationKind.ReadAllChatsInTheRoom,
|
||||
{
|
||||
userId: otherpartyId,
|
||||
},
|
||||
);
|
||||
await sendPushNotification(userId, "readAllChatsInTheRoom", {
|
||||
userId: otherpartyId,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,17 +126,17 @@ export async function readGroupMessagingMessage(
|
|||
|
||||
// Publish events
|
||||
await Promise.all([
|
||||
publishToGroupChatStream(groupId, ChatEvent.Read, {
|
||||
publishToGroupChatStream(groupId, "read", {
|
||||
ids: reads,
|
||||
userId,
|
||||
}),
|
||||
publishToChatIndexStream(userId, ChatIndexEvent.Read, reads),
|
||||
publishToChatIndexStream(userId, "read", reads),
|
||||
]);
|
||||
|
||||
if (!(await Users.getHasUnreadMessagingMessage(userId))) {
|
||||
// 全ての(いままで未読だった)自分宛てのメッセージを(これで)読みましたよというイベントを発行
|
||||
publishMainStream(userId, "readAllMessagingMessages");
|
||||
await sendPushNotification(userId, PushNotificationKind.ReadAllChats, {});
|
||||
await sendPushNotification(userId, "readAllChats", {});
|
||||
} else {
|
||||
// そのグループにおいて未読がなければイベント発行
|
||||
const hasUnread = await MessagingMessages.createQueryBuilder("message")
|
||||
|
@ -157,13 +150,9 @@ export async function readGroupMessagingMessage(
|
|||
.then((x) => x != null);
|
||||
|
||||
if (!hasUnread) {
|
||||
await sendPushNotification(
|
||||
userId,
|
||||
PushNotificationKind.ReadAllChatsInTheRoom,
|
||||
{
|
||||
groupId,
|
||||
},
|
||||
);
|
||||
await sendPushNotification(userId, "readAllChatsInTheRoom", {
|
||||
groupId,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { In } from "typeorm";
|
||||
import { publishMainStream } from "@/services/stream.js";
|
||||
import { sendPushNotification, PushNotificationKind } from "backend-rs";
|
||||
import { sendPushNotification } from "backend-rs";
|
||||
import type { User } from "@/models/entities/user.js";
|
||||
import type { Notification } from "@/models/entities/notification.js";
|
||||
import { Notifications, Users } from "@/models/index.js";
|
||||
|
@ -47,11 +47,7 @@ export async function readNotificationByQuery(
|
|||
|
||||
function postReadAllNotifications(userId: User["id"]) {
|
||||
publishMainStream(userId, "readAllNotifications");
|
||||
return sendPushNotification(
|
||||
userId,
|
||||
PushNotificationKind.ReadAllNotifications,
|
||||
{},
|
||||
);
|
||||
return sendPushNotification(userId, "readAllNotifications", {});
|
||||
}
|
||||
|
||||
function postReadNotifications(
|
||||
|
@ -59,7 +55,7 @@ function postReadNotifications(
|
|||
notificationIds: Notification["id"][],
|
||||
) {
|
||||
publishMainStream(userId, "readNotifications", notificationIds);
|
||||
return sendPushNotification(userId, PushNotificationKind.ReadNotifications, {
|
||||
return sendPushNotification(userId, "readNotifications", {
|
||||
notificationIds,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { deleteFile } from "@/services/drive/delete-file.js";
|
||||
import { publishToDriveFileStream, DriveFileEvent } from "backend-rs";
|
||||
import { publishToDriveFileStream } from "backend-rs";
|
||||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { DriveFiles } from "@/models/index.js";
|
||||
|
@ -51,5 +51,5 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
await deleteFile(file);
|
||||
|
||||
// Publish fileDeleted event
|
||||
publishToDriveFileStream(user.id, DriveFileEvent.Delete, file.id);
|
||||
publishToDriveFileStream(user.id, "delete", file.id);
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { publishToDriveFileStream, DriveFileEvent } from "backend-rs";
|
||||
import { publishToDriveFileStream } from "backend-rs";
|
||||
import { DriveFiles, DriveFolders } from "@/models/index.js";
|
||||
import { config } from "@/config.js";
|
||||
import define from "@/server/api/define.js";
|
||||
|
@ -111,7 +111,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
const fileObj = await DriveFiles.pack(file, { self: true });
|
||||
|
||||
// Publish fileUpdated event
|
||||
publishToDriveFileStream(user.id, DriveFileEvent.Update, toRustObject(file));
|
||||
publishToDriveFileStream(user.id, "update", toRustObject(file));
|
||||
|
||||
return fileObj;
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { publishToDriveFolderStream, DriveFolderEvent } from "backend-rs";
|
||||
import { publishToDriveFolderStream } from "backend-rs";
|
||||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { DriveFolders } from "@/models/index.js";
|
||||
|
@ -65,11 +65,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
const folderObj = await DriveFolders.pack(folder);
|
||||
|
||||
// Publish folderCreated event
|
||||
publishToDriveFolderStream(
|
||||
user.id,
|
||||
DriveFolderEvent.Create,
|
||||
toRustObject(folder),
|
||||
);
|
||||
publishToDriveFolderStream(user.id, "create", toRustObject(folder));
|
||||
|
||||
return folderObj;
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import define from "@/server/api/define.js";
|
||||
import { publishToDriveFolderStream, DriveFolderEvent } from "backend-rs";
|
||||
import { publishToDriveFolderStream } from "backend-rs";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { DriveFolders, DriveFiles } from "@/models/index.js";
|
||||
|
||||
|
@ -56,5 +56,5 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
await DriveFolders.delete(folder.id);
|
||||
|
||||
// Publish folderCreated event
|
||||
publishToDriveFolderStream(user.id, DriveFolderEvent.Delete, folder.id);
|
||||
publishToDriveFolderStream(user.id, "delete", folder.id);
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { publishToDriveFolderStream, DriveFolderEvent } from "backend-rs";
|
||||
import { publishToDriveFolderStream } from "backend-rs";
|
||||
import define from "@/server/api/define.js";
|
||||
import { ApiError } from "@/server/api/error.js";
|
||||
import { DriveFolders } from "@/models/index.js";
|
||||
|
@ -85,10 +85,10 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
id: folderId,
|
||||
});
|
||||
|
||||
if (folder2!.id === folder!.id) {
|
||||
if (folder2?.id === folder.id) {
|
||||
return true;
|
||||
} else if (folder2!.parentId) {
|
||||
return await checkCircle(folder2!.parentId);
|
||||
} else if (folder2?.parentId) {
|
||||
return await checkCircle(folder2?.parentId);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -113,11 +113,7 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
const folderObj = await DriveFolders.pack(folder);
|
||||
|
||||
// Publish folderUpdated event
|
||||
publishToDriveFolderStream(
|
||||
user.id,
|
||||
DriveFolderEvent.Update,
|
||||
toRustObject(folder),
|
||||
);
|
||||
publishToDriveFolderStream(user.id, "update", toRustObject(folder));
|
||||
|
||||
return folderObj;
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { publishMainStream } from "@/services/stream.js";
|
||||
import { sendPushNotification, PushNotificationKind } from "backend-rs";
|
||||
import { sendPushNotification } from "backend-rs";
|
||||
import { Notifications } from "@/models/index.js";
|
||||
import define from "@/server/api/define.js";
|
||||
|
||||
|
@ -31,9 +31,5 @@ export default define(meta, paramDef, async (_, user) => {
|
|||
|
||||
// 全ての通知を読みましたよというイベントを発行
|
||||
publishMainStream(user.id, "readAllNotifications");
|
||||
await sendPushNotification(
|
||||
user.id,
|
||||
PushNotificationKind.ReadAllNotifications,
|
||||
{},
|
||||
);
|
||||
await sendPushNotification(user.id, "readAllNotifications", {});
|
||||
});
|
||||
|
|
|
@ -18,7 +18,6 @@ import {
|
|||
publishToChannelStream,
|
||||
publishToChatStream,
|
||||
publishToGroupChatStream,
|
||||
ChatEvent,
|
||||
} from "backend-rs";
|
||||
import type { UserGroup } from "@/models/entities/user-group.js";
|
||||
import type { Packed } from "@/misc/schema.js";
|
||||
|
@ -528,15 +527,11 @@ export default class Connection {
|
|||
await publishToChatStream(
|
||||
param.partner,
|
||||
this.user.id,
|
||||
ChatEvent.Typing,
|
||||
"typing",
|
||||
this.user.id,
|
||||
);
|
||||
} else if (param.group != null) {
|
||||
await publishToGroupChatStream(
|
||||
param.group,
|
||||
ChatEvent.Typing,
|
||||
this.user.id,
|
||||
);
|
||||
await publishToGroupChatStream(param.group, "typing", this.user.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,7 @@ import {
|
|||
Users,
|
||||
Followings,
|
||||
} from "@/models/index.js";
|
||||
import {
|
||||
genIdAt,
|
||||
isSilencedServer,
|
||||
sendPushNotification,
|
||||
PushNotificationKind,
|
||||
} from "backend-rs";
|
||||
import { genIdAt, isSilencedServer, sendPushNotification } from "backend-rs";
|
||||
import type { User } from "@/models/entities/user.js";
|
||||
import type { Notification } from "@/models/entities/notification.js";
|
||||
import { sendEmailNotification } from "./send-email-notification.js";
|
||||
|
@ -88,11 +83,7 @@ export async function createNotification(
|
|||
if (fresh == null) return; // 既に削除されているかもしれない
|
||||
// We execute this before, because the server side "read" check doesnt work well with push notifications, the app and service worker will decide themself
|
||||
// when it is best to show push notifications
|
||||
await sendPushNotification(
|
||||
notifieeId,
|
||||
PushNotificationKind.Generic,
|
||||
packed,
|
||||
);
|
||||
await sendPushNotification(notifieeId, "generic", packed);
|
||||
if (fresh.isRead) return;
|
||||
|
||||
//#region ただしミュートしているユーザーからの通知なら無視
|
||||
|
|
|
@ -7,7 +7,6 @@ import sharp from "sharp";
|
|||
import { IsNull } from "typeorm";
|
||||
import { publishMainStream } from "@/services/stream.js";
|
||||
import {
|
||||
DriveFileEvent,
|
||||
FILE_TYPE_BROWSERSAFE,
|
||||
fetchMeta,
|
||||
genId,
|
||||
|
@ -667,11 +666,7 @@ export async function addFile({
|
|||
DriveFiles.pack(file, { self: true }).then((packedFile) => {
|
||||
// Publish driveFileCreated event
|
||||
publishMainStream(user.id, "driveFileCreated", packedFile);
|
||||
publishToDriveFileStream(
|
||||
user.id,
|
||||
DriveFileEvent.Create,
|
||||
toRustObject(file),
|
||||
);
|
||||
publishToDriveFileStream(user.id, "create", toRustObject(file));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,6 @@ import {
|
|||
publishToGroupChatStream,
|
||||
publishToChatIndexStream,
|
||||
toPuny,
|
||||
ChatEvent,
|
||||
ChatIndexEvent,
|
||||
PushNotificationKind,
|
||||
} from "backend-rs";
|
||||
import type { MessagingMessage } from "@/models/entities/messaging-message.js";
|
||||
import { publishMainStream } from "@/services/stream.js";
|
||||
|
@ -61,14 +58,10 @@ export async function createMessage(
|
|||
publishToChatStream(
|
||||
message.userId,
|
||||
recipientUser.id,
|
||||
ChatEvent.Message,
|
||||
messageObj,
|
||||
),
|
||||
publishToChatIndexStream(
|
||||
message.userId,
|
||||
ChatIndexEvent.Message,
|
||||
"message",
|
||||
messageObj,
|
||||
),
|
||||
publishToChatIndexStream(message.userId, "message", messageObj),
|
||||
]);
|
||||
publishMainStream(message.userId, "messagingMessage", messageObj);
|
||||
}
|
||||
|
@ -79,35 +72,23 @@ export async function createMessage(
|
|||
publishToChatStream(
|
||||
recipientUser.id,
|
||||
message.userId,
|
||||
ChatEvent.Message,
|
||||
messageObj,
|
||||
),
|
||||
publishToChatIndexStream(
|
||||
recipientUser.id,
|
||||
ChatIndexEvent.Message,
|
||||
"message",
|
||||
messageObj,
|
||||
),
|
||||
publishToChatIndexStream(recipientUser.id, "message", messageObj),
|
||||
]);
|
||||
publishMainStream(recipientUser.id, "messagingMessage", messageObj);
|
||||
}
|
||||
} else if (recipientGroup != null) {
|
||||
// group's stream
|
||||
await publishToGroupChatStream(
|
||||
recipientGroup.id,
|
||||
ChatEvent.Message,
|
||||
messageObj,
|
||||
);
|
||||
await publishToGroupChatStream(recipientGroup.id, "message", messageObj);
|
||||
|
||||
// member's stream
|
||||
const joinings = await UserGroupJoinings.findBy({
|
||||
userGroupId: recipientGroup.id,
|
||||
});
|
||||
for await (const joining of joinings) {
|
||||
await publishToChatIndexStream(
|
||||
joining.userId,
|
||||
ChatIndexEvent.Message,
|
||||
messageObj,
|
||||
);
|
||||
await publishToChatIndexStream(joining.userId, "message", messageObj);
|
||||
publishMainStream(joining.userId, "messagingMessage", messageObj);
|
||||
}
|
||||
}
|
||||
|
@ -128,11 +109,7 @@ export async function createMessage(
|
|||
//#endregion
|
||||
|
||||
publishMainStream(recipientUser.id, "unreadMessagingMessage", messageObj);
|
||||
await sendPushNotification(
|
||||
recipientUser.id,
|
||||
PushNotificationKind.Chat,
|
||||
messageObj,
|
||||
);
|
||||
await sendPushNotification(recipientUser.id, "chat", messageObj);
|
||||
} else if (recipientGroup) {
|
||||
const joinings = await UserGroupJoinings.findBy({
|
||||
userGroupId: recipientGroup.id,
|
||||
|
@ -141,11 +118,7 @@ export async function createMessage(
|
|||
for await (const joining of joinings) {
|
||||
if (freshMessage.reads.includes(joining.userId)) return; // 既読
|
||||
publishMainStream(joining.userId, "unreadMessagingMessage", messageObj);
|
||||
await sendPushNotification(
|
||||
joining.userId,
|
||||
PushNotificationKind.Chat,
|
||||
messageObj,
|
||||
);
|
||||
await sendPushNotification(joining.userId, "chat", messageObj);
|
||||
}
|
||||
}
|
||||
}, 2000);
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import { config } from "@/config.js";
|
||||
import { MessagingMessages, Users } from "@/models/index.js";
|
||||
import type { MessagingMessage } from "@/models/entities/messaging-message.js";
|
||||
import {
|
||||
publishToChatStream,
|
||||
publishToGroupChatStream,
|
||||
ChatEvent,
|
||||
} from "backend-rs";
|
||||
import { publishToChatStream, publishToGroupChatStream } from "backend-rs";
|
||||
import { renderActivity } from "@/remote/activitypub/renderer/index.js";
|
||||
import renderDelete from "@/remote/activitypub/renderer/delete.js";
|
||||
import renderTombstone from "@/remote/activitypub/renderer/tombstone.js";
|
||||
|
@ -27,14 +23,14 @@ async function postDeleteMessage(message: MessagingMessage) {
|
|||
await publishToChatStream(
|
||||
message.userId,
|
||||
message.recipientId,
|
||||
ChatEvent.Deleted,
|
||||
"deleted",
|
||||
message.id,
|
||||
);
|
||||
if (Users.isLocalUser(recipient))
|
||||
await publishToChatStream(
|
||||
message.recipientId,
|
||||
message.userId,
|
||||
ChatEvent.Deleted,
|
||||
"deleted",
|
||||
message.id,
|
||||
);
|
||||
|
||||
|
@ -48,10 +44,6 @@ async function postDeleteMessage(message: MessagingMessage) {
|
|||
deliver(user, activity, recipient.inbox);
|
||||
}
|
||||
} else if (message.groupId != null) {
|
||||
await publishToGroupChatStream(
|
||||
message.groupId,
|
||||
ChatEvent.Deleted,
|
||||
message.id,
|
||||
);
|
||||
await publishToGroupChatStream(message.groupId, "deleted", message.id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -391,7 +391,6 @@ export default async (
|
|||
}
|
||||
});
|
||||
|
||||
// type errors will be resolved by https://github.com/napi-rs/napi-rs/pull/2054
|
||||
const _note = toRustObject(note);
|
||||
if (note.renoteId == null || isQuote(_note)) {
|
||||
await updateAntennasOnNewNote(_note, user, thisNoteIsMutedBy);
|
||||
|
|
Loading…
Reference in a new issue