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