misskey-dev / misskey

🌎 An interplanetary microblogging platform 🚀
https://misskey-hub.net/
GNU Affero General Public License v3.0
9.63k stars 1.28k forks source link

WIP: feat: 投稿の編集に対応 #14011

Open GrapeApple0 opened 1 week ago

GrapeApple0 commented 1 week ago

What

ActivityPub経由の投稿の編集に対応しました。

Why

Mastodonなどからの投稿の編集が反映されないため Resolve: #8364 Related: #11944

Additional info (optional)

Checklist

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 44.64752% with 848 lines in your changes missing coverage. Please review.

Project coverage is 66.27%. Comparing base (a9012d3) to head (8fd0d69).

:exclamation: Current head 8fd0d69 differs from pull request most recent head 7e451e0

Please upload reports for the commit 7e451e0 to get more accurate results.

Files Patch % Lines
packages/backend/src/core/NoteEditService.ts 30.18% 370 Missing :warning:
...kend/src/core/entities/NoteHistoryEntityService.ts 27.47% 198 Missing :warning:
...ckend/src/core/activitypub/models/ApNoteService.ts 4.61% 186 Missing :warning:
...s/backend/src/server/api/endpoints/notes/update.ts 67.60% 46 Missing :warning:
.../backend/src/server/api/endpoints/notes/history.ts 69.73% 23 Missing :warning:
.../backend/src/core/activitypub/ApRendererService.ts 16.66% 15 Missing :warning:
packages/backend/src/models/NoteHistory.ts 93.82% 5 Missing :warning:
...ges/backend/src/core/activitypub/ApInboxService.ts 20.00% 4 Missing :warning:
...ges/backend/src/core/entities/NoteEntityService.ts 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #14011 +/- ## ============================================ - Coverage 77.79% 66.27% -11.52% ============================================ Files 184 1017 +833 Lines 25536 121553 +96017 Branches 487 4739 +4252 ============================================ + Hits 19865 80557 +60692 - Misses 5664 40965 +35301 - Partials 7 31 +24 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 1 week ago

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

差分はこちら ```diff --- base +++ head @@ -56803,6 +56803,183 @@ } } }, + "/notes/history": { + "post": { + "operationId": "notes___history", + "summary": "notes/history", + "description": "No description provided.\n\n**Credential required**: *No*", + "externalDocs": { + "description": "Source code", + "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/notes/history.ts" + }, + "tags": [ + "notes" + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 10 + }, + "noteId": { + "type": "string", + "format": "misskey:id" + }, + "sinceId": { + "type": "string", + "format": "misskey:id" + }, + "untilId": { + "type": "string", + "format": "misskey:id" + } + }, + "required": [ + "noteId" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK (with results)", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/components/schemas/NoteHistory" + } + } + } + } + }, + "400": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "NO_SUCH_NOTE": { + "value": { + "error": { + "message": "No such note.", + "code": "NO_SUCH_NOTE", + "id": "24fcbfc6-2e37-42b6-8388-c29b3861a08d" + } + } + }, + "INVALID_PARAM": { + "value": { + "error": { + "message": "Invalid param.", + "code": "INVALID_PARAM", + "id": "3d81ceae-475f-4600-b2a8-2bc116157532" + } + } + } + } + } + } + }, + "401": { + "description": "Authentication error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "CREDENTIAL_REQUIRED": { + "value": { + "error": { + "message": "Credential required.", + "code": "CREDENTIAL_REQUIRED", + "id": "1384574d-a912-4b81-8601-c7b1c4085df1" + } + } + } + } + } + } + }, + "403": { + "description": "Forbidden error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "AUTHENTICATION_FAILED": { + "value": { + "error": { + "message": "Authentication failed. Please ensure your token is correct.", + "code": "AUTHENTICATION_FAILED", + "id": "b0a7f5f8-dc2f-4171-b91f-de88ad238e14" + } + } + } + } + } + } + }, + "418": { + "description": "I'm Ai", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "I_AM_AI": { + "value": { + "error": { + "message": "You sent a request to Ai-chan, Misskey's showgirl, instead of the server.", + "code": "I_AM_AI", + "id": "60c46cd1-f23a-46b1-bebe-5d2b73951a84" + } + } + } + } + } + } + }, + "500": { + "description": "Internal server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "INTERNAL_ERROR": { + "value": { + "error": { + "message": "Internal error occurred. Please contact us if the error persists.", + "code": "INTERNAL_ERROR", + "id": "5d37dbcb-891e-41ca-a3d6-e690c97775ac" + } + } + } + } + } + } + } + } + } + }, "/notes/hybrid-timeline": { "post": { "operationId": "notes___hybrid-timeline", @@ -60495,6 +60672,264 @@ } } }, + "/notes/update": { + "post": { + "operationId": "notes___update", + "summary": "notes/update", + "description": "No description provided.\n\n**Credential required**: *Yes* / **Permission**: *write:notes*", + "externalDocs": { + "description": "Source code", + "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/notes/update.ts" + }, + "tags": [ + "notes" + ], + "security": [ + { + "bearerAuth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "noteId": { + "type": "string", + "format": "misskey:id" + }, + "text": { + "type": "string", + "minLength": 1, + "maxLength": 3000 + }, + "cw": { + "type": [ + "string", + "null" + ], + "maxLength": 100 + }, + "fileIds": { + "type": "array", + "uniqueItems": true, + "minItems": 1, + "maxItems": 16, + "items": { + "type": "string", + "format": "misskey:id" + } + }, + "poll": { + "type": [ + "object", + "null" + ], + "properties": { + "choices": { + "type": "array", + "uniqueItems": true, + "minItems": 2, + "maxItems": 10, + "items": { + "type": "string", + "minLength": 1, + "maxLength": 50 + } + }, + "multiple": { + "type": "boolean" + }, + "expiresAt": { + "type": [ + "integer", + "null" + ] + }, + "expiredAfter": { + "type": [ + "integer", + "null" + ], + "minimum": 1 + } + }, + "required": [ + "choices" + ] + } + }, + "required": [ + "noteId", + "text", + "cw" + ] + } + } + } + }, + "responses": { + "204": { + "description": "OK (without any results)" + }, + "400": { + "description": "Client error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "NO_SUCH_NOTE": { + "value": { + "error": { + "message": "No such note.", + "code": "NO_SUCH_NOTE", + "id": "a6584e14-6e01-4ad3-b566-851e7bf0d474" + } + } + }, + "ACCESS_DENIED": { + "value": { + "error": { + "message": "Access denied.", + "code": "ACCESS_DENIED", + "id": "fe8d7103-0ea8-4ec3-814d-f8b401dc69e9" + } + } + }, + "CONTAINS_PROHIBITED_WORDS": { + "value": { + "error": { + "message": "Cannot post because it contains prohibited words.", + "code": "CONTAINS_PROHIBITED_WORDS", + "id": "aa6e01d3-a85c-669d-758a-76aab43af334" + } + } + }, + "INVALID_PARAM": { + "value": { + "error": { + "message": "Invalid param.", + "code": "INVALID_PARAM", + "id": "3d81ceae-475f-4600-b2a8-2bc116157532" + } + } + } + } + } + } + }, + "401": { + "description": "Authentication error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "CREDENTIAL_REQUIRED": { + "value": { + "error": { + "message": "Credential required.", + "code": "CREDENTIAL_REQUIRED", + "id": "1384574d-a912-4b81-8601-c7b1c4085df1" + } + } + } + } + } + } + }, + "403": { + "description": "Forbidden error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "AUTHENTICATION_FAILED": { + "value": { + "error": { + "message": "Authentication failed. Please ensure your token is correct.", + "code": "AUTHENTICATION_FAILED", + "id": "b0a7f5f8-dc2f-4171-b91f-de88ad238e14" + } + } + } + } + } + } + }, + "418": { + "description": "I'm Ai", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "I_AM_AI": { + "value": { + "error": { + "message": "You sent a request to Ai-chan, Misskey's showgirl, instead of the server.", + "code": "I_AM_AI", + "id": "60c46cd1-f23a-46b1-bebe-5d2b73951a84" + } + } + } + } + } + } + }, + "429": { + "description": "To many requests", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "RATE_LIMIT_EXCEEDED": { + "value": { + "error": { + "message": "Rate limit exceeded. Please try again later.", + "code": "RATE_LIMIT_EXCEEDED", + "id": "d5826d14-3982-4d2e-8011-b9e9f02499ef" + } + } + } + } + } + } + }, + "500": { + "description": "Internal server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + }, + "examples": { + "INTERNAL_ERROR": { + "value": { + "error": { + "message": "Internal error occurred. Please contact us if the error persists.", + "code": "INTERNAL_ERROR", + "id": "5d37dbcb-891e-41ca-a3d6-e690c97775ac" + } + } + } + } + } + } + } + } + } + }, "/notes/user-list-timeline": { "post": { "operationId": "notes___user-list-timeline", @@ -77697,6 +78132,13 @@ "type": "string", "format": "date-time" }, + "updatedAt": { + "type": [ + "string", + "null" + ], + "format": "date-time" + }, "deletedAt": { "type": [ "string", @@ -77982,6 +78424,123 @@ "repliesCount" ] }, + "NoteHistory": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "id", + "example": "xxxxxxxxxx" + }, + "targetId": { + "type": "string", + "format": "id", + "example": "xxxxxxxxxx" + }, + "createdAt": { + "type": "string", + "format": "date-time" + }, + "text": { + "type": [ + "string", + "null" + ] + }, + "cw": { + "type": [ + "string", + "null" + ] + }, + "mentions": { + "type": "array", + "items": { + "type": "string", + "format": "id" + } + }, + "fileIds": { + "type": "array", + "items": { + "type": "string", + "format": "id" + } + }, + "files": { + "type": "array", + "items": { + "type": "object", + "$ref": "#/components/schemas/DriveFile" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "poll": { + "type": [ + "object", + "null" + ], + "properties": { + "expiresAt": { + "type": [ + "string", + "null" + ], + "format": "date-time" + }, + "multiple": { + "type": "boolean" + }, + "choices": { + "type": "array", + "items": { + "type": "object", + "properties": { + "isVoted": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "votes": { + "type": "number" + } + }, + "required": [ + "isVoted", + "text", + "votes" + ] + } + } + }, + "required": [ + "multiple", + "choices" + ] + }, + "emojis": { + "type": "object", + "additionalProperties": { + "anyOf": [ + { + "type": "string" + } + ] + } + } + }, + "required": [ + "id", + "targetId", + "createdAt" + ] + }, "NoteReaction": { "type": "object", "properties": { @@ -80331,6 +80890,9 @@ "canPublicNote": { "type": "boolean" }, + "canEditNote": { + "type": "boolean" + }, "mentionLimit": { "type": "integer" }, @@ -80402,6 +80964,7 @@ "gtlAvailable", "ltlAvailable", "canPublicNote", + "canEditNote", "mentionLimit", "canInvite", "inviteLimit", ```

Get diff files from Workflow Page

kakkokari-gtyih commented 1 week ago

(ある場合)検索インデックスの更新とかハッシュタグテーブルの更新とかって、これでできてるのかしら(以前はそのへんまで対応が回らなかったのでお流れになったため)

kakkokari-gtyih commented 1 week ago

(ある場合)検索インデックスの更新とかハッシュタグテーブルの更新とかって、これでできてるのかしら(以前はそのへんまで対応が回らなかったのでお流れになったため)

やってるっぽかった🙏 ドライブのセンシティブフラグが変わったときに紐付くノートについて連合に対する更新処理をかける必要もありそう

syuilo commented 1 week ago

実装できたとしても編集を実現するためだけにしてはコード量が多くなりすぎるから、テストをかなり充実させるとかでない限り採用は難しいかもしれない

tai-cha commented 1 week ago

ぱっと見編集を実現させるのにあまり余計過ぎる部分もなかったのでテストを充実させるの方向性でいい気がする(他ソフトが投稿を編集してるのに反映されないのは結構言われ続けているのもあり)