Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backend): correct app-type notification schema #14471

Merged

Conversation

zyoshoka
Copy link
Contributor

What

app タイプの通知のスキーマ・型が不正確なのを修正します。

Why

app タイプの通知を発行しているのはこの部分です:

this.notificationService.createNotification(user.id, 'app', {
appAccessTokenId: token ? token.id : null,
customBody: ps.body,
customHeader: ps.header ?? token?.name ?? null,
customIcon: ps.icon ?? token?.iconUrl ?? null,
});

...(notification.type === 'app' ? {
body: notification.customBody,
header: notification.customHeader,
icon: notification.customIcon,
} : {}),

次の問題があります:

  • customBodynull になりえないことが Ajv のバリデーションで保証されているが、型では null がついてしまっていて不正確
  • headericonnull になりうるが、スキーマでは nullable: false になってしまっていて不正確

Additional info (optional)

CHANGELOG の更新は微妙なのでとりあえず見送っています

Checklist

  • Read the contribution guide
  • Test working in a local environment
  • (If needed) Add story of storybook
  • (If needed) Update CHANGELOG.md
  • (If possible) Add tests

@github-actions github-actions bot added packages/backend Server side specific issue/PR packages/misskey-js labels Aug 27, 2024
Copy link
Contributor

このPRによるapi.jsonの差分

差分はこちら
--- base
+++ head
@@ -78515,10 +78515,16 @@
                 "type": "string"
               },
               "header": {
-                "type": "string"
+                "type": [
+                  "string",
+                  "null"
+                ]
               },
               "icon": {
-                "type": "string"
+                "type": [
+                  "string",
+                  "null"
+                ]
               }
             },
             "required": [

Get diff files from Workflow Page

Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 61.71%. Comparing base (b6fdd71) to head (9ddb36d).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
packages/backend/src/models/Notification.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           develop   #14471       +/-   ##
============================================
+ Coverage    39.76%   61.71%   +21.94%     
============================================
  Files         1547      822      -725     
  Lines       190996    90449   -100547     
  Branches      3552     1605     -1947     
============================================
- Hits         75948    55818    -20130     
+ Misses      114484    34611    -79873     
+ Partials       564       20      -544     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@syuilo syuilo merged commit 3e85052 into misskey-dev:develop Aug 29, 2024
28 checks passed
@syuilo
Copy link
Member

syuilo commented Aug 29, 2024

🙏🏿

@zyoshoka zyoshoka deleted the correct-app-type-notification-schema branch August 29, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages/backend Server side specific issue/PR packages/misskey-js
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants