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

feat: ユーザースキーマの改善 #12568

Merged
merged 5 commits into from
Dec 4, 2023

Conversation

yupix
Copy link
Contributor

@yupix yupix commented Dec 4, 2023

What

  • packedUserDetailedNotMeOnlySchema.notifyenum を追加しました
  • packedMeDetailedOnlySchema.securityKeysListproperties を定義しました

Why

現状だとドキュメントから securityKeysListobject であることしか知ることが出来ない為。また、notify にはどのような文字列が入るのか明確にするため

Additional info (optional)

現状は何も手を加えていませんが notificationRecieveConfig にも properties を定義したいと考えています。愚直に記述すると量がとても多いため、部分的に別の変数に分けてそれを使うようにしたいのですが、大丈夫でしょうか?
以下がやりたい物になるので、大丈夫そうでしたらこちらもコミットしようと思います

const notificationRecieveConfig = {
	type: 'object',
	nullable: false, optional: true,
	properties: {
		type: {
			type: 'string',
			enum: ['all', 'following', 'follower', 'mutualFollow', 'list', 'never'],
			nullable: false, optional: false,
		}
	}
}

export const packedMeDetailedOnlySchema = {
	type: 'object',
	properties: {
		// ...
		notificationRecieveConfig: {
			type: 'object',
			nullable: false, optional: false,
			properties: {
				app: notificationRecieveConfig,
				quote: notificationRecieveConfig,
				reply: notificationRecieveConfig,
				follow: notificationRecieveConfig,
				renote: notificationRecieveConfig,
				mention: notificationRecieveConfig,
				reaction: notificationRecieveConfig,
				pollEnded: notificationRecieveConfig,
				achievementEarned: notificationRecieveConfig,
				receiveFollowRequest: notificationRecieveConfig,
				followRequestAccepted: notificationRecieveConfig,
			},
		},
		// ...
	},
} as const;

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 Dec 4, 2023
Copy link

codecov bot commented Dec 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (55c8ec8) 78.74% compared to head (9bd0e07) 78.76%.
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #12568      +/-   ##
===========================================
+ Coverage    78.74%   78.76%   +0.01%     
===========================================
  Files          954      955       +1     
  Lines       103825   103860      +35     
  Branches      8351     8327      -24     
===========================================
+ Hits         81758    81806      +48     
+ Misses       22067    22054      -13     

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

Copy link
Contributor

github-actions bot commented Dec 4, 2023

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

差分はこちら
--- base
+++ head
@@ -63495,7 +63495,11 @@
           },
           "notify": {
             "type": "string",
-            "nullable": false
+            "nullable": false,
+            "enum": [
+              "normal",
+              "none"
+            ]
           },
           "withReplies": {
             "type": "boolean",
@@ -63686,7 +63690,240 @@
           },
           "notificationRecieveConfig": {
             "type": "object",
-            "nullable": false
+            "nullable": false,
+            "properties": {
+              "app": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "quote": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "reply": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "follow": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "renote": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "mention": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "reaction": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "pollEnded": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "achievementEarned": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "receiveFollowRequest": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              },
+              "followRequestAccepted": {
+                "type": "object",
+                "nullable": false,
+                "properties": {
+                  "type": {
+                    "type": "string",
+                    "nullable": false,
+                    "enum": [
+                      "all",
+                      "following",
+                      "follower",
+                      "mutualFollow",
+                      "list",
+                      "never"
+                    ]
+                  }
+                },
+                "required": [
+                  "type"
+                ]
+              }
+            }
           },
           "emailNotificationTypes": {
             "type": "array",
@@ -63858,7 +64095,29 @@
             "nullable": false,
             "items": {
               "type": "object",
-              "nullable": false
+              "nullable": false,
+              "properties": {
+                "id": {
+                  "type": "string",
+                  "nullable": false,
+                  "format": "id",
+                  "example": "xxxxxxxxxx"
+                },
+                "name": {
+                  "type": "string",
+                  "nullable": false
+                },
+                "lastUsed": {
+                  "type": "string",
+                  "nullable": false,
+                  "format": "date-time"
+                }
+              },
+              "required": [
+                "id",
+                "name",
+                "lastUsed"
+              ]
             }
           }
         },

Get diff files from Workflow Page

@syuilo
Copy link
Member

syuilo commented Dec 4, 2023

現状は何も手を加えていませんが notificationRecieveConfig にも properties を定義したいと考えています。愚直に記述すると量がとても多いため、部分的に別の変数に分けてそれを使うようにしたいのですが、大丈夫でしょうか?
以下がやりたい物になるので、大丈夫そうでしたらこちらもコミットしようと思います

👍🏻

@yupix
Copy link
Contributor Author

yupix commented Dec 4, 2023

了解しました。Misskey.jsの更新までするので少々お待ちください🙏

@yupix
Copy link
Contributor Author

yupix commented Dec 4, 2023

出来ました

@syuilo
Copy link
Member

syuilo commented Dec 4, 2023

バックエンドの型チェックが失敗してるのが直れば良さそうです 👍🏻

@yupix
Copy link
Contributor Author

yupix commented Dec 4, 2023

直ったと思います

@syuilo syuilo merged commit 33034b0 into misskey-dev:develop Dec 4, 2023
18 checks passed
@syuilo
Copy link
Member

syuilo commented Dec 4, 2023

🙏🙏

@yupix yupix deleted the feat/schema-modification branch December 4, 2023 07:53
camilla-ett pushed a commit to kaseiski/misskey that referenced this pull request Jan 2, 2024
* chore: notifyにenumを設定

* feat: securityKeysListの型を明確に

* feat: notificationRecieveConfigにpropertiesを定義

* chore: misskey.jsのmodelを更新

* fix: as constをつけ忘れている
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