Merge branch 'misskey-dev:develop' into develop
This commit is contained in:
commit
03c1d70a99
37
.github/dependabot.yml
vendored
37
.github/dependabot.yml
vendored
@ -10,28 +10,23 @@ updates:
|
|||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: daily
|
||||||
open-pull-requests-limit: 100
|
open-pull-requests-limit: 100
|
||||||
|
|
||||||
|
# Add only the root, not each workspace item
|
||||||
|
# https://github.com/dependabot/dependabot-core/issues/4993#issuecomment-1289133027
|
||||||
- package-ecosystem: npm
|
- package-ecosystem: npm
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: daily
|
interval: daily
|
||||||
open-pull-requests-limit: 100
|
# PNPM has an issue with dependabot. See:
|
||||||
- package-ecosystem: npm
|
# https://github.com/dependabot/dependabot-core/issues/7258
|
||||||
directory: "/packages/backend"
|
# https://github.com/pnpm/pnpm/issues/6530
|
||||||
schedule:
|
# TODO: Restore this when the issue is solved
|
||||||
interval: daily
|
open-pull-requests-limit: 0
|
||||||
open-pull-requests-limit: 100
|
groups:
|
||||||
- package-ecosystem: npm
|
swc:
|
||||||
directory: "/packages/frontend"
|
patterns:
|
||||||
schedule:
|
- "@swc/*"
|
||||||
interval: daily
|
storybook:
|
||||||
open-pull-requests-limit: 100
|
patterns:
|
||||||
- package-ecosystem: npm
|
- "storybook*"
|
||||||
directory: "/packages/sw"
|
- "@storybook/*"
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
||||||
open-pull-requests-limit: 100
|
|
||||||
- package-ecosystem: npm
|
|
||||||
directory: "/packages/misskey-js"
|
|
||||||
schedule:
|
|
||||||
interval: daily
|
|
||||||
open-pull-requests-limit: 100
|
|
||||||
|
4
.github/workflows/api-misskey-js.yml
vendored
4
.github/workflows/api-misskey-js.yml
vendored
@ -9,12 +9,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3.3.0
|
uses: actions/checkout@v3.5.3
|
||||||
|
|
||||||
- run: corepack enable
|
- run: corepack enable
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v3.6.0
|
uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
2
.github/workflows/check_copyright_year.yml
vendored
2
.github/workflows/check_copyright_year.yml
vendored
@ -10,7 +10,7 @@ jobs:
|
|||||||
check_copyright_year:
|
check_copyright_year:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.2.0
|
- uses: actions/checkout@v3.5.3
|
||||||
- run: |
|
- run: |
|
||||||
if [ "$(grep Copyright COPYING | sed -e 's/.*2014-\([0-9]*\) .*/\1/g')" -ne "$(date +%Y)" ]; then
|
if [ "$(grep Copyright COPYING | sed -e 's/.*2014-\([0-9]*\) .*/\1/g')" -ne "$(date +%Y)" ]; then
|
||||||
echo "Please change copyright year!"
|
echo "Please change copyright year!"
|
||||||
|
4
.github/workflows/docker-develop.yml
vendored
4
.github/workflows/docker-develop.yml
vendored
@ -13,10 +13,10 @@ jobs:
|
|||||||
if: github.repository == 'laoxong/misskey'
|
if: github.repository == 'laoxong/misskey'
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the repo
|
- name: Check out the repo
|
||||||
uses: actions/checkout@v3.3.0
|
uses: actions/checkout@v3.5.3
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.3.0
|
uses: docker/setup-buildx-action@v2.9.1
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
|
4
.github/workflows/docker.yml
vendored
4
.github/workflows/docker.yml
vendored
@ -12,10 +12,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out the repo
|
- name: Check out the repo
|
||||||
uses: actions/checkout@v3.3.0
|
uses: actions/checkout@v3.5.3
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
id: buildx
|
||||||
uses: docker/setup-buildx-action@v2.3.0
|
uses: docker/setup-buildx-action@v2.9.1
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64
|
platforms: linux/amd64,linux/arm64
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
|
2
.github/workflows/dockle.yml
vendored
2
.github/workflows/dockle.yml
vendored
@ -14,7 +14,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DOCKER_CONTENT_TRUST: 1
|
DOCKER_CONTENT_TRUST: 1
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.2.0
|
- uses: actions/checkout@v3.5.3
|
||||||
- run: |
|
- run: |
|
||||||
curl -L -o dockle.deb "https://github.com/goodwithtech/dockle/releases/download/v0.4.10/dockle_0.4.10_Linux-64bit.deb"
|
curl -L -o dockle.deb "https://github.com/goodwithtech/dockle/releases/download/v0.4.10/dockle_0.4.10_Linux-64bit.deb"
|
||||||
sudo dpkg -i dockle.deb
|
sudo dpkg -i dockle.deb
|
||||||
|
12
.github/workflows/lint.yml
vendored
12
.github/workflows/lint.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
|||||||
pnpm_install:
|
pnpm_install:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.5.3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
@ -19,7 +19,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: 8
|
version: 8
|
||||||
run_install: false
|
run_install: false
|
||||||
- uses: actions/setup-node@v3.6.0
|
- uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
@ -38,7 +38,7 @@ jobs:
|
|||||||
- sw
|
- sw
|
||||||
- misskey-js
|
- misskey-js
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.5.3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
@ -46,7 +46,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: 7
|
version: 7
|
||||||
run_install: false
|
run_install: false
|
||||||
- uses: actions/setup-node@v3.6.0
|
- uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
@ -64,7 +64,7 @@ jobs:
|
|||||||
- backend
|
- backend
|
||||||
- misskey-js
|
- misskey-js
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.5.3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
@ -72,7 +72,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
version: 7
|
version: 7
|
||||||
run_install: false
|
run_install: false
|
||||||
- uses: actions/setup-node@v3.6.0
|
- uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
2
.github/workflows/ok-to-test.yml
vendored
2
.github/workflows/ok-to-test.yml
vendored
@ -23,7 +23,7 @@ jobs:
|
|||||||
private_key: ${{ secrets.DEPLOYBOT_PRIVATE_KEY }}
|
private_key: ${{ secrets.DEPLOYBOT_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Slash Command Dispatch
|
- name: Slash Command Dispatch
|
||||||
uses: peter-evans/slash-command-dispatch@v1
|
uses: peter-evans/slash-command-dispatch@v3
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ steps.generate_token.outputs.token }}
|
TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||||
with:
|
with:
|
||||||
|
2
.github/workflows/pr-preview-deploy.yml
vendored
2
.github/workflows/pr-preview-deploy.yml
vendored
@ -53,7 +53,7 @@ jobs:
|
|||||||
|
|
||||||
# Check out merge commit
|
# Check out merge commit
|
||||||
- name: Fork based /deploy checkout
|
- name: Fork based /deploy checkout
|
||||||
uses: actions/checkout@v3.3.0
|
uses: actions/checkout@v3.5.3
|
||||||
with:
|
with:
|
||||||
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
|
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
|
||||||
|
|
||||||
|
4
.github/workflows/reviewer_lottery.yml
vendored
4
.github/workflows/reviewer_lottery.yml
vendored
@ -7,7 +7,7 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v3.5.3
|
||||||
- uses: uesteibar/reviewer-lottery@v2
|
- uses: uesteibar/reviewer-lottery@v3
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
6
.github/workflows/storybook.yml
vendored
6
.github/workflows/storybook.yml
vendored
@ -15,12 +15,12 @@ jobs:
|
|||||||
NODE_OPTIONS: "--max_old_space_size=7168"
|
NODE_OPTIONS: "--max_old_space_size=7168"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.5.3
|
||||||
if: github.event_name != 'pull_request_target'
|
if: github.event_name != 'pull_request_target'
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.5.3
|
||||||
if: github.event_name == 'pull_request_target'
|
if: github.event_name == 'pull_request_target'
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@ -38,7 +38,7 @@ jobs:
|
|||||||
version: 8
|
version: 8
|
||||||
run_install: false
|
run_install: false
|
||||||
- name: Use Node.js 20.x
|
- name: Use Node.js 20.x
|
||||||
uses: actions/setup-node@v3.6.0
|
uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version-file: '.node-version'
|
node-version-file: '.node-version'
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
4
.github/workflows/test-backend.yml
vendored
4
.github/workflows/test-backend.yml
vendored
@ -29,7 +29,7 @@ jobs:
|
|||||||
- 56312:6379
|
- 56312:6379
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.5.3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
@ -38,7 +38,7 @@ jobs:
|
|||||||
version: 8
|
version: 8
|
||||||
run_install: false
|
run_install: false
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v3.6.0
|
uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
8
.github/workflows/test-frontend.yml
vendored
8
.github/workflows/test-frontend.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
|||||||
node-version: [20.x]
|
node-version: [20.x]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.5.3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
@ -25,7 +25,7 @@ jobs:
|
|||||||
version: 8
|
version: 8
|
||||||
run_install: false
|
run_install: false
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v3.6.0
|
uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
@ -68,7 +68,7 @@ jobs:
|
|||||||
- 56312:6379
|
- 56312:6379
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.5.3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
# https://github.com/cypress-io/cypress-docker-images/issues/150
|
# https://github.com/cypress-io/cypress-docker-images/issues/150
|
||||||
@ -83,7 +83,7 @@ jobs:
|
|||||||
version: 7
|
version: 7
|
||||||
run_install: false
|
run_install: false
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v3.6.0
|
uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
4
.github/workflows/test-misskey-js.yml
vendored
4
.github/workflows/test-misskey-js.yml
vendored
@ -21,12 +21,12 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3.3.0
|
uses: actions/checkout@v3.5.3
|
||||||
|
|
||||||
- run: corepack enable
|
- run: corepack enable
|
||||||
|
|
||||||
- name: Setup Node.js ${{ matrix.node-version }}
|
- name: Setup Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v3.6.0
|
uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
4
.github/workflows/test-production.yml
vendored
4
.github/workflows/test-production.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
node-version: [20.x]
|
node-version: [20.x]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3.3.0
|
- uses: actions/checkout@v3.5.3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- name: Install pnpm
|
- name: Install pnpm
|
||||||
@ -28,7 +28,7 @@ jobs:
|
|||||||
version: 8
|
version: 8
|
||||||
run_install: false
|
run_install: false
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v3.6.0
|
uses: actions/setup-node@v3.8.0
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -16,6 +16,10 @@
|
|||||||
|
|
||||||
### General
|
### General
|
||||||
- OAuth 2.0のサポート
|
- OAuth 2.0のサポート
|
||||||
|
- お知らせ機能の強化
|
||||||
|
- ユーザー個別のお知らせを作成可能に
|
||||||
|
- お知らせのバナー表示やダイアログ表示が可能に
|
||||||
|
- お知らせのアイコンを設定可能に
|
||||||
- チャンネルをセンシティブ指定できるようになりました
|
- チャンネルをセンシティブ指定できるようになりました
|
||||||
|
|
||||||
### Client
|
### Client
|
||||||
@ -26,12 +30,14 @@
|
|||||||
- Fix: サーバー情報画面(`/instance-info/{domain}`)でブロックができないのを修正
|
- Fix: サーバー情報画面(`/instance-info/{domain}`)でブロックができないのを修正
|
||||||
- Fix: 未読のお知らせの「わかった」をクリック・タップしてもその場で「わかった」が消えない問題を修正
|
- Fix: 未読のお知らせの「わかった」をクリック・タップしてもその場で「わかった」が消えない問題を修正
|
||||||
- Fix: iOSで画面を回転させるとテキストサイズが変わる問題を修正
|
- Fix: iOSで画面を回転させるとテキストサイズが変わる問題を修正
|
||||||
|
- Fix: word mute for sub note is not applied
|
||||||
|
- Fix: タイムラインを下にスクロールしてノート画面に移動して再び戻ったら以前のスクロール位置を失う問題を修正
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
- cacheRemoteFilesの初期値はfalseになりました
|
- cacheRemoteFilesの初期値はfalseになりました
|
||||||
- 一部のfeatured noteを照会できない問題を修正
|
|
||||||
- ファイルアップロード時等にファイル名の拡張子を修正する関数(correctFilename)の挙動を改善
|
- ファイルアップロード時等にファイル名の拡張子を修正する関数(correctFilename)の挙動を改善
|
||||||
- fix: muteがapiからのuser list timeline取得で機能しない問題を修正
|
- Fix: 一部のfeatured noteを照会できない問題を修正
|
||||||
|
- Fix: muteがapiからのuser list timeline取得で機能しない問題を修正
|
||||||
|
|
||||||
## 13.14.2
|
## 13.14.2
|
||||||
|
|
||||||
|
16
locales/index.d.ts
vendored
16
locales/index.d.ts
vendored
@ -1098,6 +1098,22 @@ export interface Locale {
|
|||||||
"doYouAgree": string;
|
"doYouAgree": string;
|
||||||
"beSureToReadThisAsItIsImportant": string;
|
"beSureToReadThisAsItIsImportant": string;
|
||||||
"iHaveReadXCarefullyAndAgree": string;
|
"iHaveReadXCarefullyAndAgree": string;
|
||||||
|
"dialog": string;
|
||||||
|
"icon": string;
|
||||||
|
"forYou": string;
|
||||||
|
"currentAnnouncements": string;
|
||||||
|
"pastAnnouncements": string;
|
||||||
|
"youHaveUnreadAnnouncements": string;
|
||||||
|
"_announcement": {
|
||||||
|
"forExistingUsers": string;
|
||||||
|
"forExistingUsersDescription": string;
|
||||||
|
"needConfirmationToRead": string;
|
||||||
|
"needConfirmationToReadDescription": string;
|
||||||
|
"end": string;
|
||||||
|
"tooManyActiveAnnouncementDescription": string;
|
||||||
|
"readConfirmTitle": string;
|
||||||
|
"readConfirmText": string;
|
||||||
|
};
|
||||||
"_initialAccountSetting": {
|
"_initialAccountSetting": {
|
||||||
"accountCreated": string;
|
"accountCreated": string;
|
||||||
"letsStartAccountSetup": string;
|
"letsStartAccountSetup": string;
|
||||||
|
@ -330,7 +330,7 @@ watch: "ウォッチ"
|
|||||||
unwatch: "ウォッチ解除"
|
unwatch: "ウォッチ解除"
|
||||||
accept: "許可"
|
accept: "許可"
|
||||||
reject: "拒否"
|
reject: "拒否"
|
||||||
normal: "正常"
|
normal: "通常"
|
||||||
instanceName: "サーバー名"
|
instanceName: "サーバー名"
|
||||||
instanceDescription: "サーバーの紹介"
|
instanceDescription: "サーバーの紹介"
|
||||||
maintainerName: "管理者の名前"
|
maintainerName: "管理者の名前"
|
||||||
@ -1095,6 +1095,22 @@ expired: "期限切れ"
|
|||||||
doYouAgree: "同意しますか?"
|
doYouAgree: "同意しますか?"
|
||||||
beSureToReadThisAsItIsImportant: "重要ですので必ずお読みください。"
|
beSureToReadThisAsItIsImportant: "重要ですので必ずお読みください。"
|
||||||
iHaveReadXCarefullyAndAgree: "「{x}」の内容をよく読み、同意します。"
|
iHaveReadXCarefullyAndAgree: "「{x}」の内容をよく読み、同意します。"
|
||||||
|
dialog: "ダイアログ"
|
||||||
|
icon: "アイコン"
|
||||||
|
forYou: "あなたへ"
|
||||||
|
currentAnnouncements: "現在のお知らせ"
|
||||||
|
pastAnnouncements: "過去のお知らせ"
|
||||||
|
youHaveUnreadAnnouncements: "未読のお知らせがあります。"
|
||||||
|
|
||||||
|
_announcement:
|
||||||
|
forExistingUsers: "既存ユーザーのみ"
|
||||||
|
forExistingUsersDescription: "有効にすると、このお知らせ作成時点で存在するユーザーにのみお知らせが表示されます。無効にすると、このお知らせ作成後にアカウントを作成したユーザーにもお知らせが表示されます。"
|
||||||
|
needConfirmationToRead: "既読にするのに確認が必要"
|
||||||
|
needConfirmationToReadDescription: "有効にすると、このお知らせを既読にする際に確認ダイアログが表示されます。また、一括既読操作の対象になりません。"
|
||||||
|
end: "お知らせを終了"
|
||||||
|
tooManyActiveAnnouncementDescription: "アクティブなお知らせが多いため、UXが低下する可能性があります。終了したお知らせはアーカイブすることを検討してください。"
|
||||||
|
readConfirmTitle: "既読にしますか?"
|
||||||
|
readConfirmText: "「{title}」の内容を読み、既読にします。"
|
||||||
|
|
||||||
_initialAccountSetting:
|
_initialAccountSetting:
|
||||||
accountCreated: "アカウントの作成が完了しました!"
|
accountCreated: "アカウントの作成が完了しました!"
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
export class RefineAnnouncement1691649257651 {
|
||||||
|
name = 'RefineAnnouncement1691649257651'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" ADD "display" character varying(256) NOT NULL DEFAULT 'normal'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" ADD "needConfirmationToRead" boolean NOT NULL DEFAULT false`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" ADD "isActive" boolean NOT NULL DEFAULT true`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" ADD "forExistingUsers" boolean NOT NULL DEFAULT false`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" ADD "userId" character varying(32)`);
|
||||||
|
await queryRunner.query(`CREATE INDEX "IDX_bc1afcc8ef7e9400cdc3c0a87e" ON "announcement" ("isActive") `);
|
||||||
|
await queryRunner.query(`CREATE INDEX "IDX_da795d3a83187e8832005ba19d" ON "announcement" ("forExistingUsers") `);
|
||||||
|
await queryRunner.query(`CREATE INDEX "IDX_fd25dfe3da37df1715f11ba6ec" ON "announcement" ("userId") `);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" ADD CONSTRAINT "FK_fd25dfe3da37df1715f11ba6ec8" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" DROP CONSTRAINT "FK_fd25dfe3da37df1715f11ba6ec8"`);
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_fd25dfe3da37df1715f11ba6ec"`);
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_da795d3a83187e8832005ba19d"`);
|
||||||
|
await queryRunner.query(`DROP INDEX "public"."IDX_bc1afcc8ef7e9400cdc3c0a87e"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" DROP COLUMN "userId"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" DROP COLUMN "forExistingUsers"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" DROP COLUMN "isActive"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" DROP COLUMN "needConfirmationToRead"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" DROP COLUMN "display"`);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
export class RefineAnnouncement21691657412740 {
|
||||||
|
name = 'RefineAnnouncement21691657412740'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" ADD "icon" character varying(256) NOT NULL DEFAULT 'info'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TABLE "announcement" DROP COLUMN "icon"`);
|
||||||
|
}
|
||||||
|
}
|
135
packages/backend/src/core/AnnouncementService.ts
Normal file
135
packages/backend/src/core/AnnouncementService.ts
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { Brackets } from 'typeorm';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import type { User } from '@/models/entities/User.js';
|
||||||
|
import type { AnnouncementReadsRepository, AnnouncementsRepository, Announcement, AnnouncementRead } from '@/models/index.js';
|
||||||
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { Packed } from '@/misc/json-schema.js';
|
||||||
|
import { IdService } from '@/core/IdService.js';
|
||||||
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AnnouncementService {
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.announcementsRepository)
|
||||||
|
private announcementsRepository: AnnouncementsRepository,
|
||||||
|
|
||||||
|
@Inject(DI.announcementReadsRepository)
|
||||||
|
private announcementReadsRepository: AnnouncementReadsRepository,
|
||||||
|
|
||||||
|
private idService: IdService,
|
||||||
|
private globalEventService: GlobalEventService,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async getReads(userId: User['id']): Promise<AnnouncementRead[]> {
|
||||||
|
return this.announcementReadsRepository.findBy({
|
||||||
|
userId: userId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async getUnreadAnnouncements(user: User): Promise<Announcement[]> {
|
||||||
|
const readsQuery = this.announcementReadsRepository.createQueryBuilder('read')
|
||||||
|
.select('read.announcementId')
|
||||||
|
.where('read.userId = :userId', { userId: user.id });
|
||||||
|
|
||||||
|
const q = this.announcementsRepository.createQueryBuilder('announcement')
|
||||||
|
.where('announcement.isActive = true')
|
||||||
|
.andWhere(new Brackets(qb => {
|
||||||
|
qb.orWhere('announcement.userId = :userId', { userId: user.id });
|
||||||
|
qb.orWhere('announcement.userId IS NULL');
|
||||||
|
}))
|
||||||
|
.andWhere(new Brackets(qb => {
|
||||||
|
qb.orWhere('announcement.forExistingUsers = false');
|
||||||
|
qb.orWhere('announcement.createdAt > :createdAt', { createdAt: user.createdAt });
|
||||||
|
}))
|
||||||
|
.andWhere(`announcement.id NOT IN (${ readsQuery.getQuery() })`);
|
||||||
|
|
||||||
|
q.setParameters(readsQuery.getParameters());
|
||||||
|
|
||||||
|
return q.getMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async create(values: Partial<Announcement>): Promise<{ raw: Announcement; packed: Packed<'Announcement'> }> {
|
||||||
|
const announcement = await this.announcementsRepository.insert({
|
||||||
|
id: this.idService.genId(),
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: null,
|
||||||
|
title: values.title,
|
||||||
|
text: values.text,
|
||||||
|
imageUrl: values.imageUrl,
|
||||||
|
icon: values.icon,
|
||||||
|
display: values.display,
|
||||||
|
forExistingUsers: values.forExistingUsers,
|
||||||
|
needConfirmationToRead: values.needConfirmationToRead,
|
||||||
|
userId: values.userId,
|
||||||
|
}).then(x => this.announcementsRepository.findOneByOrFail(x.identifiers[0]));
|
||||||
|
|
||||||
|
const packed = (await this.packMany([announcement]))[0];
|
||||||
|
|
||||||
|
if (values.userId) {
|
||||||
|
this.globalEventService.publishMainStream(values.userId, 'announcementCreated', {
|
||||||
|
announcement: packed,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.globalEventService.publishBroadcastStream('announcementCreated', {
|
||||||
|
announcement: packed,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
raw: announcement,
|
||||||
|
packed: packed,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async read(user: User, announcementId: Announcement['id']): Promise<void> {
|
||||||
|
try {
|
||||||
|
await this.announcementReadsRepository.insert({
|
||||||
|
id: this.idService.genId(),
|
||||||
|
createdAt: new Date(),
|
||||||
|
announcementId: announcementId,
|
||||||
|
userId: user.id,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((await this.getUnreadAnnouncements(user)).length === 0) {
|
||||||
|
this.globalEventService.publishMainStream(user.id, 'readAllAnnouncements');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public async packMany(
|
||||||
|
announcements: Announcement[],
|
||||||
|
me?: { id: User['id'] } | null | undefined,
|
||||||
|
options?: {
|
||||||
|
reads?: AnnouncementRead[];
|
||||||
|
},
|
||||||
|
): Promise<Packed<'Announcement'>[]> {
|
||||||
|
const reads = me ? (options?.reads ?? await this.getReads(me.id)) : [];
|
||||||
|
return announcements.map(announcement => ({
|
||||||
|
id: announcement.id,
|
||||||
|
createdAt: announcement.createdAt.toISOString(),
|
||||||
|
updatedAt: announcement.updatedAt?.toISOString() ?? null,
|
||||||
|
text: announcement.text,
|
||||||
|
title: announcement.title,
|
||||||
|
imageUrl: announcement.imageUrl,
|
||||||
|
icon: announcement.icon,
|
||||||
|
display: announcement.display,
|
||||||
|
needConfirmationToRead: announcement.needConfirmationToRead,
|
||||||
|
forYou: announcement.userId === me?.id,
|
||||||
|
isRead: reads.some(read => read.announcementId === announcement.id),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ import { Module } from '@nestjs/common';
|
|||||||
import { AccountMoveService } from './AccountMoveService.js';
|
import { AccountMoveService } from './AccountMoveService.js';
|
||||||
import { AccountUpdateService } from './AccountUpdateService.js';
|
import { AccountUpdateService } from './AccountUpdateService.js';
|
||||||
import { AiService } from './AiService.js';
|
import { AiService } from './AiService.js';
|
||||||
|
import { AnnouncementService } from './AnnouncementService.js';
|
||||||
import { AntennaService } from './AntennaService.js';
|
import { AntennaService } from './AntennaService.js';
|
||||||
import { AppLockService } from './AppLockService.js';
|
import { AppLockService } from './AppLockService.js';
|
||||||
import { AchievementService } from './AchievementService.js';
|
import { AchievementService } from './AchievementService.js';
|
||||||
@ -130,6 +131,7 @@ const $LoggerService: Provider = { provide: 'LoggerService', useExisting: Logger
|
|||||||
const $AccountMoveService: Provider = { provide: 'AccountMoveService', useExisting: AccountMoveService };
|
const $AccountMoveService: Provider = { provide: 'AccountMoveService', useExisting: AccountMoveService };
|
||||||
const $AccountUpdateService: Provider = { provide: 'AccountUpdateService', useExisting: AccountUpdateService };
|
const $AccountUpdateService: Provider = { provide: 'AccountUpdateService', useExisting: AccountUpdateService };
|
||||||
const $AiService: Provider = { provide: 'AiService', useExisting: AiService };
|
const $AiService: Provider = { provide: 'AiService', useExisting: AiService };
|
||||||
|
const $AnnouncementService: Provider = { provide: 'AnnouncementService', useExisting: AnnouncementService };
|
||||||
const $AntennaService: Provider = { provide: 'AntennaService', useExisting: AntennaService };
|
const $AntennaService: Provider = { provide: 'AntennaService', useExisting: AntennaService };
|
||||||
const $AppLockService: Provider = { provide: 'AppLockService', useExisting: AppLockService };
|
const $AppLockService: Provider = { provide: 'AppLockService', useExisting: AppLockService };
|
||||||
const $AchievementService: Provider = { provide: 'AchievementService', useExisting: AchievementService };
|
const $AchievementService: Provider = { provide: 'AchievementService', useExisting: AchievementService };
|
||||||
@ -257,6 +259,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
AccountMoveService,
|
AccountMoveService,
|
||||||
AccountUpdateService,
|
AccountUpdateService,
|
||||||
AiService,
|
AiService,
|
||||||
|
AnnouncementService,
|
||||||
AntennaService,
|
AntennaService,
|
||||||
AppLockService,
|
AppLockService,
|
||||||
AchievementService,
|
AchievementService,
|
||||||
@ -377,6 +380,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
$AccountMoveService,
|
$AccountMoveService,
|
||||||
$AccountUpdateService,
|
$AccountUpdateService,
|
||||||
$AiService,
|
$AiService,
|
||||||
|
$AnnouncementService,
|
||||||
$AntennaService,
|
$AntennaService,
|
||||||
$AppLockService,
|
$AppLockService,
|
||||||
$AchievementService,
|
$AchievementService,
|
||||||
@ -498,6 +502,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
AccountMoveService,
|
AccountMoveService,
|
||||||
AccountUpdateService,
|
AccountUpdateService,
|
||||||
AiService,
|
AiService,
|
||||||
|
AnnouncementService,
|
||||||
AntennaService,
|
AntennaService,
|
||||||
AppLockService,
|
AppLockService,
|
||||||
AchievementService,
|
AchievementService,
|
||||||
@ -617,6 +622,7 @@ const $ApQuestionService: Provider = { provide: 'ApQuestionService', useExisting
|
|||||||
$AccountMoveService,
|
$AccountMoveService,
|
||||||
$AccountUpdateService,
|
$AccountUpdateService,
|
||||||
$AiService,
|
$AiService,
|
||||||
|
$AnnouncementService,
|
||||||
$AntennaService,
|
$AntennaService,
|
||||||
$AppLockService,
|
$AppLockService,
|
||||||
$AchievementService,
|
$AchievementService,
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { In, Not } from 'typeorm';
|
|
||||||
import * as Redis from 'ioredis';
|
import * as Redis from 'ioredis';
|
||||||
import _Ajv from 'ajv';
|
import _Ajv from 'ajv';
|
||||||
import { ModuleRef } from '@nestjs/core';
|
import { ModuleRef } from '@nestjs/core';
|
||||||
@ -16,13 +15,13 @@ import { awaitAll } from '@/misc/prelude/await-all.js';
|
|||||||
import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js';
|
import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js';
|
||||||
import type { LocalUser, PartialLocalUser, PartialRemoteUser, RemoteUser, User } from '@/models/entities/User.js';
|
import type { LocalUser, PartialLocalUser, PartialRemoteUser, RemoteUser, User } from '@/models/entities/User.js';
|
||||||
import { birthdaySchema, descriptionSchema, localUsernameSchema, locationSchema, nameSchema, passwordSchema } from '@/models/entities/User.js';
|
import { birthdaySchema, descriptionSchema, localUsernameSchema, locationSchema, nameSchema, passwordSchema } from '@/models/entities/User.js';
|
||||||
import type { UsersRepository, UserSecurityKeysRepository, FollowingsRepository, FollowRequestsRepository, BlockingsRepository, MutingsRepository, DriveFilesRepository, NoteUnreadsRepository, UserNotePiningsRepository, UserProfilesRepository, AnnouncementReadsRepository, AnnouncementsRepository, UserProfile, RenoteMutingsRepository, UserMemoRepository } from '@/models/index.js';
|
import type { UsersRepository, UserSecurityKeysRepository, FollowingsRepository, FollowRequestsRepository, BlockingsRepository, MutingsRepository, DriveFilesRepository, NoteUnreadsRepository, UserNotePiningsRepository, UserProfilesRepository, AnnouncementReadsRepository, AnnouncementsRepository, UserProfile, RenoteMutingsRepository, UserMemoRepository, Announcement } from '@/models/index.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
import type { OnModuleInit } from '@nestjs/common';
|
import type { OnModuleInit } from '@nestjs/common';
|
||||||
import type { AntennaService } from '../AntennaService.js';
|
import type { AnnouncementService } from '../AnnouncementService.js';
|
||||||
import type { CustomEmojiService } from '../CustomEmojiService.js';
|
import type { CustomEmojiService } from '../CustomEmojiService.js';
|
||||||
import type { NoteEntityService } from './NoteEntityService.js';
|
import type { NoteEntityService } from './NoteEntityService.js';
|
||||||
import type { DriveFileEntityService } from './DriveFileEntityService.js';
|
import type { DriveFileEntityService } from './DriveFileEntityService.js';
|
||||||
@ -58,7 +57,7 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
private driveFileEntityService: DriveFileEntityService;
|
private driveFileEntityService: DriveFileEntityService;
|
||||||
private pageEntityService: PageEntityService;
|
private pageEntityService: PageEntityService;
|
||||||
private customEmojiService: CustomEmojiService;
|
private customEmojiService: CustomEmojiService;
|
||||||
private antennaService: AntennaService;
|
private announcementService: AnnouncementService;
|
||||||
private roleService: RoleService;
|
private roleService: RoleService;
|
||||||
private federatedInstanceService: FederatedInstanceService;
|
private federatedInstanceService: FederatedInstanceService;
|
||||||
|
|
||||||
@ -128,7 +127,7 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
this.driveFileEntityService = this.moduleRef.get('DriveFileEntityService');
|
this.driveFileEntityService = this.moduleRef.get('DriveFileEntityService');
|
||||||
this.pageEntityService = this.moduleRef.get('PageEntityService');
|
this.pageEntityService = this.moduleRef.get('PageEntityService');
|
||||||
this.customEmojiService = this.moduleRef.get('CustomEmojiService');
|
this.customEmojiService = this.moduleRef.get('CustomEmojiService');
|
||||||
this.antennaService = this.moduleRef.get('AntennaService');
|
this.announcementService = this.moduleRef.get('AnnouncementService');
|
||||||
this.roleService = this.moduleRef.get('RoleService');
|
this.roleService = this.moduleRef.get('RoleService');
|
||||||
this.federatedInstanceService = this.moduleRef.get('FederatedInstanceService');
|
this.federatedInstanceService = this.moduleRef.get('FederatedInstanceService');
|
||||||
}
|
}
|
||||||
@ -208,19 +207,6 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
|
||||||
public async getHasUnreadAnnouncement(userId: User['id']): Promise<boolean> {
|
|
||||||
const reads = await this.announcementReadsRepository.findBy({
|
|
||||||
userId: userId,
|
|
||||||
});
|
|
||||||
|
|
||||||
const count = await this.announcementsRepository.countBy(reads.length > 0 ? {
|
|
||||||
id: Not(In(reads.map(read => read.announcementId))),
|
|
||||||
} : {});
|
|
||||||
|
|
||||||
return count > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async getHasUnreadAntenna(userId: User['id']): Promise<boolean> {
|
public async getHasUnreadAntenna(userId: User['id']): Promise<boolean> {
|
||||||
/*
|
/*
|
||||||
@ -347,6 +333,7 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
|
|
||||||
const isModerator = isMe && opts.detail ? this.roleService.isModerator(user) : null;
|
const isModerator = isMe && opts.detail ? this.roleService.isModerator(user) : null;
|
||||||
const isAdmin = isMe && opts.detail ? this.roleService.isAdministrator(user) : null;
|
const isAdmin = isMe && opts.detail ? this.roleService.isAdministrator(user) : null;
|
||||||
|
const unreadAnnouncements = isMe && opts.detail ? await this.announcementService.getUnreadAnnouncements(user) : null;
|
||||||
|
|
||||||
const falsy = opts.detail ? false : undefined;
|
const falsy = opts.detail ? false : undefined;
|
||||||
|
|
||||||
@ -456,7 +443,8 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
where: { userId: user.id, isMentioned: true },
|
where: { userId: user.id, isMentioned: true },
|
||||||
take: 1,
|
take: 1,
|
||||||
}).then(count => count > 0),
|
}).then(count => count > 0),
|
||||||
hasUnreadAnnouncement: this.getHasUnreadAnnouncement(user.id),
|
hasUnreadAnnouncement: unreadAnnouncements!.length > 0,
|
||||||
|
unreadAnnouncements,
|
||||||
hasUnreadAntenna: this.getHasUnreadAntenna(user.id),
|
hasUnreadAntenna: this.getHasUnreadAntenna(user.id),
|
||||||
hasUnreadChannel: false, // 後方互換性のため
|
hasUnreadChannel: false, // 後方互換性のため
|
||||||
hasUnreadNotification: this.getHasUnreadNotification(user.id),
|
hasUnreadNotification: this.getHasUnreadNotification(user.id),
|
||||||
|
@ -43,6 +43,8 @@ export function correctFilename(filename: string, ext: string | null) {
|
|||||||
// jpeg, tiffを同一視
|
// jpeg, tiffを同一視
|
||||||
dotExt === '.jpg' && filenameExt === '.jpeg' ||
|
dotExt === '.jpg' && filenameExt === '.jpeg' ||
|
||||||
dotExt === '.tif' && filenameExt === '.tiff' ||
|
dotExt === '.tif' && filenameExt === '.tiff' ||
|
||||||
|
// dllもexeもportable executableなので判定が正しく行われない
|
||||||
|
dotExt === '.exe' && filenameExt === '.dll' ||
|
||||||
|
|
||||||
// 圧縮形式っぽければ下手に拡張子を変えない
|
// 圧縮形式っぽければ下手に拡張子を変えない
|
||||||
// https://github.com/misskey-dev/misskey/issues/11482
|
// https://github.com/misskey-dev/misskey/issues/11482
|
||||||
|
@ -35,6 +35,7 @@ import { packedQueueCountSchema } from '@/models/json-schema/queue.js';
|
|||||||
import { packedGalleryPostSchema } from '@/models/json-schema/gallery-post.js';
|
import { packedGalleryPostSchema } from '@/models/json-schema/gallery-post.js';
|
||||||
import { packedEmojiDetailedSchema, packedEmojiSimpleSchema } from '@/models/json-schema/emoji.js';
|
import { packedEmojiDetailedSchema, packedEmojiSimpleSchema } from '@/models/json-schema/emoji.js';
|
||||||
import { packedFlashSchema } from '@/models/json-schema/flash.js';
|
import { packedFlashSchema } from '@/models/json-schema/flash.js';
|
||||||
|
import { packedAnnouncementSchema } from '@/models/json-schema/announcement.js';
|
||||||
|
|
||||||
export const refs = {
|
export const refs = {
|
||||||
UserLite: packedUserLiteSchema,
|
UserLite: packedUserLiteSchema,
|
||||||
@ -46,6 +47,7 @@ export const refs = {
|
|||||||
User: packedUserSchema,
|
User: packedUserSchema,
|
||||||
|
|
||||||
UserList: packedUserListSchema,
|
UserList: packedUserListSchema,
|
||||||
|
Announcement: packedAnnouncementSchema,
|
||||||
App: packedAppSchema,
|
App: packedAppSchema,
|
||||||
Note: packedNoteSchema,
|
Note: packedNoteSchema,
|
||||||
NoteReaction: packedNoteReactionSchema,
|
NoteReaction: packedNoteReactionSchema,
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Entity, Index, Column, PrimaryColumn } from 'typeorm';
|
import { Entity, Index, Column, PrimaryColumn, ManyToOne, JoinColumn } from 'typeorm';
|
||||||
import { id } from '../id.js';
|
import { id } from '../id.js';
|
||||||
|
import { User } from './User.js';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Announcement {
|
export class Announcement {
|
||||||
@ -38,6 +39,52 @@ export class Announcement {
|
|||||||
})
|
})
|
||||||
public imageUrl: string | null;
|
public imageUrl: string | null;
|
||||||
|
|
||||||
|
// info, warning, error, success
|
||||||
|
@Column('varchar', {
|
||||||
|
length: 256, nullable: false,
|
||||||
|
default: 'info',
|
||||||
|
})
|
||||||
|
public icon: string;
|
||||||
|
|
||||||
|
// normal ... お知らせページ掲載
|
||||||
|
// banner ... お知らせページ掲載 + バナー表示
|
||||||
|
// dialog ... お知らせページ掲載 + ダイアログ表示
|
||||||
|
@Column('varchar', {
|
||||||
|
length: 256, nullable: false,
|
||||||
|
default: 'normal',
|
||||||
|
})
|
||||||
|
public display: string;
|
||||||
|
|
||||||
|
@Column('boolean', {
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
public needConfirmationToRead: boolean;
|
||||||
|
|
||||||
|
@Index()
|
||||||
|
@Column('boolean', {
|
||||||
|
default: true,
|
||||||
|
})
|
||||||
|
public isActive: boolean;
|
||||||
|
|
||||||
|
@Index()
|
||||||
|
@Column('boolean', {
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
public forExistingUsers: boolean;
|
||||||
|
|
||||||
|
@Index()
|
||||||
|
@Column({
|
||||||
|
...id(),
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
|
public userId: User['id'] | null;
|
||||||
|
|
||||||
|
@ManyToOne(type => User, {
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
})
|
||||||
|
@JoinColumn()
|
||||||
|
public user: User | null;
|
||||||
|
|
||||||
constructor(data: Partial<Announcement>) {
|
constructor(data: Partial<Announcement>) {
|
||||||
if (data == null) return;
|
if (data == null) return;
|
||||||
|
|
||||||
|
58
packages/backend/src/models/json-schema/announcement.ts
Normal file
58
packages/backend/src/models/json-schema/announcement.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const packedAnnouncementSchema = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
format: 'id',
|
||||||
|
example: 'xxxxxxxxxx',
|
||||||
|
},
|
||||||
|
createdAt: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
format: 'date-time',
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: true,
|
||||||
|
format: 'date-time',
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
imageUrl: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: true,
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
display: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
forYou: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
needConfirmationToRead: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
},
|
||||||
|
isRead: {
|
||||||
|
type: 'boolean',
|
||||||
|
optional: true, nullable: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as const;
|
@ -3,11 +3,9 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { AnnouncementsRepository } from '@/models/index.js';
|
import { AnnouncementService } from '@/core/AnnouncementService.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
|
||||||
import { DI } from '@/di-symbols.js';
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
@ -57,6 +55,11 @@ export const paramDef = {
|
|||||||
title: { type: 'string', minLength: 1 },
|
title: { type: 'string', minLength: 1 },
|
||||||
text: { type: 'string', minLength: 1 },
|
text: { type: 'string', minLength: 1 },
|
||||||
imageUrl: { type: 'string', nullable: true, minLength: 1 },
|
imageUrl: { type: 'string', nullable: true, minLength: 1 },
|
||||||
|
icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'], default: 'info' },
|
||||||
|
display: { type: 'string', enum: ['normal', 'banner', 'dialog'], default: 'normal' },
|
||||||
|
forExistingUsers: { type: 'boolean', default: false },
|
||||||
|
needConfirmationToRead: { type: 'boolean', default: false },
|
||||||
|
userId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
||||||
},
|
},
|
||||||
required: ['title', 'text', 'imageUrl'],
|
required: ['title', 'text', 'imageUrl'],
|
||||||
} as const;
|
} as const;
|
||||||
@ -65,22 +68,23 @@ export const paramDef = {
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.announcementsRepository)
|
private announcementService: AnnouncementService,
|
||||||
private announcementsRepository: AnnouncementsRepository,
|
|
||||||
|
|
||||||
private idService: IdService,
|
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const announcement = await this.announcementsRepository.insert({
|
const { raw, packed } = await this.announcementService.create({
|
||||||
id: this.idService.genId(),
|
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
updatedAt: null,
|
updatedAt: null,
|
||||||
title: ps.title,
|
title: ps.title,
|
||||||
text: ps.text,
|
text: ps.text,
|
||||||
imageUrl: ps.imageUrl,
|
imageUrl: ps.imageUrl,
|
||||||
}).then(x => this.announcementsRepository.findOneByOrFail(x.identifiers[0]));
|
icon: ps.icon,
|
||||||
|
display: ps.display,
|
||||||
|
forExistingUsers: ps.forExistingUsers,
|
||||||
|
needConfirmationToRead: ps.needConfirmationToRead,
|
||||||
|
userId: ps.userId,
|
||||||
|
});
|
||||||
|
|
||||||
return Object.assign({}, announcement, { createdAt: announcement.createdAt.toISOString(), updatedAt: null });
|
return packed;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ export const paramDef = {
|
|||||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
sinceId: { type: 'string', format: 'misskey:id' },
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
untilId: { type: 'string', format: 'misskey:id' },
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
userId: { type: 'string', format: 'misskey:id', nullable: true },
|
||||||
},
|
},
|
||||||
required: [],
|
required: [],
|
||||||
} as const;
|
} as const;
|
||||||
@ -84,6 +85,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
|
const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
|
||||||
|
if (ps.userId) {
|
||||||
|
query.andWhere('announcement.userId = :userId', { userId: ps.userId });
|
||||||
|
} else {
|
||||||
|
query.andWhere('announcement.userId IS NULL');
|
||||||
|
}
|
||||||
|
|
||||||
const announcements = await query.limit(ps.limit).getMany();
|
const announcements = await query.limit(ps.limit).getMany();
|
||||||
|
|
||||||
@ -102,6 +108,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||||||
title: announcement.title,
|
title: announcement.title,
|
||||||
text: announcement.text,
|
text: announcement.text,
|
||||||
imageUrl: announcement.imageUrl,
|
imageUrl: announcement.imageUrl,
|
||||||
|
icon: announcement.icon,
|
||||||
|
display: announcement.display,
|
||||||
|
isActive: announcement.isActive,
|
||||||
|
forExistingUsers: announcement.forExistingUsers,
|
||||||
|
needConfirmationToRead: announcement.needConfirmationToRead,
|
||||||
|
userId: announcement.userId,
|
||||||
reads: reads.get(announcement)!,
|
reads: reads.get(announcement)!,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -31,8 +31,13 @@ export const paramDef = {
|
|||||||
title: { type: 'string', minLength: 1 },
|
title: { type: 'string', minLength: 1 },
|
||||||
text: { type: 'string', minLength: 1 },
|
text: { type: 'string', minLength: 1 },
|
||||||
imageUrl: { type: 'string', nullable: true, minLength: 0 },
|
imageUrl: { type: 'string', nullable: true, minLength: 0 },
|
||||||
|
icon: { type: 'string', enum: ['info', 'warning', 'error', 'success'] },
|
||||||
|
display: { type: 'string', enum: ['normal', 'banner', 'dialog'] },
|
||||||
|
forExistingUsers: { type: 'boolean' },
|
||||||
|
needConfirmationToRead: { type: 'boolean' },
|
||||||
|
isActive: { type: 'boolean' },
|
||||||
},
|
},
|
||||||
required: ['id', 'title', 'text', 'imageUrl'],
|
required: ['id'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
@ -53,6 +58,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||||||
text: ps.text,
|
text: ps.text,
|
||||||
/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- 空の文字列の場合、nullを渡すようにするため */
|
/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- 空の文字列の場合、nullを渡すようにするため */
|
||||||
imageUrl: ps.imageUrl || null,
|
imageUrl: ps.imageUrl || null,
|
||||||
|
display: ps.display,
|
||||||
|
icon: ps.icon,
|
||||||
|
forExistingUsers: ps.forExistingUsers,
|
||||||
|
needConfirmationToRead: ps.needConfirmationToRead,
|
||||||
|
isActive: ps.isActive,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
import { Brackets } from 'typeorm';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { QueryService } from '@/core/QueryService.js';
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
|
import { AnnouncementService } from '@/core/AnnouncementService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { AnnouncementReadsRepository, AnnouncementsRepository } from '@/models/index.js';
|
import type { AnnouncementReadsRepository, AnnouncementsRepository } from '@/models/index.js';
|
||||||
|
|
||||||
@ -20,40 +22,7 @@ export const meta = {
|
|||||||
items: {
|
items: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
properties: {
|
ref: 'Announcement',
|
||||||
id: {
|
|
||||||
type: 'string',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
format: 'id',
|
|
||||||
example: 'xxxxxxxxxx',
|
|
||||||
},
|
|
||||||
createdAt: {
|
|
||||||
type: 'string',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
format: 'date-time',
|
|
||||||
},
|
|
||||||
updatedAt: {
|
|
||||||
type: 'string',
|
|
||||||
optional: false, nullable: true,
|
|
||||||
format: 'date-time',
|
|
||||||
},
|
|
||||||
text: {
|
|
||||||
type: 'string',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
type: 'string',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
imageUrl: {
|
|
||||||
type: 'string',
|
|
||||||
optional: false, nullable: true,
|
|
||||||
},
|
|
||||||
isRead: {
|
|
||||||
type: 'boolean',
|
|
||||||
optional: true, nullable: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
@ -62,9 +31,9 @@ export const paramDef = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
||||||
withUnreads: { type: 'boolean', default: false },
|
|
||||||
sinceId: { type: 'string', format: 'misskey:id' },
|
sinceId: { type: 'string', format: 'misskey:id' },
|
||||||
untilId: { type: 'string', format: 'misskey:id' },
|
untilId: { type: 'string', format: 'misskey:id' },
|
||||||
|
isActive: { type: 'boolean', default: true },
|
||||||
},
|
},
|
||||||
required: [],
|
required: [],
|
||||||
} as const;
|
} as const;
|
||||||
@ -80,27 +49,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|||||||
private announcementReadsRepository: AnnouncementReadsRepository,
|
private announcementReadsRepository: AnnouncementReadsRepository,
|
||||||
|
|
||||||
private queryService: QueryService,
|
private queryService: QueryService,
|
||||||
|
private announcementService: AnnouncementService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId);
|
const query = this.queryService.makePaginationQuery(this.announcementsRepository.createQueryBuilder('announcement'), ps.sinceId, ps.untilId)
|
||||||
|
.where('announcement.isActive = :isActive', { isActive: ps.isActive })
|
||||||
|
.andWhere(new Brackets(qb => {
|
||||||
|
if (me) qb.orWhere('announcement.userId = :meId', { meId: me.id });
|
||||||
|
qb.orWhere('announcement.userId IS NULL');
|
||||||
|
}));
|
||||||
|
|
||||||
const announcements = await query.limit(ps.limit).getMany();
|
const announcements = await query.limit(ps.limit).getMany();
|
||||||
|
|
||||||
if (me) {
|
return this.announcementService.packMany(announcements, me);
|
||||||
const reads = (await this.announcementReadsRepository.findBy({
|
|
||||||
userId: me.id,
|
|
||||||
})).map(x => x.announcementId);
|
|
||||||
|
|
||||||
for (const announcement of announcements) {
|
|
||||||
(announcement as any).isRead = reads.includes(announcement.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ps.withUnreads ? announcements.filter((a: any) => !a.isRead) : announcements).map((a) => ({
|
|
||||||
...a,
|
|
||||||
createdAt: a.createdAt.toISOString(),
|
|
||||||
updatedAt: a.updatedAt?.toISOString() ?? null,
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,9 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { AnnouncementService } from '@/core/AnnouncementService.js';
|
||||||
import type { AnnouncementReadsRepository, AnnouncementsRepository } from '@/models/index.js';
|
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
|
||||||
import { DI } from '@/di-symbols.js';
|
|
||||||
import { ApiError } from '../../error.js';
|
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['account'],
|
tags: ['account'],
|
||||||
@ -20,11 +15,6 @@ export const meta = {
|
|||||||
kind: 'write:account',
|
kind: 'write:account',
|
||||||
|
|
||||||
errors: {
|
errors: {
|
||||||
noSuchAnnouncement: {
|
|
||||||
message: 'No such announcement.',
|
|
||||||
code: 'NO_SUCH_ANNOUNCEMENT',
|
|
||||||
id: '184663db-df88-4bc2-8b52-fb85f0681939',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
@ -40,47 +30,10 @@ export const paramDef = {
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.announcementsRepository)
|
private announcementService: AnnouncementService,
|
||||||
private announcementsRepository: AnnouncementsRepository,
|
|
||||||
|
|
||||||
@Inject(DI.announcementReadsRepository)
|
|
||||||
private announcementReadsRepository: AnnouncementReadsRepository,
|
|
||||||
|
|
||||||
private userEntityService: UserEntityService,
|
|
||||||
private idService: IdService,
|
|
||||||
private globalEventService: GlobalEventService,
|
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
// Check if announcement exists
|
await this.announcementService.read(me, ps.announcementId);
|
||||||
const announcementExist = await this.announcementsRepository.exist({ where: { id: ps.announcementId } });
|
|
||||||
|
|
||||||
if (!announcementExist) {
|
|
||||||
throw new ApiError(meta.errors.noSuchAnnouncement);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if already read
|
|
||||||
const alreadyRead = await this.announcementReadsRepository.exist({
|
|
||||||
where: {
|
|
||||||
announcementId: ps.announcementId,
|
|
||||||
userId: me.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
if (alreadyRead) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create read
|
|
||||||
await this.announcementReadsRepository.insert({
|
|
||||||
id: this.idService.genId(),
|
|
||||||
createdAt: new Date(),
|
|
||||||
announcementId: ps.announcementId,
|
|
||||||
userId: me.id,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!await this.userEntityService.getHasUnreadAnnouncement(me.id)) {
|
|
||||||
this.globalEventService.publishMainStream(me.id, 'readAllAnnouncements');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,9 @@ export interface BroadcastTypes {
|
|||||||
[other: string]: any;
|
[other: string]: any;
|
||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
|
announcementCreated: {
|
||||||
|
announcement: Packed<'Announcement'>;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MainStreamTypes {
|
export interface MainStreamTypes {
|
||||||
@ -105,6 +108,9 @@ export interface MainStreamTypes {
|
|||||||
driveFileCreated: Packed<'DriveFile'>;
|
driveFileCreated: Packed<'DriveFile'>;
|
||||||
readAntenna: Antenna;
|
readAntenna: Antenna;
|
||||||
receiveFollowRequest: Packed<'User'>;
|
receiveFollowRequest: Packed<'User'>;
|
||||||
|
announcementCreated: {
|
||||||
|
announcement: Packed<'Announcement'>;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DriveStreamTypes {
|
export interface DriveStreamTypes {
|
||||||
|
@ -160,6 +160,7 @@ describe('ユーザー', () => {
|
|||||||
hasUnreadChannel: user.hasUnreadChannel,
|
hasUnreadChannel: user.hasUnreadChannel,
|
||||||
hasUnreadNotification: user.hasUnreadNotification,
|
hasUnreadNotification: user.hasUnreadNotification,
|
||||||
hasPendingReceivedFollowRequest: user.hasPendingReceivedFollowRequest,
|
hasPendingReceivedFollowRequest: user.hasPendingReceivedFollowRequest,
|
||||||
|
unreadAnnouncements: user.unreadAnnouncements,
|
||||||
mutedWords: user.mutedWords,
|
mutedWords: user.mutedWords,
|
||||||
mutedInstances: user.mutedInstances,
|
mutedInstances: user.mutedInstances,
|
||||||
mutingNotificationTypes: user.mutingNotificationTypes,
|
mutingNotificationTypes: user.mutingNotificationTypes,
|
||||||
@ -405,6 +406,7 @@ describe('ユーザー', () => {
|
|||||||
assert.strictEqual(response.hasUnreadChannel, false);
|
assert.strictEqual(response.hasUnreadChannel, false);
|
||||||
assert.strictEqual(response.hasUnreadNotification, false);
|
assert.strictEqual(response.hasUnreadNotification, false);
|
||||||
assert.strictEqual(response.hasPendingReceivedFollowRequest, false);
|
assert.strictEqual(response.hasPendingReceivedFollowRequest, false);
|
||||||
|
assert.deepStrictEqual(response.unreadAnnouncements, []);
|
||||||
assert.deepStrictEqual(response.mutedWords, []);
|
assert.deepStrictEqual(response.mutedWords, []);
|
||||||
assert.deepStrictEqual(response.mutedInstances, []);
|
assert.deepStrictEqual(response.mutedInstances, []);
|
||||||
assert.deepStrictEqual(response.mutingNotificationTypes, []);
|
assert.deepStrictEqual(response.mutingNotificationTypes, []);
|
||||||
|
194
packages/backend/test/unit/AnnouncementService.ts
Normal file
194
packages/backend/test/unit/AnnouncementService.ts
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
process.env.NODE_ENV = 'test';
|
||||||
|
|
||||||
|
import { jest } from '@jest/globals';
|
||||||
|
import { ModuleMocker } from 'jest-mock';
|
||||||
|
import { Test } from '@nestjs/testing';
|
||||||
|
import { GlobalModule } from '@/GlobalModule.js';
|
||||||
|
import { AnnouncementService } from '@/core/AnnouncementService.js';
|
||||||
|
import type { Announcement, AnnouncementsRepository, AnnouncementReadsRepository, UsersRepository, User } from '@/models/index.js';
|
||||||
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { genAid } from '@/misc/id/aid.js';
|
||||||
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
|
import { IdService } from '@/core/IdService.js';
|
||||||
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
|
import type { TestingModule } from '@nestjs/testing';
|
||||||
|
import type { MockFunctionMetadata } from 'jest-mock';
|
||||||
|
|
||||||
|
const moduleMocker = new ModuleMocker(global);
|
||||||
|
|
||||||
|
describe('AnnouncementService', () => {
|
||||||
|
let app: TestingModule;
|
||||||
|
let announcementService: AnnouncementService;
|
||||||
|
let usersRepository: UsersRepository;
|
||||||
|
let announcementsRepository: AnnouncementsRepository;
|
||||||
|
let announcementReadsRepository: AnnouncementReadsRepository;
|
||||||
|
let globalEventService: jest.Mocked<GlobalEventService>;
|
||||||
|
|
||||||
|
function createUser(data: Partial<User> = {}) {
|
||||||
|
const un = secureRndstr(16);
|
||||||
|
return usersRepository.insert({
|
||||||
|
id: genAid(new Date()),
|
||||||
|
createdAt: new Date(),
|
||||||
|
username: un,
|
||||||
|
usernameLower: un,
|
||||||
|
...data,
|
||||||
|
})
|
||||||
|
.then(x => usersRepository.findOneByOrFail(x.identifiers[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAnnouncement(data: Partial<Announcement> = {}) {
|
||||||
|
return announcementsRepository.insert({
|
||||||
|
id: genAid(new Date()),
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: null,
|
||||||
|
title: 'Title',
|
||||||
|
text: 'Text',
|
||||||
|
...data,
|
||||||
|
})
|
||||||
|
.then(x => announcementsRepository.findOneByOrFail(x.identifiers[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
app = await Test.createTestingModule({
|
||||||
|
imports: [
|
||||||
|
GlobalModule,
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
AnnouncementService,
|
||||||
|
CacheService,
|
||||||
|
IdService,
|
||||||
|
],
|
||||||
|
})
|
||||||
|
.useMocker((token) => {
|
||||||
|
if (token === GlobalEventService) {
|
||||||
|
return {
|
||||||
|
publishMainStream: jest.fn(),
|
||||||
|
publishBroadcastStream: jest.fn(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (typeof token === 'function') {
|
||||||
|
const mockMetadata = moduleMocker.getMetadata(token) as MockFunctionMetadata<any, any>;
|
||||||
|
const Mock = moduleMocker.generateFromMetadata(mockMetadata);
|
||||||
|
return new Mock();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.compile();
|
||||||
|
|
||||||
|
app.enableShutdownHooks();
|
||||||
|
|
||||||
|
announcementService = app.get<AnnouncementService>(AnnouncementService);
|
||||||
|
usersRepository = app.get<UsersRepository>(DI.usersRepository);
|
||||||
|
announcementsRepository = app.get<AnnouncementsRepository>(DI.announcementsRepository);
|
||||||
|
announcementReadsRepository = app.get<AnnouncementReadsRepository>(DI.announcementReadsRepository);
|
||||||
|
globalEventService = app.get<GlobalEventService>(GlobalEventService) as jest.Mocked<GlobalEventService>;
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await Promise.all([
|
||||||
|
app.get(DI.metasRepository).delete({}),
|
||||||
|
usersRepository.delete({}),
|
||||||
|
announcementsRepository.delete({}),
|
||||||
|
announcementReadsRepository.delete({}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
await app.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getUnreadAnnouncements', () => {
|
||||||
|
test('通常', async () => {
|
||||||
|
const user = await createUser();
|
||||||
|
const announcement = await createAnnouncement({
|
||||||
|
title: '1',
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await announcementService.getUnreadAnnouncements(user);
|
||||||
|
|
||||||
|
expect(result.length).toBe(1);
|
||||||
|
expect(result[0].title).toBe(announcement.title);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('isActiveがfalseは除外', async () => {
|
||||||
|
const user = await createUser();
|
||||||
|
await createAnnouncement({
|
||||||
|
isActive: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await announcementService.getUnreadAnnouncements(user);
|
||||||
|
|
||||||
|
expect(result.length).toBe(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('forExistingUsers', async () => {
|
||||||
|
const user = await createUser();
|
||||||
|
const [announcementAfter, announcementBefore, announcementBefore2] = await Promise.all([
|
||||||
|
createAnnouncement({
|
||||||
|
title: 'after',
|
||||||
|
createdAt: new Date(),
|
||||||
|
forExistingUsers: true,
|
||||||
|
}),
|
||||||
|
createAnnouncement({
|
||||||
|
title: 'before',
|
||||||
|
createdAt: new Date(Date.now() - 1000),
|
||||||
|
forExistingUsers: true,
|
||||||
|
}),
|
||||||
|
createAnnouncement({
|
||||||
|
title: 'before2',
|
||||||
|
createdAt: new Date(Date.now() - 1000),
|
||||||
|
forExistingUsers: false,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const result = await announcementService.getUnreadAnnouncements(user);
|
||||||
|
|
||||||
|
expect(result.length).toBe(2);
|
||||||
|
expect(result.some(a => a.title === announcementAfter.title)).toBe(true);
|
||||||
|
expect(result.some(a => a.title === announcementBefore.title)).toBe(false);
|
||||||
|
expect(result.some(a => a.title === announcementBefore2.title)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('create', () => {
|
||||||
|
test('通常', async () => {
|
||||||
|
const result = await announcementService.create({
|
||||||
|
title: 'Title',
|
||||||
|
text: 'Text',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.raw.title).toBe('Title');
|
||||||
|
expect(result.packed.title).toBe('Title');
|
||||||
|
|
||||||
|
expect(globalEventService.publishBroadcastStream).toHaveBeenCalled();
|
||||||
|
expect(globalEventService.publishBroadcastStream.mock.lastCall![0]).toBe('announcementCreated');
|
||||||
|
expect((globalEventService.publishBroadcastStream.mock.lastCall![1] as any).announcement).toBe(result.packed);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('ユーザー指定', async () => {
|
||||||
|
const user = await createUser();
|
||||||
|
const result = await announcementService.create({
|
||||||
|
title: 'Title',
|
||||||
|
text: 'Text',
|
||||||
|
userId: user.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(result.raw.title).toBe('Title');
|
||||||
|
expect(result.packed.title).toBe('Title');
|
||||||
|
|
||||||
|
expect(globalEventService.publishBroadcastStream).not.toHaveBeenCalled();
|
||||||
|
expect(globalEventService.publishMainStream).toHaveBeenCalled();
|
||||||
|
expect(globalEventService.publishMainStream.mock.lastCall![0]).toBe(user.id);
|
||||||
|
expect(globalEventService.publishMainStream.mock.lastCall![1]).toBe('announcementCreated');
|
||||||
|
expect((globalEventService.publishMainStream.mock.lastCall![2] as any).announcement).toBe(result.packed);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('read', () => {
|
||||||
|
// TODO
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -96,7 +96,6 @@ export async function removeAccount(idOrToken: Account['id']) {
|
|||||||
|
|
||||||
function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Promise<Account> {
|
function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Promise<Account> {
|
||||||
return new Promise((done, fail) => {
|
return new Promise((done, fail) => {
|
||||||
// Fetch user
|
|
||||||
window.fetch(`${apiUrl}/i`, {
|
window.fetch(`${apiUrl}/i`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@ -108,8 +107,8 @@ function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Pr
|
|||||||
})
|
})
|
||||||
.then(res => new Promise<Account | { error: Record<string, any> }>((done2, fail2) => {
|
.then(res => new Promise<Account | { error: Record<string, any> }>((done2, fail2) => {
|
||||||
if (res.status >= 500 && res.status < 600) {
|
if (res.status >= 500 && res.status < 600) {
|
||||||
// サーバーエラー(5xx)の場合をrejectとする
|
// サーバーエラー(5xx)の場合をrejectとする
|
||||||
// (認証エラーなど4xxはresolve)
|
// (認証エラーなど4xxはresolve)
|
||||||
return fail2(res);
|
return fail2(res);
|
||||||
}
|
}
|
||||||
res.json().then(done2, fail2);
|
res.json().then(done2, fail2);
|
||||||
|
@ -83,6 +83,21 @@ export async function mainBoot() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (const announcement of ($i.unreadAnnouncements ?? []).filter(x => x.display === 'dialog')) {
|
||||||
|
popup(defineAsyncComponent(() => import('@/components/MkAnnouncementDialog.vue')), {
|
||||||
|
announcement,
|
||||||
|
}, {}, 'closed');
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.on('announcementCreated', (ev) => {
|
||||||
|
const announcement = ev.announcement;
|
||||||
|
if (announcement.display === 'dialog') {
|
||||||
|
popup(defineAsyncComponent(() => import('@/components/MkAnnouncementDialog.vue')), {
|
||||||
|
announcement,
|
||||||
|
}, {}, 'closed');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if ($i.isDeleted) {
|
if ($i.isDeleted) {
|
||||||
alert({
|
alert({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
|
@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<template>
|
<template>
|
||||||
<div class="bcekxzvu _margin _panel">
|
<div class="bcekxzvu _margin _panel">
|
||||||
<div class="target">
|
<div class="target">
|
||||||
<MkA v-user-preview="report.targetUserId" class="info" :to="`/user-info/${report.targetUserId}`">
|
<MkA v-user-preview="report.targetUserId" class="info" :to="`/admin/user/${report.targetUserId}`">
|
||||||
<MkAvatar class="avatar" :user="report.targetUser" indicator/>
|
<MkAvatar class="avatar" :user="report.targetUser" indicator/>
|
||||||
<div class="names">
|
<div class="names">
|
||||||
<MkUserName class="name" :user="report.targetUser"/>
|
<MkUserName class="name" :user="report.targetUser"/>
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||||
|
import { StoryObj } from '@storybook/vue3';
|
||||||
|
import MkAnnouncementDialog from './MkAnnouncementDialog.vue';
|
||||||
|
export const Default = {
|
||||||
|
render(args) {
|
||||||
|
return {
|
||||||
|
components: {
|
||||||
|
MkAnnouncementDialog,
|
||||||
|
},
|
||||||
|
setup() {
|
||||||
|
return {
|
||||||
|
args,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
props() {
|
||||||
|
return {
|
||||||
|
...this.args,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
},
|
||||||
|
template: '<MkAnnouncementDialog v-bind="props" />',
|
||||||
|
};
|
||||||
|
},
|
||||||
|
args: {
|
||||||
|
announcement: {
|
||||||
|
id: '1',
|
||||||
|
title: 'Title',
|
||||||
|
text: 'Text',
|
||||||
|
createdAt: new Date().toISOString(),
|
||||||
|
updatedAt: null,
|
||||||
|
icon: 'info',
|
||||||
|
imageUrl: null,
|
||||||
|
display: 'dialog',
|
||||||
|
needConfirmationToRead: false,
|
||||||
|
forYou: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
parameters: {
|
||||||
|
layout: 'centered',
|
||||||
|
},
|
||||||
|
} satisfies StoryObj<typeof MkAnnouncementDialog>;
|
104
packages/frontend/src/components/MkAnnouncementDialog.vue
Normal file
104
packages/frontend/src/components/MkAnnouncementDialog.vue
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<MkModal ref="modal" :zPriority="'middle'" @closed="$emit('closed')" @click="onBgClick">
|
||||||
|
<div ref="rootEl" :class="$style.root">
|
||||||
|
<div :class="$style.header">
|
||||||
|
<span :class="$style.icon">
|
||||||
|
<i v-if="announcement.icon === 'info'" class="ti ti-info-circle"></i>
|
||||||
|
<i v-else-if="announcement.icon === 'warning'" class="ti ti-alert-triangle" style="color: var(--warn);"></i>
|
||||||
|
<i v-else-if="announcement.icon === 'error'" class="ti ti-circle-x" style="color: var(--error);"></i>
|
||||||
|
<i v-else-if="announcement.icon === 'success'" class="ti ti-check" style="color: var(--success);"></i>
|
||||||
|
</span>
|
||||||
|
<span :class="$style.title">{{ announcement.title }}</span>
|
||||||
|
</div>
|
||||||
|
<div :class="$style.text"><Mfm :text="announcement.text"/></div>
|
||||||
|
<MkButton primary full @click="ok">{{ i18n.ts.ok }}</MkButton>
|
||||||
|
</div>
|
||||||
|
</MkModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { onMounted, shallowRef } from 'vue';
|
||||||
|
import * as misskey from 'misskey-js';
|
||||||
|
import * as os from '@/os';
|
||||||
|
import MkModal from '@/components/MkModal.vue';
|
||||||
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
import { $i, updateAccount } from '@/account';
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
announcement: misskey.entities.Announcement;
|
||||||
|
}>(), {
|
||||||
|
});
|
||||||
|
|
||||||
|
const rootEl = shallowRef<HTMLDivElement>();
|
||||||
|
const modal = shallowRef<InstanceType<typeof MkModal>>();
|
||||||
|
|
||||||
|
async function ok() {
|
||||||
|
if (props.announcement.needConfirmationToRead) {
|
||||||
|
const confirm = await os.confirm({
|
||||||
|
type: 'question',
|
||||||
|
title: i18n.ts._announcement.readConfirmTitle,
|
||||||
|
text: i18n.t('_announcement.readConfirmText', { title: props.announcement.title }),
|
||||||
|
});
|
||||||
|
if (confirm.canceled) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.value.close();
|
||||||
|
os.api('i/read-announcement', { announcementId: props.announcement.id });
|
||||||
|
updateAccount({
|
||||||
|
unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== props.announcement.id),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function onBgClick() {
|
||||||
|
rootEl.value.animate([{
|
||||||
|
offset: 0,
|
||||||
|
transform: 'scale(1)',
|
||||||
|
}, {
|
||||||
|
offset: 0.5,
|
||||||
|
transform: 'scale(1.1)',
|
||||||
|
}, {
|
||||||
|
offset: 1,
|
||||||
|
transform: 'scale(1)',
|
||||||
|
}], {
|
||||||
|
duration: 100,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" module>
|
||||||
|
.root {
|
||||||
|
margin: auto;
|
||||||
|
position: relative;
|
||||||
|
padding: 32px;
|
||||||
|
min-width: 320px;
|
||||||
|
max-width: 480px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: var(--panel);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
font-size: 120%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
margin-right: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
</style>
|
@ -172,7 +172,6 @@ import { showMovedDialog } from '@/scripts/show-moved-dialog';
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
note: misskey.entities.Note;
|
note: misskey.entities.Note;
|
||||||
pinned?: boolean;
|
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const inChannel = inject('inChannel', null);
|
const inChannel = inject('inChannel', null);
|
||||||
|
@ -37,7 +37,6 @@ import { userPage } from '@/filters/user';
|
|||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
note: misskey.entities.Note;
|
note: misskey.entities.Note;
|
||||||
pinned?: boolean;
|
|
||||||
}>();
|
}>();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@ import { $i } from '@/account';
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
note: misskey.entities.Note;
|
note: misskey.entities.Note;
|
||||||
pinned?: boolean;
|
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const showContent = $ref(false);
|
const showContent = $ref(false);
|
||||||
|
@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="[$style.root, { [$style.children]: depth > 1 }]">
|
<div v-if="!muted" :class="[$style.root, { [$style.children]: depth > 1 }]">
|
||||||
<div :class="$style.main">
|
<div :class="$style.main">
|
||||||
<div v-if="note.channel" :class="$style.colorBar" :style="{ background: note.channel.color }"></div>
|
<div v-if="note.channel" :class="$style.colorBar" :style="{ background: note.channel.color }"></div>
|
||||||
<MkAvatar :class="$style.avatar" :user="note.user" link preview/>
|
<MkAvatar :class="$style.avatar" :user="note.user" link preview/>
|
||||||
@ -28,10 +28,19 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<MkA class="_link" :to="notePage(note)">{{ i18n.ts.continueThread }} <i class="ti ti-chevron-double-right"></i></MkA>
|
<MkA class="_link" :to="notePage(note)">{{ i18n.ts.continueThread }} <i class="ti ti-chevron-double-right"></i></MkA>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else :class="$style.muted" @click="muted = false">
|
||||||
|
<I18n :src="i18n.ts.userSaysSomething" tag="small">
|
||||||
|
<template #name>
|
||||||
|
<MkA v-user-preview="note.userId" :to="userPage(note.user)">
|
||||||
|
<MkUserName :user="note.user"/>
|
||||||
|
</MkA>
|
||||||
|
</template>
|
||||||
|
</I18n>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { } from 'vue';
|
import { ref } from 'vue';
|
||||||
import * as misskey from 'misskey-js';
|
import * as misskey from 'misskey-js';
|
||||||
import MkNoteHeader from '@/components/MkNoteHeader.vue';
|
import MkNoteHeader from '@/components/MkNoteHeader.vue';
|
||||||
import MkSubNoteContent from '@/components/MkSubNoteContent.vue';
|
import MkSubNoteContent from '@/components/MkSubNoteContent.vue';
|
||||||
@ -40,6 +49,9 @@ import { notePage } from '@/filters/note';
|
|||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { $i } from '@/account';
|
import { $i } from '@/account';
|
||||||
|
import { userPage } from "@/filters/user";
|
||||||
|
import { checkWordMute } from "@/scripts/check-word-mute";
|
||||||
|
import { defaultStore } from "@/store";
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
note: misskey.entities.Note;
|
note: misskey.entities.Note;
|
||||||
@ -51,6 +63,8 @@ const props = withDefaults(defineProps<{
|
|||||||
depth: 1,
|
depth: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const muted = ref(checkWordMute(props.note, $i, defaultStore.state.mutedWords));
|
||||||
|
|
||||||
let showContent = $ref(false);
|
let showContent = $ref(false);
|
||||||
let replies: misskey.entities.Note[] = $ref([]);
|
let replies: misskey.entities.Note[] = $ref([]);
|
||||||
|
|
||||||
@ -139,4 +153,12 @@ if (props.detail) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.muted {
|
||||||
|
text-align: center;
|
||||||
|
padding: 8px !important;
|
||||||
|
border: 1px solid var(--divider);
|
||||||
|
margin: 8px 8px 0 8px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -12,10 +12,15 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
:class="$style.input"
|
:class="$style.input"
|
||||||
@keydown.enter="toggle"
|
@keydown.enter="toggle"
|
||||||
>
|
>
|
||||||
<XButton :checked="checked" :disabled="disabled" @toggle="toggle" />
|
<XButton :checked="checked" :disabled="disabled" @toggle="toggle"/>
|
||||||
<span :class="$style.body">
|
<span :class="$style.body">
|
||||||
<!-- TODO: 無名slotの方は廃止 -->
|
<!-- TODO: 無名slotの方は廃止 -->
|
||||||
<span :class="$style.label" @click="toggle"><slot name="label"></slot><slot></slot></span>
|
<span :class="$style.label">
|
||||||
|
<span @click="toggle">
|
||||||
|
<slot name="label"></slot><slot></slot>
|
||||||
|
</span>
|
||||||
|
<span v-if="helpText" v-tooltip:dialog="helpText" class="_button _help" :class="$style.help"><i class="ti ti-help-circle"></i></span>
|
||||||
|
</span>
|
||||||
<p :class="$style.caption"><slot name="caption"></slot></p>
|
<p :class="$style.caption"><slot name="caption"></slot></p>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -28,6 +33,7 @@ import XButton from '@/components/MkSwitch.button.vue';
|
|||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
modelValue: boolean | Ref<boolean>;
|
modelValue: boolean | Ref<boolean>;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
helpText?: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@ -38,10 +44,6 @@ const checked = toRefs(props).modelValue;
|
|||||||
const toggle = () => {
|
const toggle = () => {
|
||||||
if (props.disabled) return;
|
if (props.disabled) return;
|
||||||
emit('update:modelValue', !checked.value);
|
emit('update:modelValue', !checked.value);
|
||||||
|
|
||||||
if (!checked.value) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -98,4 +100,10 @@ const toggle = () => {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.help {
|
||||||
|
margin-left: 0.5em;
|
||||||
|
font-size: 85%;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -28,7 +28,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</template>
|
</template>
|
||||||
<template v-else-if="tweetId && tweetExpanded">
|
<template v-else-if="tweetId && tweetExpanded">
|
||||||
<div ref="twitter">
|
<div ref="twitter">
|
||||||
<iframe ref="tweet" scrolling="no" frameborder="no" :style="{ position: 'relative', width: '100%', height: `${tweetHeight}px` }" :src="`https://platform.twitter.com/embed/index.html?embedId=${embedId}&hideCard=false&hideThread=false&lang=en&theme=${defaultStore.state.darkMode ? 'dark' : 'light'}&id=${tweetId}`"></iframe>
|
<iframe
|
||||||
|
ref="tweet"
|
||||||
|
allow="fullscreen;web-share"
|
||||||
|
sandbox="allow-popups allow-scripts allow-same-origin"
|
||||||
|
scrolling="no"
|
||||||
|
:style="{ position: 'relative', width: '100%', height: `${tweetHeight}px`, border: 0 }"
|
||||||
|
:src="`https://platform.twitter.com/embed/index.html?embedId=${embedId}&hideCard=false&hideThread=false&lang=en&theme=${defaultStore.state.darkMode ? 'dark' : 'light'}&id=${tweetId}`"
|
||||||
|
></iframe>
|
||||||
</div>
|
</div>
|
||||||
<div :class="$style.action">
|
<div :class="$style.action">
|
||||||
<MkButton :small="true" inline @click="tweetExpanded = false">
|
<MkButton :small="true" inline @click="tweetExpanded = false">
|
||||||
|
@ -0,0 +1,145 @@
|
|||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<MkModalWindow
|
||||||
|
ref="dialog"
|
||||||
|
:width="400"
|
||||||
|
@close="dialog.close()"
|
||||||
|
@closed="$emit('closed')"
|
||||||
|
>
|
||||||
|
<template v-if="announcement" #header>:{{ announcement.title }}:</template>
|
||||||
|
<template v-else #header>New announcement</template>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<MkSpacer :marginMin="20" :marginMax="28">
|
||||||
|
<div class="_gaps_m">
|
||||||
|
<MkInput v-model="title">
|
||||||
|
<template #label>{{ i18n.ts.title }}</template>
|
||||||
|
</MkInput>
|
||||||
|
<MkTextarea v-model="text">
|
||||||
|
<template #label>{{ i18n.ts.text }}</template>
|
||||||
|
</MkTextarea>
|
||||||
|
<MkRadios v-model="icon">
|
||||||
|
<template #label>{{ i18n.ts.icon }}</template>
|
||||||
|
<option value="info"><i class="ti ti-info-circle"></i></option>
|
||||||
|
<option value="warning"><i class="ti ti-alert-triangle" style="color: var(--warn);"></i></option>
|
||||||
|
<option value="error"><i class="ti ti-circle-x" style="color: var(--error);"></i></option>
|
||||||
|
<option value="success"><i class="ti ti-check" style="color: var(--success);"></i></option>
|
||||||
|
</MkRadios>
|
||||||
|
<MkRadios v-model="display">
|
||||||
|
<template #label>{{ i18n.ts.display }}</template>
|
||||||
|
<option value="normal">{{ i18n.ts.normal }}</option>
|
||||||
|
<option value="banner">{{ i18n.ts.banner }}</option>
|
||||||
|
<option value="dialog">{{ i18n.ts.dialog }}</option>
|
||||||
|
</MkRadios>
|
||||||
|
<MkSwitch v-model="needConfirmationToRead">
|
||||||
|
{{ i18n.ts._announcement.needConfirmationToRead }}
|
||||||
|
<template #caption>{{ i18n.ts._announcement.needConfirmationToReadDescription }}</template>
|
||||||
|
</MkSwitch>
|
||||||
|
<MkButton v-if="announcement" danger @click="del()"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
|
||||||
|
</div>
|
||||||
|
</MkSpacer>
|
||||||
|
<div :class="$style.footer">
|
||||||
|
<MkButton primary rounded style="margin: 0 auto;" @click="done"><i class="ti ti-check"></i> {{ props.announcement ? i18n.ts.update : i18n.ts.create }}</MkButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</MkModalWindow>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { } from 'vue';
|
||||||
|
import * as misskey from 'misskey-js';
|
||||||
|
import MkModalWindow from '@/components/MkModalWindow.vue';
|
||||||
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
import MkInput from '@/components/MkInput.vue';
|
||||||
|
import * as os from '@/os';
|
||||||
|
import { i18n } from '@/i18n';
|
||||||
|
import MkTextarea from '@/components/MkTextarea.vue';
|
||||||
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
|
import MkRadios from '@/components/MkRadios.vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
user: misskey.entities.User,
|
||||||
|
announcement?: any,
|
||||||
|
}>();
|
||||||
|
|
||||||
|
let dialog = $ref(null);
|
||||||
|
let title: string = $ref(props.announcement ? props.announcement.title : '');
|
||||||
|
let text: string = $ref(props.announcement ? props.announcement.text : '');
|
||||||
|
let icon: string = $ref(props.announcement ? props.announcement.icon : 'info');
|
||||||
|
let display: string = $ref(props.announcement ? props.announcement.display : 'dialog');
|
||||||
|
let needConfirmationToRead = $ref(props.announcement ? props.announcement.needConfirmationToRead : false);
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(ev: 'done', v: { deleted?: boolean; updated?: any; created?: any }): void,
|
||||||
|
(ev: 'closed'): void
|
||||||
|
}>();
|
||||||
|
|
||||||
|
async function done() {
|
||||||
|
const params = {
|
||||||
|
title: title,
|
||||||
|
text: text,
|
||||||
|
icon: icon,
|
||||||
|
imageUrl: null,
|
||||||
|
display: display,
|
||||||
|
needConfirmationToRead: needConfirmationToRead,
|
||||||
|
userId: props.user.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (props.announcement) {
|
||||||
|
await os.apiWithDialog('admin/announcements/update', {
|
||||||
|
id: props.announcement.id,
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
|
||||||
|
emit('done', {
|
||||||
|
updated: {
|
||||||
|
id: props.announcement.id,
|
||||||
|
...params,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.close();
|
||||||
|
} else {
|
||||||
|
const created = await os.apiWithDialog('admin/announcements/create', params);
|
||||||
|
|
||||||
|
emit('done', {
|
||||||
|
created: created,
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function del() {
|
||||||
|
const { canceled } = await os.confirm({
|
||||||
|
type: 'warning',
|
||||||
|
text: i18n.t('removeAreYouSure', { x: title }),
|
||||||
|
});
|
||||||
|
if (canceled) return;
|
||||||
|
|
||||||
|
os.api('admin/announcements/delete', {
|
||||||
|
id: props.announcement.id,
|
||||||
|
}).then(() => {
|
||||||
|
emit('done', {
|
||||||
|
deleted: true,
|
||||||
|
});
|
||||||
|
dialog.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" module>
|
||||||
|
.footer {
|
||||||
|
position: sticky;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
padding: 12px;
|
||||||
|
border-top: solid 0.5px var(--divider);
|
||||||
|
-webkit-backdrop-filter: var(--blur, blur(15px));
|
||||||
|
backdrop-filter: var(--blur, blur(15px));
|
||||||
|
}
|
||||||
|
</style>
|
@ -9,16 +9,16 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<div v-show="loaded" :class="$style.root">
|
<div v-show="loaded" :class="$style.root">
|
||||||
<img :src="serverErrorImageUrl" class="_ghost" :class="$style.img"/>
|
<img :src="serverErrorImageUrl" class="_ghost" :class="$style.img"/>
|
||||||
<div class="_gaps">
|
<div class="_gaps">
|
||||||
<p><b><i class="ti ti-alert-triangle"></i> {{ i18n.ts.pageLoadError }}</b></p>
|
<div><b><i class="ti ti-alert-triangle"></i> {{ i18n.ts.pageLoadError }}</b></div>
|
||||||
<p v-if="meta && (version === meta.version)">{{ i18n.ts.pageLoadErrorDescription }}</p>
|
<div v-if="meta && (version === meta.version)">{{ i18n.ts.pageLoadErrorDescription }}</div>
|
||||||
<p v-else-if="serverIsDead">{{ i18n.ts.serverIsDead }}</p>
|
<div v-else-if="serverIsDead">{{ i18n.ts.serverIsDead }}</div>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<p>{{ i18n.ts.newVersionOfClientAvailable }}</p>
|
<div>{{ i18n.ts.newVersionOfClientAvailable }}</div>
|
||||||
<p>{{ i18n.ts.youShouldUpgradeClient }}</p>
|
<div>{{ i18n.ts.youShouldUpgradeClient }}</div>
|
||||||
<MkButton style="margin: 8px auto;" @click="reload">{{ i18n.ts.reload }}</MkButton>
|
<MkButton style="margin: 8px auto;" @click="reload">{{ i18n.ts.reload }}</MkButton>
|
||||||
</template>
|
</template>
|
||||||
<p><MkA to="/docs/general/troubleshooting" class="_link">{{ i18n.ts.troubleshooting }}</MkA></p>
|
<div><MkA to="/docs/general/troubleshooting" class="_link">{{ i18n.ts.troubleshooting }}</MkA></div>
|
||||||
<p v-if="error" style="opacity: 0.7;">ERROR: {{ error }}</p>
|
<div v-if="error" style="opacity: 0.7;">ERROR: {{ error }}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Transition>
|
</Transition>
|
||||||
|
@ -33,7 +33,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<template #value><span class="_monospace"><MkTime :time="file.createdAt" mode="detail" style="display: block;"/></span></template>
|
<template #value><span class="_monospace"><MkTime :time="file.createdAt" mode="detail" style="display: block;"/></span></template>
|
||||||
</MkKeyValue>
|
</MkKeyValue>
|
||||||
</div>
|
</div>
|
||||||
<MkA v-if="file.user" class="user" :to="`/user-info/${file.user.id}`">
|
<MkA v-if="file.user" class="user" :to="`/admin/user/${file.user.id}`">
|
||||||
<MkUserCardMini :user="file.user"/>
|
<MkUserCardMini :user="file.user"/>
|
||||||
</MkA>
|
</MkA>
|
||||||
<div>
|
<div>
|
||||||
|
@ -24,12 +24,6 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
|
|
||||||
<MkInfo v-if="user.username.includes('.')">{{ i18n.ts.isSystemAccount }}</MkInfo>
|
<MkInfo v-if="user.username.includes('.')">{{ i18n.ts.isSystemAccount }}</MkInfo>
|
||||||
|
|
||||||
<div v-if="user.url" class="_formLinksGrid">
|
|
||||||
<FormLink :to="userPage(user)">Profile</FormLink>
|
|
||||||
<FormLink :to="user.url" :external="true">Profile (remote)</FormLink>
|
|
||||||
</div>
|
|
||||||
<FormLink v-else :to="userPage(user)">Profile</FormLink>
|
|
||||||
|
|
||||||
<FormLink v-if="user.host" :to="`/instance-info/${user.host}`">{{ i18n.ts.instanceInfo }}</FormLink>
|
<FormLink v-if="user.host" :to="`/instance-info/${user.host}`">{{ i18n.ts.instanceInfo }}</FormLink>
|
||||||
|
|
||||||
<div style="display: flex; flex-direction: column; gap: 1em;">
|
<div style="display: flex; flex-direction: column; gap: 1em;">
|
||||||
@ -57,6 +51,11 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</MkKeyValue>
|
</MkKeyValue>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<MkTextarea v-model="moderationNote" manualSave>
|
||||||
|
<template #label>Moderation note</template>
|
||||||
|
</MkTextarea>
|
||||||
|
|
||||||
|
<!--
|
||||||
<FormSection>
|
<FormSection>
|
||||||
<template #label>ActivityPub</template>
|
<template #label>ActivityPub</template>
|
||||||
|
|
||||||
@ -90,70 +89,85 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</MkFolder>
|
</MkFolder>
|
||||||
</div>
|
</div>
|
||||||
</FormSection>
|
</FormSection>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<FormSection>
|
||||||
|
<div class="_gaps">
|
||||||
|
<MkSwitch v-model="suspended" @update:modelValue="toggleSuspend">{{ i18n.ts.suspend }}</MkSwitch>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<MkButton v-if="user.host == null" inline style="margin-right: 8px;" @click="resetPassword"><i class="ti ti-key"></i> {{ i18n.ts.resetPassword }}</MkButton>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<MkFolder>
|
||||||
|
<template #icon><i class="ti ti-license"></i></template>
|
||||||
|
<template #label>{{ i18n.ts._role.policies }}</template>
|
||||||
|
<div class="_gaps">
|
||||||
|
<div v-for="policy in Object.keys(info.policies)" :key="policy">
|
||||||
|
{{ policy }} ... {{ info.policies[policy] }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</MkFolder>
|
||||||
|
|
||||||
|
<MkFolder>
|
||||||
|
<template #icon><i class="ti ti-password"></i></template>
|
||||||
|
<template #label>IP</template>
|
||||||
|
<MkInfo v-if="!iAmAdmin" warn>{{ i18n.ts.requireAdminForView }}</MkInfo>
|
||||||
|
<MkInfo v-else>The date is the IP address was first acknowledged.</MkInfo>
|
||||||
|
<template v-if="iAmAdmin && ips">
|
||||||
|
<div v-for="record in ips" :key="record.ip" class="_monospace" :class="$style.ip" style="margin: 1em 0;">
|
||||||
|
<span class="date">{{ record.createdAt }}</span>
|
||||||
|
<span class="ip">{{ record.ip }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</MkFolder>
|
||||||
|
|
||||||
|
<MkButton v-if="$i.isAdmin" inline danger @click="deleteAccount">{{ i18n.ts.deleteAccount }}</MkButton>
|
||||||
|
</div>
|
||||||
|
</FormSection>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="tab === 'moderation'" class="_gaps_m">
|
<div v-else-if="tab === 'roles'" class="_gaps">
|
||||||
<MkSwitch v-model="suspended" @update:modelValue="toggleSuspend">{{ i18n.ts.suspend }}</MkSwitch>
|
<MkButton v-if="user.host == null" primary rounded @click="assignRole"><i class="ti ti-plus"></i> {{ i18n.ts.assign }}</MkButton>
|
||||||
|
|
||||||
<div>
|
<div v-for="role in info.roles" :key="role.id" :class="$style.roleItem">
|
||||||
<MkButton v-if="user.host == null && iAmModerator" inline style="margin-right: 8px;" @click="resetPassword"><i class="ti ti-key"></i> {{ i18n.ts.resetPassword }}</MkButton>
|
<div :class="$style.roleItemMain">
|
||||||
<MkButton v-if="$i.isAdmin" inline danger @click="deleteAccount">{{ i18n.ts.deleteAccount }}</MkButton>
|
<MkRolePreview :class="$style.role" :role="role" :forModeration="true"/>
|
||||||
|
<button class="_button" :class="$style.roleToggle" @click="toggleRoleItem(role)"><i class="ti ti-chevron-down"></i></button>
|
||||||
|
<button v-if="role.target === 'manual'" class="_button" :class="$style.roleUnassign" @click="unassignRole(role, $event)"><i class="ti ti-x"></i></button>
|
||||||
|
<button v-else class="_button" :class="$style.roleUnassign" disabled><i class="ti ti-ban"></i></button>
|
||||||
|
</div>
|
||||||
|
<div v-if="expandedRoles.includes(role.id)" :class="$style.roleItemSub">
|
||||||
|
<div>Assigned: <MkTime :time="info.roleAssigns.find(a => a.roleId === role.id).createdAt" mode="detail"/></div>
|
||||||
|
<div v-if="info.roleAssigns.find(a => a.roleId === role.id).expiresAt">Period: {{ new Date(info.roleAssigns.find(a => a.roleId === role.id).expiresAt).toLocaleString() }}</div>
|
||||||
|
<div v-else>Period: {{ i18n.ts.indefinitely }}</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<MkFolder>
|
<div v-else-if="tab === 'announcements'" class="_gaps">
|
||||||
<template #icon><i class="ti ti-license"></i></template>
|
<MkButton primary rounded @click="createAnnouncement"><i class="ti ti-plus"></i> {{ i18n.ts.new }}</MkButton>
|
||||||
<template #label>{{ i18n.ts._role.policies }}</template>
|
|
||||||
<div class="_gaps">
|
|
||||||
<div v-for="policy in Object.keys(info.policies)" :key="policy">
|
|
||||||
{{ policy }} ... {{ info.policies[policy] }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</MkFolder>
|
|
||||||
|
|
||||||
<MkFolder>
|
<MkPagination :pagination="announcementsPagination">
|
||||||
<template #icon><i class="ti ti-badges"></i></template>
|
<template #default="{ items }">
|
||||||
<template #label>{{ i18n.ts.roles }}</template>
|
<div class="_gaps_s">
|
||||||
<div class="_gaps">
|
<div v-for="announcement in items" :key="announcement.id" v-panel :class="$style.announcementItem" @click="editAnnouncement(announcement)">
|
||||||
<MkButton v-if="user.host == null && iAmModerator" primary rounded @click="assignRole"><i class="ti ti-plus"></i> {{ i18n.ts.assign }}</MkButton>
|
<span style="margin-right: 0.5em;">
|
||||||
|
<i v-if="announcement.icon === 'info'" class="ti ti-info-circle"></i>
|
||||||
<div v-for="role in info.roles" :key="role.id" :class="$style.roleItem">
|
<i v-else-if="announcement.icon === 'warning'" class="ti ti-alert-triangle" style="color: var(--warn);"></i>
|
||||||
<div :class="$style.roleItemMain">
|
<i v-else-if="announcement.icon === 'error'" class="ti ti-circle-x" style="color: var(--error);"></i>
|
||||||
<MkRolePreview :class="$style.role" :role="role" :forModeration="true"/>
|
<i v-else-if="announcement.icon === 'success'" class="ti ti-check" style="color: var(--success);"></i>
|
||||||
<button class="_button" :class="$style.roleToggle" @click="toggleRoleItem(role)"><i class="ti ti-chevron-down"></i></button>
|
</span>
|
||||||
<button v-if="role.target === 'manual'" class="_button" :class="$style.roleUnassign" @click="unassignRole(role, $event)"><i class="ti ti-x"></i></button>
|
<span>{{ announcement.title }}</span>
|
||||||
<button v-else class="_button" :class="$style.roleUnassign" disabled><i class="ti ti-ban"></i></button>
|
<span v-if="announcement.reads > 0" style="margin-left: auto; opacity: 0.7;">{{ i18n.ts.messageRead }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="expandedRoles.includes(role.id)" :class="$style.roleItemSub">
|
|
||||||
<div>Assigned: <MkTime :time="info.roleAssigns.find(a => a.roleId === role.id).createdAt" mode="detail"/></div>
|
|
||||||
<div v-if="info.roleAssigns.find(a => a.roleId === role.id).expiresAt">Period: {{ new Date(info.roleAssigns.find(a => a.roleId === role.id).expiresAt).toLocaleString() }}</div>
|
|
||||||
<div v-else>Period: {{ i18n.ts.indefinitely }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</MkFolder>
|
|
||||||
|
|
||||||
<MkFolder>
|
|
||||||
<template #icon><i class="ti ti-password"></i></template>
|
|
||||||
<template #label>IP</template>
|
|
||||||
<MkInfo v-if="!iAmAdmin" warn>{{ i18n.ts.requireAdminForView }}</MkInfo>
|
|
||||||
<MkInfo v-else>The date is the IP address was first acknowledged.</MkInfo>
|
|
||||||
<template v-if="iAmAdmin && ips">
|
|
||||||
<div v-for="record in ips" :key="record.ip" class="_monospace" :class="$style.ip" style="margin: 1em 0;">
|
|
||||||
<span class="date">{{ record.createdAt }}</span>
|
|
||||||
<span class="ip">{{ record.ip }}</span>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</MkFolder>
|
</MkPagination>
|
||||||
|
</div>
|
||||||
|
|
||||||
<MkFolder>
|
<div v-else-if="tab === 'drive'" class="_gaps">
|
||||||
<template #icon><i class="ti ti-cloud"></i></template>
|
<MkFileListForAdmin :pagination="filesPagination" viewMode="grid"/>
|
||||||
<template #label>{{ i18n.ts.files }}</template>
|
|
||||||
<MkFileListForAdmin :pagination="filesPagination" viewMode="grid"/>
|
|
||||||
</MkFolder>
|
|
||||||
|
|
||||||
<MkTextarea v-model="moderationNote" manualSave>
|
|
||||||
<template #label>Moderation note</template>
|
|
||||||
</MkTextarea>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="tab === 'chart'" class="_gaps_m">
|
<div v-else-if="tab === 'chart'" class="_gaps_m">
|
||||||
@ -185,7 +199,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, watch } from 'vue';
|
import { computed, defineAsyncComponent, watch } from 'vue';
|
||||||
import * as misskey from 'misskey-js';
|
import * as misskey from 'misskey-js';
|
||||||
import MkChart from '@/components/MkChart.vue';
|
import MkChart from '@/components/MkChart.vue';
|
||||||
import MkObjectView from '@/components/MkObjectView.vue';
|
import MkObjectView from '@/components/MkObjectView.vue';
|
||||||
@ -205,8 +219,9 @@ import { url } from '@/config';
|
|||||||
import { userPage, acct } from '@/filters/user';
|
import { userPage, acct } from '@/filters/user';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { iAmAdmin, iAmModerator, $i } from '@/account';
|
import { iAmAdmin, $i } from '@/account';
|
||||||
import MkRolePreview from '@/components/MkRolePreview.vue';
|
import MkRolePreview from '@/components/MkRolePreview.vue';
|
||||||
|
import MkPagination, { Paging } from '@/components/MkPagination.vue';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
userId: string;
|
userId: string;
|
||||||
@ -233,37 +248,36 @@ const filesPagination = {
|
|||||||
userId: props.userId,
|
userId: props.userId,
|
||||||
})),
|
})),
|
||||||
};
|
};
|
||||||
|
const announcementsPagination = {
|
||||||
|
endpoint: 'admin/announcements/list' as const,
|
||||||
|
limit: 10,
|
||||||
|
params: computed(() => ({
|
||||||
|
userId: props.userId,
|
||||||
|
})),
|
||||||
|
};
|
||||||
let expandedRoles = $ref([]);
|
let expandedRoles = $ref([]);
|
||||||
|
|
||||||
function createFetcher() {
|
function createFetcher() {
|
||||||
if (iAmModerator) {
|
return () => Promise.all([os.api('users/show', {
|
||||||
return () => Promise.all([os.api('users/show', {
|
userId: props.userId,
|
||||||
userId: props.userId,
|
}), os.api('admin/show-user', {
|
||||||
}), os.api('admin/show-user', {
|
userId: props.userId,
|
||||||
userId: props.userId,
|
}), iAmAdmin ? os.api('admin/get-user-ips', {
|
||||||
}), iAmAdmin ? os.api('admin/get-user-ips', {
|
userId: props.userId,
|
||||||
userId: props.userId,
|
}) : Promise.resolve(null)]).then(([_user, _info, _ips]) => {
|
||||||
}) : Promise.resolve(null)]).then(([_user, _info, _ips]) => {
|
user = _user;
|
||||||
user = _user;
|
info = _info;
|
||||||
info = _info;
|
ips = _ips;
|
||||||
ips = _ips;
|
moderator = info.isModerator;
|
||||||
moderator = info.isModerator;
|
silenced = info.isSilenced;
|
||||||
silenced = info.isSilenced;
|
suspended = info.isSuspended;
|
||||||
suspended = info.isSuspended;
|
moderationNote = info.moderationNote;
|
||||||
moderationNote = info.moderationNote;
|
|
||||||
|
|
||||||
watch($$(moderationNote), async () => {
|
watch($$(moderationNote), async () => {
|
||||||
await os.api('admin/update-user-note', { userId: user.id, text: moderationNote });
|
await os.api('admin/update-user-note', { userId: user.id, text: moderationNote });
|
||||||
await refreshUser();
|
await refreshUser();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
});
|
||||||
return () => os.api('users/show', {
|
|
||||||
userId: props.userId,
|
|
||||||
}).then((res) => {
|
|
||||||
user = res;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshUser() {
|
function refreshUser() {
|
||||||
@ -406,6 +420,19 @@ function toggleRoleItem(role) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createAnnouncement() {
|
||||||
|
os.popup(defineAsyncComponent(() => import('@/components/MkUserAnnouncementEditDialog.vue')), {
|
||||||
|
user,
|
||||||
|
}, {}, 'closed');
|
||||||
|
}
|
||||||
|
|
||||||
|
function editAnnouncement(announcement) {
|
||||||
|
os.popup(defineAsyncComponent(() => import('@/components/MkUserAnnouncementEditDialog.vue')), {
|
||||||
|
user,
|
||||||
|
announcement,
|
||||||
|
}, {}, 'closed');
|
||||||
|
}
|
||||||
|
|
||||||
watch(() => props.userId, () => {
|
watch(() => props.userId, () => {
|
||||||
init = createFetcher();
|
init = createFetcher();
|
||||||
}, {
|
}, {
|
||||||
@ -426,11 +453,19 @@ const headerTabs = $computed(() => [{
|
|||||||
key: 'overview',
|
key: 'overview',
|
||||||
title: i18n.ts.overview,
|
title: i18n.ts.overview,
|
||||||
icon: 'ti ti-info-circle',
|
icon: 'ti ti-info-circle',
|
||||||
}, iAmModerator ? {
|
}, {
|
||||||
key: 'moderation',
|
key: 'roles',
|
||||||
title: i18n.ts.moderation,
|
title: i18n.ts.roles,
|
||||||
icon: 'ti ti-user-exclamation',
|
icon: 'ti ti-badges',
|
||||||
} : null, {
|
}, {
|
||||||
|
key: 'announcements',
|
||||||
|
title: i18n.ts.announcements,
|
||||||
|
icon: 'ti ti-speakerphone',
|
||||||
|
}, {
|
||||||
|
key: 'drive',
|
||||||
|
title: i18n.ts.drive,
|
||||||
|
icon: 'ti ti-cloud',
|
||||||
|
}, {
|
||||||
key: 'chart',
|
key: 'chart',
|
||||||
title: i18n.ts.charts,
|
title: i18n.ts.charts,
|
||||||
icon: 'ti ti-chart-line',
|
icon: 'ti ti-chart-line',
|
||||||
@ -438,11 +473,11 @@ const headerTabs = $computed(() => [{
|
|||||||
key: 'raw',
|
key: 'raw',
|
||||||
title: 'Raw',
|
title: 'Raw',
|
||||||
icon: 'ti ti-code',
|
icon: 'ti ti-code',
|
||||||
}].filter(x => x != null));
|
}]);
|
||||||
|
|
||||||
definePageMetadata(computed(() => ({
|
definePageMetadata(computed(() => ({
|
||||||
title: user ? acct(user) : i18n.ts.userInfo,
|
title: user ? acct(user) : i18n.ts.userInfo,
|
||||||
icon: 'ti ti-info-circle',
|
icon: 'ti ti-user-exclamation',
|
||||||
})));
|
})));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -569,4 +604,11 @@ definePageMetadata(computed(() => ({
|
|||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
align-self: center;
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.announcementItem {
|
||||||
|
display: flex;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -7,9 +7,20 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<MkStickyContainer>
|
<MkStickyContainer>
|
||||||
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
||||||
<MkSpacer :contentMax="900">
|
<MkSpacer :contentMax="900">
|
||||||
<div class="_gaps_m">
|
<div class="_gaps">
|
||||||
<section v-for="announcement in announcements" class="">
|
<MkInfo v-if="announcements.length > 5" warn>{{ i18n.ts._announcement.tooManyActiveAnnouncementDescription }}</MkInfo>
|
||||||
<div class="_panel _gaps_m" style="padding: 24px;">
|
|
||||||
|
<MkFolder v-for="announcement in announcements" :key="announcement.id ?? announcement._id" :defaultOpen="announcement.id == null">
|
||||||
|
<template #label>{{ announcement.title }}</template>
|
||||||
|
<template #icon>
|
||||||
|
<i v-if="announcement.icon === 'info'" class="ti ti-info-circle"></i>
|
||||||
|
<i v-else-if="announcement.icon === 'warning'" class="ti ti-alert-triangle" style="color: var(--warn);"></i>
|
||||||
|
<i v-else-if="announcement.icon === 'error'" class="ti ti-circle-x" style="color: var(--error);"></i>
|
||||||
|
<i v-else-if="announcement.icon === 'success'" class="ti ti-check" style="color: var(--success);"></i>
|
||||||
|
</template>
|
||||||
|
<template #caption>{{ announcement.text }}</template>
|
||||||
|
|
||||||
|
<div class="_gaps_m">
|
||||||
<MkInput v-model="announcement.title">
|
<MkInput v-model="announcement.title">
|
||||||
<template #label>{{ i18n.ts.title }}</template>
|
<template #label>{{ i18n.ts.title }}</template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
@ -19,13 +30,33 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<MkInput v-model="announcement.imageUrl">
|
<MkInput v-model="announcement.imageUrl">
|
||||||
<template #label>{{ i18n.ts.imageUrl }}</template>
|
<template #label>{{ i18n.ts.imageUrl }}</template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
|
<MkRadios v-model="announcement.icon">
|
||||||
|
<template #label>{{ i18n.ts.icon }}</template>
|
||||||
|
<option value="info"><i class="ti ti-info-circle"></i></option>
|
||||||
|
<option value="warning"><i class="ti ti-alert-triangle" style="color: var(--warn);"></i></option>
|
||||||
|
<option value="error"><i class="ti ti-circle-x" style="color: var(--error);"></i></option>
|
||||||
|
<option value="success"><i class="ti ti-check" style="color: var(--success);"></i></option>
|
||||||
|
</MkRadios>
|
||||||
|
<MkRadios v-model="announcement.display">
|
||||||
|
<template #label>{{ i18n.ts.display }}</template>
|
||||||
|
<option value="normal">{{ i18n.ts.normal }}</option>
|
||||||
|
<option value="banner">{{ i18n.ts.banner }}</option>
|
||||||
|
<option value="dialog">{{ i18n.ts.dialog }}</option>
|
||||||
|
</MkRadios>
|
||||||
|
<MkSwitch v-model="announcement.forExistingUsers" :helpText="i18n.ts._announcement.forExistingUsersDescription">
|
||||||
|
{{ i18n.ts._announcement.forExistingUsers }}
|
||||||
|
</MkSwitch>
|
||||||
|
<MkSwitch v-model="announcement.needConfirmationToRead" :helpText="i18n.ts._announcement.needConfirmationToReadDescription">
|
||||||
|
{{ i18n.ts._announcement.needConfirmationToRead }}
|
||||||
|
</MkSwitch>
|
||||||
<p v-if="announcement.reads">{{ i18n.t('nUsersRead', { n: announcement.reads }) }}</p>
|
<p v-if="announcement.reads">{{ i18n.t('nUsersRead', { n: announcement.reads }) }}</p>
|
||||||
<div class="buttons _buttons">
|
<div class="buttons _buttons">
|
||||||
<MkButton class="button" inline primary @click="save(announcement)"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
<MkButton class="button" inline primary @click="save(announcement)"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
|
||||||
<MkButton class="button" inline danger @click="remove(announcement)"><i class="ti ti-trash"></i> {{ i18n.ts.remove }}</MkButton>
|
<MkButton v-if="announcement.id != null" class="button" inline @click="archive(announcement)"><i class="ti ti-check"></i> {{ i18n.ts._announcement.end }} ({{ i18n.ts.archive }})</MkButton>
|
||||||
|
<MkButton v-if="announcement.id != null" class="button" inline danger @click="del(announcement)"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</MkFolder>
|
||||||
</div>
|
</div>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
</MkStickyContainer>
|
</MkStickyContainer>
|
||||||
@ -37,9 +68,13 @@ import XHeader from './_header_.vue';
|
|||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import MkInput from '@/components/MkInput.vue';
|
import MkInput from '@/components/MkInput.vue';
|
||||||
import MkTextarea from '@/components/MkTextarea.vue';
|
import MkTextarea from '@/components/MkTextarea.vue';
|
||||||
|
import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
|
import MkRadios from '@/components/MkRadios.vue';
|
||||||
|
import MkInfo from '@/components/MkInfo.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
|
import MkFolder from '@/components/MkFolder.vue';
|
||||||
|
|
||||||
let announcements: any[] = $ref([]);
|
let announcements: any[] = $ref([]);
|
||||||
|
|
||||||
@ -49,17 +84,22 @@ os.api('admin/announcements/list').then(announcementResponse => {
|
|||||||
|
|
||||||
function add() {
|
function add() {
|
||||||
announcements.unshift({
|
announcements.unshift({
|
||||||
|
_id: Math.random().toString(36),
|
||||||
id: null,
|
id: null,
|
||||||
title: '',
|
title: 'New announcement',
|
||||||
text: '',
|
text: '',
|
||||||
imageUrl: null,
|
imageUrl: null,
|
||||||
|
icon: 'info',
|
||||||
|
display: 'normal',
|
||||||
|
forExistingUsers: false,
|
||||||
|
needConfirmationToRead: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove(announcement) {
|
function del(announcement) {
|
||||||
os.confirm({
|
os.confirm({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
text: i18n.t('removeAreYouSure', { x: announcement.title }),
|
text: i18n.t('deleteAreYouSure', { x: announcement.title }),
|
||||||
}).then(({ canceled }) => {
|
}).then(({ canceled }) => {
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
announcements = announcements.filter(x => x !== announcement);
|
announcements = announcements.filter(x => x !== announcement);
|
||||||
@ -67,32 +107,20 @@ function remove(announcement) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(announcement) {
|
async function archive(announcement) {
|
||||||
|
await os.apiWithDialog('admin/announcements/update', {
|
||||||
|
...announcement,
|
||||||
|
isActive: false,
|
||||||
|
});
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function save(announcement) {
|
||||||
if (announcement.id == null) {
|
if (announcement.id == null) {
|
||||||
os.api('admin/announcements/create', announcement).then(() => {
|
await os.apiWithDialog('admin/announcements/create', announcement);
|
||||||
os.alert({
|
refresh();
|
||||||
type: 'success',
|
|
||||||
text: i18n.ts.saved,
|
|
||||||
});
|
|
||||||
refresh();
|
|
||||||
}).catch(err => {
|
|
||||||
os.alert({
|
|
||||||
type: 'error',
|
|
||||||
text: err,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
os.api('admin/announcements/update', announcement).then(() => {
|
os.apiWithDialog('admin/announcements/update', announcement);
|
||||||
os.alert({
|
|
||||||
type: 'success',
|
|
||||||
text: i18n.ts.saved,
|
|
||||||
});
|
|
||||||
}).catch(err => {
|
|
||||||
os.alert({
|
|
||||||
type: 'error',
|
|
||||||
text: err,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<Transition :name="defaultStore.state.animation ? '_transition_zoom' : ''" mode="out-in">
|
<Transition :name="defaultStore.state.animation ? '_transition_zoom' : ''" mode="out-in">
|
||||||
<MkLoading v-if="fetching"/>
|
<MkLoading v-if="fetching"/>
|
||||||
<div v-else :class="$style.root" class="_panel">
|
<div v-else :class="$style.root" class="_panel">
|
||||||
<MkA v-for="user in moderators" :key="user.id" class="user" :to="`/user-info/${user.id}`">
|
<MkA v-for="user in moderators" :key="user.id" class="user" :to="`/admin/user/${user.id}`">
|
||||||
<MkAvatar :user="user" class="avatar" indicator/>
|
<MkAvatar :user="user" class="avatar" indicator/>
|
||||||
</MkA>
|
</MkA>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<Transition :name="defaultStore.state.animation ? '_transition_zoom' : ''" mode="out-in">
|
<Transition :name="defaultStore.state.animation ? '_transition_zoom' : ''" mode="out-in">
|
||||||
<MkLoading v-if="fetching"/>
|
<MkLoading v-if="fetching"/>
|
||||||
<div v-else class="users">
|
<div v-else class="users">
|
||||||
<MkA v-for="(user, i) in newUsers" :key="user.id" :to="`/user-info/${user.id}`" class="user">
|
<MkA v-for="(user, i) in newUsers" :key="user.id" :to="`/admin/user/${user.id}`" class="user">
|
||||||
<MkUserCardMini :user="user"/>
|
<MkUserCardMini :user="user"/>
|
||||||
</MkA>
|
</MkA>
|
||||||
</div>
|
</div>
|
||||||
|
@ -37,7 +37,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<div class="_gaps_s">
|
<div class="_gaps_s">
|
||||||
<div v-for="item in items" :key="item.user.id" :class="[$style.userItem, { [$style.userItemOpend]: expandedItems.includes(item.id) }]">
|
<div v-for="item in items" :key="item.user.id" :class="[$style.userItem, { [$style.userItemOpend]: expandedItems.includes(item.id) }]">
|
||||||
<div :class="$style.userItemMain">
|
<div :class="$style.userItemMain">
|
||||||
<MkA :class="$style.userItemMainBody" :to="`/user-info/${item.user.id}`">
|
<MkA :class="$style.userItemMainBody" :to="`/admin/user/${item.user.id}`">
|
||||||
<MkUserCardMini :user="item.user"/>
|
<MkUserCardMini :user="item.user"/>
|
||||||
</MkA>
|
</MkA>
|
||||||
<button class="_button" :class="$style.userToggle" @click="toggleItem(item)"><i :class="$style.chevron" class="ti ti-chevron-down"></i></button>
|
<button class="_button" :class="$style.userToggle" @click="toggleItem(item)"><i :class="$style.chevron" class="ti ti-chevron-down"></i></button>
|
||||||
|
@ -45,7 +45,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
|
|
||||||
<MkPagination v-slot="{items}" ref="paginationComponent" :pagination="pagination">
|
<MkPagination v-slot="{items}" ref="paginationComponent" :pagination="pagination">
|
||||||
<div :class="$style.users">
|
<div :class="$style.users">
|
||||||
<MkA v-for="user in items" :key="user.id" v-tooltip.mfm="`Last posted: ${dateString(user.updatedAt)}`" :class="$style.user" :to="`/user-info/${user.id}`">
|
<MkA v-for="user in items" :key="user.id" v-tooltip.mfm="`Last posted: ${dateString(user.updatedAt)}`" :class="$style.user" :to="`/admin/user/${user.id}`">
|
||||||
<MkUserCardMini :user="user"/>
|
<MkUserCardMini :user="user"/>
|
||||||
</MkA>
|
</MkA>
|
||||||
</div>
|
</div>
|
||||||
@ -116,7 +116,7 @@ async function addUser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show(user) {
|
function show(user) {
|
||||||
os.pageWindow(`/user-info/${user.id}`);
|
os.pageWindow(`/admin/user/${user.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerActions = $computed(() => [{
|
const headerActions = $computed(() => [{
|
||||||
|
@ -5,20 +5,36 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<MkStickyContainer>
|
<MkStickyContainer>
|
||||||
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
||||||
<MkSpacer :contentMax="800">
|
<MkSpacer :contentMax="800">
|
||||||
<MkPagination ref="paginationEl" v-slot="{items}" :pagination="pagination" class="ruryvtyk _gaps_m">
|
<div class="_gaps">
|
||||||
<section v-for="announcement in items" :key="announcement.id" class="announcement _panel">
|
<MkInfo v-if="$i && $i.hasUnreadAnnouncement && tab === 'current'" warn>{{ i18n.ts.youHaveUnreadAnnouncements }}</MkInfo>
|
||||||
<div class="header"><span v-if="$i && !announcement.isRead">🆕 </span>{{ announcement.title }}</div>
|
<MkPagination ref="paginationEl" :key="tab" v-slot="{items}" :pagination="tab === 'current' ? paginationCurrent : paginationPast" class="_gaps">
|
||||||
<div class="content">
|
<section v-for="announcement in items" :key="announcement.id" class="_panel" :class="$style.announcement">
|
||||||
<Mfm :text="announcement.text"/>
|
<div v-if="announcement.forYou" :class="$style.forYou"><i class="ti ti-pin"></i> {{ i18n.ts.forYou }}</div>
|
||||||
<img v-if="announcement.imageUrl" :src="announcement.imageUrl"/>
|
<div :class="$style.header">
|
||||||
</div>
|
<span v-if="$i && !announcement.isRead" style="margin-right: 0.5em;">🆕</span>
|
||||||
<div v-if="$i && !announcement.isRead" class="footer">
|
<span style="margin-right: 0.5em;">
|
||||||
<MkButton primary @click="read(announcement.id)"><i class="ti ti-check"></i> {{ i18n.ts.gotIt }}</MkButton>
|
<i v-if="announcement.icon === 'info'" class="ti ti-info-circle"></i>
|
||||||
</div>
|
<i v-else-if="announcement.icon === 'warning'" class="ti ti-alert-triangle" style="color: var(--warn);"></i>
|
||||||
</section>
|
<i v-else-if="announcement.icon === 'error'" class="ti ti-circle-x" style="color: var(--error);"></i>
|
||||||
</MkPagination>
|
<i v-else-if="announcement.icon === 'success'" class="ti ti-check" style="color: var(--success);"></i>
|
||||||
|
</span>
|
||||||
|
<span>{{ announcement.title }}</span>
|
||||||
|
</div>
|
||||||
|
<div :class="$style.content">
|
||||||
|
<Mfm :text="announcement.text"/>
|
||||||
|
<img v-if="announcement.imageUrl" :src="announcement.imageUrl"/>
|
||||||
|
<div style="opacity: 0.7; font-size: 85%;">
|
||||||
|
<MkTime :time="announcement.updatedAt ?? announcement.createdAt" mode="detail"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="tab !== 'past' && $i && !announcement.isRead" :class="$style.footer">
|
||||||
|
<MkButton primary @click="read(announcement)"><i class="ti ti-check"></i> {{ i18n.ts.gotIt }}</MkButton>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</MkPagination>
|
||||||
|
</div>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
</MkStickyContainer>
|
</MkStickyContainer>
|
||||||
</template>
|
</template>
|
||||||
@ -27,30 +43,64 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import MkPagination from '@/components/MkPagination.vue';
|
import MkPagination from '@/components/MkPagination.vue';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
|
import MkInfo from '@/components/MkInfo.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
import { $i } from '@/account';
|
import { $i, updateAccount } from '@/account';
|
||||||
|
|
||||||
const pagination = {
|
const paginationCurrent = {
|
||||||
endpoint: 'announcements' as const,
|
endpoint: 'announcements' as const,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
params: {
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const paginationPast = {
|
||||||
|
endpoint: 'announcements' as const,
|
||||||
|
limit: 10,
|
||||||
|
params: {
|
||||||
|
isActive: false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const paginationEl = ref<InstanceType<typeof MkPagination>>();
|
const paginationEl = ref<InstanceType<typeof MkPagination>>();
|
||||||
|
|
||||||
function read(id: string) {
|
const tab = ref('current');
|
||||||
|
|
||||||
|
async function read(announcement) {
|
||||||
|
if (announcement.needConfirmationToRead) {
|
||||||
|
const confirm = await os.confirm({
|
||||||
|
type: 'question',
|
||||||
|
title: i18n.ts._announcement.readConfirmTitle,
|
||||||
|
text: i18n.t('_announcement.readConfirmText', { title: announcement.title }),
|
||||||
|
});
|
||||||
|
if (confirm.canceled) return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!paginationEl.value) return;
|
if (!paginationEl.value) return;
|
||||||
paginationEl.value.updateItem(id, announcement => {
|
paginationEl.value.updateItem(announcement.id, a => {
|
||||||
announcement.isRead = true;
|
a.isRead = true;
|
||||||
return announcement;
|
return a;
|
||||||
|
});
|
||||||
|
os.api('i/read-announcement', { announcementId: announcement.id });
|
||||||
|
updateAccount({
|
||||||
|
unreadAnnouncements: $i!.unreadAnnouncements.filter(a => a.id !== announcement.id),
|
||||||
});
|
});
|
||||||
os.api('i/read-announcement', { announcementId: id });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const headerActions = $computed(() => []);
|
const headerActions = $computed(() => []);
|
||||||
|
|
||||||
const headerTabs = $computed(() => []);
|
const headerTabs = $computed(() => [{
|
||||||
|
key: 'current',
|
||||||
|
title: i18n.ts.currentAnnouncements,
|
||||||
|
icon: 'ti ti-flare',
|
||||||
|
}, {
|
||||||
|
key: 'past',
|
||||||
|
title: i18n.ts.pastAnnouncements,
|
||||||
|
icon: 'ti ti-point',
|
||||||
|
}]);
|
||||||
|
|
||||||
definePageMetadata({
|
definePageMetadata({
|
||||||
title: i18n.ts.announcements,
|
title: i18n.ts.announcements,
|
||||||
@ -58,27 +108,34 @@ definePageMetadata({
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" module>
|
||||||
.ruryvtyk {
|
.announcement {
|
||||||
> .announcement {
|
padding: 16px;
|
||||||
padding: 16px;
|
}
|
||||||
|
|
||||||
> .header {
|
.forYou {
|
||||||
margin-bottom: 16px;
|
display: flex;
|
||||||
font-weight: bold;
|
align-items: center;
|
||||||
}
|
line-height: 24px;
|
||||||
|
font-size: 90%;
|
||||||
|
white-space: pre;
|
||||||
|
color: #d28a3f;
|
||||||
|
}
|
||||||
|
|
||||||
> .content {
|
.header {
|
||||||
> img {
|
margin-bottom: 16px;
|
||||||
display: block;
|
font-weight: bold;
|
||||||
max-height: 300px;
|
}
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
> .footer {
|
.content {
|
||||||
margin-top: 16px;
|
> img {
|
||||||
}
|
display: block;
|
||||||
|
max-height: 300px;
|
||||||
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -63,7 +63,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</MkFolder>
|
</MkFolder>
|
||||||
<MkSwitch v-model="isSensitive">isSensitive</MkSwitch>
|
<MkSwitch v-model="isSensitive">isSensitive</MkSwitch>
|
||||||
<MkSwitch v-model="localOnly">{{ i18n.ts.localOnly }}</MkSwitch>
|
<MkSwitch v-model="localOnly">{{ i18n.ts.localOnly }}</MkSwitch>
|
||||||
<MkButton danger @click="del()"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
|
<MkButton v-if="emoji" danger @click="del()"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
|
||||||
</div>
|
</div>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
<div :class="$style.footer">
|
<div :class="$style.footer">
|
||||||
|
@ -86,7 +86,7 @@ const tagUsersPagination = $computed(() => ({
|
|||||||
endpoint: 'hashtags/users' as const,
|
endpoint: 'hashtags/users' as const,
|
||||||
limit: 30,
|
limit: 30,
|
||||||
params: {
|
params: {
|
||||||
tag: this.tag,
|
tag: props.tag,
|
||||||
origin: 'combined',
|
origin: 'combined',
|
||||||
sort: '+follower',
|
sort: '+follower',
|
||||||
},
|
},
|
||||||
|
@ -102,7 +102,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
</div>
|
</div>
|
||||||
<div v-else-if="tab === 'users'" class="_gaps_m">
|
<div v-else-if="tab === 'users'" class="_gaps_m">
|
||||||
<MkPagination v-slot="{items}" :pagination="usersPagination" style="display: grid; grid-template-columns: repeat(auto-fill,minmax(270px,1fr)); grid-gap: 12px;">
|
<MkPagination v-slot="{items}" :pagination="usersPagination" style="display: grid; grid-template-columns: repeat(auto-fill,minmax(270px,1fr)); grid-gap: 12px;">
|
||||||
<MkA v-for="user in items" :key="user.id" v-tooltip.mfm="`Last posted: ${dateString(user.updatedAt)}`" class="user" :to="`/user-info/${user.id}`">
|
<MkA v-for="user in items" :key="user.id" v-tooltip.mfm="`Last posted: ${dateString(user.updatedAt)}`" class="user" :to="`/admin/user/${user.id}`">
|
||||||
<MkUserCardMini :user="user"/>
|
<MkUserCardMini :user="user"/>
|
||||||
</MkA>
|
</MkA>
|
||||||
</MkPagination>
|
</MkPagination>
|
||||||
|
@ -24,7 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<div class="_gaps_s">
|
<div class="_gaps_s">
|
||||||
<div v-for="item in items" :key="item.mutee.id" :class="[$style.userItem, { [$style.userItemOpend]: expandedRenoteMuteItems.includes(item.id) }]">
|
<div v-for="item in items" :key="item.mutee.id" :class="[$style.userItem, { [$style.userItemOpend]: expandedRenoteMuteItems.includes(item.id) }]">
|
||||||
<div :class="$style.userItemMain">
|
<div :class="$style.userItemMain">
|
||||||
<MkA :class="$style.userItemMainBody" :to="`/user-info/${item.mutee.id}`">
|
<MkA :class="$style.userItemMainBody" :to="userPage(item.mutee)">
|
||||||
<MkUserCardMini :user="item.mutee"/>
|
<MkUserCardMini :user="item.mutee"/>
|
||||||
</MkA>
|
</MkA>
|
||||||
<button class="_button" :class="$style.userToggle" @click="toggleRenoteMuteItem(item)"><i :class="$style.chevron" class="ti ti-chevron-down"></i></button>
|
<button class="_button" :class="$style.userToggle" @click="toggleRenoteMuteItem(item)"><i :class="$style.chevron" class="ti ti-chevron-down"></i></button>
|
||||||
@ -52,7 +52,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<div class="_gaps_s">
|
<div class="_gaps_s">
|
||||||
<div v-for="item in items" :key="item.mutee.id" :class="[$style.userItem, { [$style.userItemOpend]: expandedMuteItems.includes(item.id) }]">
|
<div v-for="item in items" :key="item.mutee.id" :class="[$style.userItem, { [$style.userItemOpend]: expandedMuteItems.includes(item.id) }]">
|
||||||
<div :class="$style.userItemMain">
|
<div :class="$style.userItemMain">
|
||||||
<MkA :class="$style.userItemMainBody" :to="`/user-info/${item.mutee.id}`">
|
<MkA :class="$style.userItemMainBody" :to="userPage(item.mutee)">
|
||||||
<MkUserCardMini :user="item.mutee"/>
|
<MkUserCardMini :user="item.mutee"/>
|
||||||
</MkA>
|
</MkA>
|
||||||
<button class="_button" :class="$style.userToggle" @click="toggleMuteItem(item)"><i :class="$style.chevron" class="ti ti-chevron-down"></i></button>
|
<button class="_button" :class="$style.userToggle" @click="toggleMuteItem(item)"><i :class="$style.chevron" class="ti ti-chevron-down"></i></button>
|
||||||
@ -82,7 +82,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<div class="_gaps_s">
|
<div class="_gaps_s">
|
||||||
<div v-for="item in items" :key="item.blockee.id" :class="[$style.userItem, { [$style.userItemOpend]: expandedBlockItems.includes(item.id) }]">
|
<div v-for="item in items" :key="item.blockee.id" :class="[$style.userItem, { [$style.userItemOpend]: expandedBlockItems.includes(item.id) }]">
|
||||||
<div :class="$style.userItemMain">
|
<div :class="$style.userItemMain">
|
||||||
<MkA :class="$style.userItemMainBody" :to="`/user-info/${item.blockee.id}`">
|
<MkA :class="$style.userItemMainBody" :to="userPage(item.blockee)">
|
||||||
<MkUserCardMini :user="item.blockee"/>
|
<MkUserCardMini :user="item.blockee"/>
|
||||||
</MkA>
|
</MkA>
|
||||||
<button class="_button" :class="$style.userToggle" @click="toggleBlockItem(item)"><i :class="$style.chevron" class="ti ti-chevron-down"></i></button>
|
<button class="_button" :class="$style.userToggle" @click="toggleBlockItem(item)"><i :class="$style.chevron" class="ti ti-chevron-down"></i></button>
|
||||||
|
@ -42,10 +42,6 @@ export const routes = [{
|
|||||||
}, {
|
}, {
|
||||||
path: '/clips/:clipId',
|
path: '/clips/:clipId',
|
||||||
component: page(() => import('./pages/clip.vue')),
|
component: page(() => import('./pages/clip.vue')),
|
||||||
}, {
|
|
||||||
path: '/user-info/:userId',
|
|
||||||
component: page(() => import('./pages/user-info.vue')),
|
|
||||||
hash: 'initialTab',
|
|
||||||
}, {
|
}, {
|
||||||
path: '/instance-info/:host',
|
path: '/instance-info/:host',
|
||||||
component: page(() => import('./pages/instance-info.vue')),
|
component: page(() => import('./pages/instance-info.vue')),
|
||||||
@ -334,6 +330,9 @@ export const routes = [{
|
|||||||
}, {
|
}, {
|
||||||
path: '/registry',
|
path: '/registry',
|
||||||
component: page(() => import('./pages/registry.vue')),
|
component: page(() => import('./pages/registry.vue')),
|
||||||
|
}, {
|
||||||
|
path: '/admin/user/:userId',
|
||||||
|
component: iAmModerator ? page(() => import('./pages/admin-user.vue')) : page(() => import('./pages/not-found.vue')),
|
||||||
}, {
|
}, {
|
||||||
path: '/admin/file/:fileId',
|
path: '/admin/file/:fileId',
|
||||||
component: iAmModerator ? page(() => import('./pages/admin-file.vue')) : page(() => import('./pages/not-found.vue')),
|
component: iAmModerator ? page(() => import('./pages/admin-file.vue')) : page(() => import('./pages/not-found.vue')),
|
||||||
|
@ -133,13 +133,13 @@ export function getUserMenu(user: misskey.entities.UserDetailed, router: Router
|
|||||||
action: () => {
|
action: () => {
|
||||||
copyToClipboard(`@${user.username}@${user.host ?? host}`);
|
copyToClipboard(`@${user.username}@${user.host ?? host}`);
|
||||||
},
|
},
|
||||||
}, {
|
}, ...(iAmModerator ? [{
|
||||||
icon: 'ti ti-info-circle',
|
icon: 'ti ti-user-exclamation',
|
||||||
text: i18n.ts.info,
|
text: i18n.ts.moderation,
|
||||||
action: () => {
|
action: () => {
|
||||||
router.push(`/user-info/${user.id}`);
|
router.push(`/admin/user/${user.id}`);
|
||||||
},
|
},
|
||||||
}, {
|
}] : []), {
|
||||||
icon: 'ti ti-rss',
|
icon: 'ti ti-rss',
|
||||||
text: i18n.ts.copyRSS,
|
text: i18n.ts.copyRSS,
|
||||||
action: () => {
|
action: () => {
|
||||||
|
@ -14,7 +14,7 @@ export async function lookupUser() {
|
|||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
|
|
||||||
const show = (user) => {
|
const show = (user) => {
|
||||||
os.pageWindow(`/user-info/${user.id}`);
|
os.pageWindow(`/admin/user/${user.id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const usernamePromise = os.api('users/show', Acct.parse(result));
|
const usernamePromise = os.api('users/show', Acct.parse(result));
|
||||||
|
@ -30,7 +30,7 @@ export function getScrollPosition(el: HTMLElement | null): number {
|
|||||||
|
|
||||||
export function onScrollTop(el: HTMLElement, cb: () => unknown, tolerance = 1, once = false) {
|
export function onScrollTop(el: HTMLElement, cb: () => unknown, tolerance = 1, once = false) {
|
||||||
// とりあえず評価してみる
|
// とりあえず評価してみる
|
||||||
if (isTopVisible(el)) {
|
if (el.isConnected && isTopVisible(el)) {
|
||||||
cb();
|
cb();
|
||||||
if (once) return null;
|
if (once) return null;
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ export function onScrollBottom(el: HTMLElement, cb: () => unknown, tolerance = 1
|
|||||||
const container = getScrollContainer(el);
|
const container = getScrollContainer(el);
|
||||||
|
|
||||||
// とりあえず評価してみる
|
// とりあえず評価してみる
|
||||||
if (isBottomVisible(el, tolerance, container)) {
|
if (el.isConnected && isBottomVisible(el, tolerance, container)) {
|
||||||
cb();
|
cb();
|
||||||
if (once) return null;
|
if (once) return null;
|
||||||
}
|
}
|
||||||
|
80
packages/frontend/src/ui/_common_/announcements.vue
Normal file
80
packages/frontend/src/ui/_common_/announcements.vue
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div :class="$style.root">
|
||||||
|
<MkA
|
||||||
|
v-for="announcement in $i.unreadAnnouncements.filter(x => x.display === 'banner')"
|
||||||
|
:key="announcement.id"
|
||||||
|
:class="$style.item"
|
||||||
|
to="/announcements"
|
||||||
|
>
|
||||||
|
<span :class="$style.icon">
|
||||||
|
<i v-if="announcement.icon === 'info'" class="ti ti-info-circle"></i>
|
||||||
|
<i v-else-if="announcement.icon === 'warning'" class="ti ti-alert-triangle" style="color: var(--warn);"></i>
|
||||||
|
<i v-else-if="announcement.icon === 'error'" class="ti ti-circle-x" style="color: var(--error);"></i>
|
||||||
|
<i v-else-if="announcement.icon === 'success'" class="ti ti-check" style="color: var(--success);"></i>
|
||||||
|
</span>
|
||||||
|
<span :class="$style.title">{{ announcement.title }}</span>
|
||||||
|
<span :class="$style.body">{{ announcement.text }}</span>
|
||||||
|
</MkA>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { $i } from '@/account';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" module>
|
||||||
|
.root {
|
||||||
|
font-size: 15px;
|
||||||
|
background: var(--panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
--height: 24px;
|
||||||
|
font-size: 0.85em;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
vertical-align: bottom;
|
||||||
|
width: 100%;
|
||||||
|
line-height: var(--height);
|
||||||
|
height: var(--height);
|
||||||
|
overflow: clip;
|
||||||
|
contain: strict;
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--fgOnAccent);
|
||||||
|
|
||||||
|
@container (max-width: 1000px) {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
> .body {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
padding: 0 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
|
&:empty {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.body {
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1;
|
||||||
|
overflow: clip;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
</style>
|
@ -8,6 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<XSidebar v-if="!isMobile"/>
|
<XSidebar v-if="!isMobile"/>
|
||||||
|
|
||||||
<div :class="$style.main">
|
<div :class="$style.main">
|
||||||
|
<XAnnouncements v-if="$i" :class="$style.announcements"/>
|
||||||
<XStatusBars/>
|
<XStatusBars/>
|
||||||
<div ref="columnsEl" :class="[$style.sections, { [$style.center]: deckStore.reactiveState.columnAlign.value === 'center', [$style.snapScroll]: snapScroll }]" @contextmenu.self.prevent="onContextmenu" @wheel.self="onWheel">
|
<div ref="columnsEl" :class="[$style.sections, { [$style.center]: deckStore.reactiveState.columnAlign.value === 'center', [$style.snapScroll]: snapScroll }]" @contextmenu.self.prevent="onContextmenu" @wheel.self="onWheel">
|
||||||
<!-- sectionを利用しているのは、deck.vue側でcolumnに対してfirst-of-typeを効かせるため -->
|
<!-- sectionを利用しているのは、deck.vue側でcolumnに対してfirst-of-typeを効かせるため -->
|
||||||
@ -113,6 +114,7 @@ import XMentionsColumn from '@/ui/deck/mentions-column.vue';
|
|||||||
import XDirectColumn from '@/ui/deck/direct-column.vue';
|
import XDirectColumn from '@/ui/deck/direct-column.vue';
|
||||||
import XRoleTimelineColumn from '@/ui/deck/role-timeline-column.vue';
|
import XRoleTimelineColumn from '@/ui/deck/role-timeline-column.vue';
|
||||||
const XStatusBars = defineAsyncComponent(() => import('@/ui/_common_/statusbars.vue'));
|
const XStatusBars = defineAsyncComponent(() => import('@/ui/_common_/statusbars.vue'));
|
||||||
|
const XAnnouncements = defineAsyncComponent(() => import('@/ui/_common_/announcements.vue'));
|
||||||
|
|
||||||
const columnComponents = {
|
const columnComponents = {
|
||||||
main: XMainColumn,
|
main: XMainColumn,
|
||||||
|
@ -8,7 +8,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
<XSidebar v-if="!isMobile" :class="$style.sidebar"/>
|
<XSidebar v-if="!isMobile" :class="$style.sidebar"/>
|
||||||
|
|
||||||
<MkStickyContainer ref="contents" :class="$style.contents" style="container-type: inline-size;" @contextmenu.stop="onContextmenu">
|
<MkStickyContainer ref="contents" :class="$style.contents" style="container-type: inline-size;" @contextmenu.stop="onContextmenu">
|
||||||
<template #header><XStatusBars :class="$style.statusbars"/></template>
|
<template #header>
|
||||||
|
<div>
|
||||||
|
<XAnnouncements v-if="$i" :class="$style.announcements"/>
|
||||||
|
<XStatusBars :class="$style.statusbars"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<RouterView/>
|
<RouterView/>
|
||||||
<div :class="$style.spacer"></div>
|
<div :class="$style.spacer"></div>
|
||||||
</MkStickyContainer>
|
</MkStickyContainer>
|
||||||
@ -105,6 +110,7 @@ import { useScrollPositionManager } from '@/nirax';
|
|||||||
const XWidgets = defineAsyncComponent(() => import('./universal.widgets.vue'));
|
const XWidgets = defineAsyncComponent(() => import('./universal.widgets.vue'));
|
||||||
const XSidebar = defineAsyncComponent(() => import('@/ui/_common_/navbar.vue'));
|
const XSidebar = defineAsyncComponent(() => import('@/ui/_common_/navbar.vue'));
|
||||||
const XStatusBars = defineAsyncComponent(() => import('@/ui/_common_/statusbars.vue'));
|
const XStatusBars = defineAsyncComponent(() => import('@/ui/_common_/statusbars.vue'));
|
||||||
|
const XAnnouncements = defineAsyncComponent(() => import('@/ui/_common_/announcements.vue'));
|
||||||
|
|
||||||
const DESKTOP_THRESHOLD = 1100;
|
const DESKTOP_THRESHOLD = 1100;
|
||||||
const MOBILE_THRESHOLD = 500;
|
const MOBILE_THRESHOLD = 500;
|
||||||
|
64
packages/frontend/test/scroll.test.ts
Normal file
64
packages/frontend/test/scroll.test.ts
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { describe, test, assert, afterEach } from 'vitest';
|
||||||
|
import { Window } from 'happy-dom';
|
||||||
|
import { onScrollBottom, onScrollTop } from '@/scripts/scroll';
|
||||||
|
|
||||||
|
describe('Scroll', () => {
|
||||||
|
describe('onScrollTop', () => {
|
||||||
|
test('Initial onScrollTop callback for connected elements', () => {
|
||||||
|
const { document } = new Window();
|
||||||
|
const div = document.createElement('div');
|
||||||
|
assert.strictEqual(div.scrollTop, 0);
|
||||||
|
|
||||||
|
document.body.append(div);
|
||||||
|
|
||||||
|
let called = false;
|
||||||
|
onScrollTop(div as any as HTMLElement, () => called = true);
|
||||||
|
|
||||||
|
assert.ok(called);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('No onScrollTop callback for disconnected elements', () => {
|
||||||
|
const { document } = new Window();
|
||||||
|
const div = document.createElement('div');
|
||||||
|
assert.strictEqual(div.scrollTop, 0);
|
||||||
|
|
||||||
|
let called = false;
|
||||||
|
onScrollTop(div as any as HTMLElement, () => called = true);
|
||||||
|
|
||||||
|
assert.ok(!called);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('onScrollBottom', () => {
|
||||||
|
test('Initial onScrollBottom callback for connected elements', () => {
|
||||||
|
const { document } = new Window();
|
||||||
|
const div = document.createElement('div');
|
||||||
|
assert.strictEqual(div.scrollTop, 0);
|
||||||
|
(div as any).scrollHeight = 100; // happy-dom has no scrollHeight
|
||||||
|
|
||||||
|
document.body.append(div);
|
||||||
|
|
||||||
|
let called = false;
|
||||||
|
onScrollBottom(div as any as HTMLElement, () => called = true);
|
||||||
|
|
||||||
|
assert.ok(called);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('No onScrollBottom callback for disconnected elements', () => {
|
||||||
|
const { document } = new Window();
|
||||||
|
const div = document.createElement('div');
|
||||||
|
assert.strictEqual(div.scrollTop, 0);
|
||||||
|
(div as any).scrollHeight = 100; // happy-dom has no scrollHeight
|
||||||
|
|
||||||
|
let called = false;
|
||||||
|
onScrollBottom(div as any as HTMLElement, () => called = true);
|
||||||
|
|
||||||
|
assert.ok(!called);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -13,7 +13,7 @@ import MkUrlPreview from '@/components/MkUrlPreview.vue';
|
|||||||
|
|
||||||
type SummalyResult = Awaited<ReturnType<typeof summaly>>;
|
type SummalyResult = Awaited<ReturnType<typeof summaly>>;
|
||||||
|
|
||||||
describe('MkMediaImage', () => {
|
describe('MkUrlPreview', () => {
|
||||||
const renderPreviewBy = async (summary: Partial<SummalyResult>): Promise<RenderResult> => {
|
const renderPreviewBy = async (summary: Partial<SummalyResult>): Promise<RenderResult> => {
|
||||||
if (!summary.player) {
|
if (!summary.player) {
|
||||||
summary.player = {
|
summary.player = {
|
||||||
@ -143,4 +143,13 @@ describe('MkMediaImage', () => {
|
|||||||
assert.exists(iframe, 'iframe should exist');
|
assert.exists(iframe, 'iframe should exist');
|
||||||
assert.strictEqual(iframe?.parentElement?.style.paddingTop, '200px');
|
assert.strictEqual(iframe?.parentElement?.style.paddingTop, '200px');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Loading a tweet in iframe', async () => {
|
||||||
|
const iframe = await renderAndOpenPreview({
|
||||||
|
url: 'https://twitter.com/i/web/status/1685072521782325249',
|
||||||
|
});
|
||||||
|
assert.exists(iframe, 'iframe should exist');
|
||||||
|
assert.strictEqual(iframe?.getAttribute('allow'), 'fullscreen;web-share');
|
||||||
|
assert.strictEqual(iframe?.getAttribute('sandbox'), 'allow-popups allow-scripts allow-same-origin');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -30,6 +30,10 @@ type Announcement = {
|
|||||||
text: string;
|
text: string;
|
||||||
title: string;
|
title: string;
|
||||||
imageUrl: string | null;
|
imageUrl: string | null;
|
||||||
|
display: 'normal' | 'banner' | 'dialog';
|
||||||
|
icon: 'info' | 'warning' | 'error' | 'success';
|
||||||
|
needConfirmationToRead: boolean;
|
||||||
|
forYou: boolean;
|
||||||
isRead?: boolean;
|
isRead?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2453,6 +2457,7 @@ type MeDetailed = UserDetailed & {
|
|||||||
noCrawle: boolean;
|
noCrawle: boolean;
|
||||||
receiveAnnouncementEmail: boolean;
|
receiveAnnouncementEmail: boolean;
|
||||||
usePasswordLessLogin: boolean;
|
usePasswordLessLogin: boolean;
|
||||||
|
unreadAnnouncements: Announcement[];
|
||||||
[other: string]: any;
|
[other: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,6 +104,7 @@ export type MeDetailed = UserDetailed & {
|
|||||||
noCrawle: boolean;
|
noCrawle: boolean;
|
||||||
receiveAnnouncementEmail: boolean;
|
receiveAnnouncementEmail: boolean;
|
||||||
usePasswordLessLogin: boolean;
|
usePasswordLessLogin: boolean;
|
||||||
|
unreadAnnouncements: Announcement[];
|
||||||
[other: string]: any;
|
[other: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -413,6 +414,10 @@ export type Announcement = {
|
|||||||
text: string;
|
text: string;
|
||||||
title: string;
|
title: string;
|
||||||
imageUrl: string | null;
|
imageUrl: string | null;
|
||||||
|
display: 'normal' | 'banner' | 'dialog';
|
||||||
|
icon: 'info' | 'warning' | 'error' | 'success';
|
||||||
|
needConfirmationToRead: boolean;
|
||||||
|
forYou: boolean;
|
||||||
isRead?: boolean;
|
isRead?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user