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: 特定ユーザーからのリアクションをブロックする機能の追加 #14986

Closed
wants to merge 1 commit into from

Conversation

sakuhanight
Copy link

  • BlockingReactionUserエンティティの追加
  • blocking-reaction-userエンドポイントの追加
  • 関連するフロントエンドの追加
    Migrationがあります。

What

特定ユーザーからのリアクションをブロックする

Why

脈絡がなかったりよくわからん絵文字でリアクションをする人からリアクションを受け取りたくないが、ブロックまではする必要がないことがある。

Additional info (optional)

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

- BlockingReactionUserエンティティの追加
- blocking-reaction-userエンドポイントの追加
- 関連するフロントエンドの追加
Migrationがあります。
@github-actions github-actions bot added packages/frontend Client side specific issue/PR packages/backend Server side specific issue/PR packages/misskey-js labels Nov 17, 2024
Copy link

codecov bot commented Nov 17, 2024

Codecov Report

Attention: Patch coverage is 64.90251% with 252 lines in your changes missing coverage. Please review.

Project coverage is 40.73%. Comparing base (eed45c7) to head (51bc83c).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...es/backend/src/core/BlockingReactionUserService.ts 53.63% 51 Missing ⚠️
...ackages/frontend/src/pages/settings/mute-block.vue 0.00% 48 Missing ⚠️
...ver/api/endpoints/blocking-reaction-user/delete.ts 58.55% 46 Missing ⚠️
...ver/api/endpoints/blocking-reaction-user/create.ts 59.09% 45 Missing ⚠️
...core/entities/BlockingReactionUserEntityService.ts 53.44% 27 Missing ⚠️
...erver/api/endpoints/blocking-reaction-user/list.ts 68.85% 19 Missing ⚠️
packages/frontend/src/scripts/get-user-menu.ts 0.00% 14 Missing ⚠️
packages/backend/src/core/ReactionService.ts 50.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #14986      +/-   ##
===========================================
+ Coverage    39.97%   40.73%   +0.76%     
===========================================
  Files         1561     1571      +10     
  Lines       197256   203748    +6492     
  Branches      3607     3350     -257     
===========================================
+ Hits         78849    82997    +4148     
- Misses      117835   120179    +2344     
  Partials       572      572              

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

@samunohito samunohito linked an issue Nov 17, 2024 that may be closed by this pull request
1 task
Copy link
Contributor

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

差分はこちら
--- base
+++ head
@@ -20952,6 +20952,580 @@
         }
       }
     },
+    "/blocking-reaction-user/create": {
+      "post": {
+        "operationId": "blocking-reaction-user___create",
+        "summary": "blocking-reaction-user/create",
+        "description": "No description provided.\n\n**Credential required**: *Yes* / **Permission**: *write:blocks*",
+        "externalDocs": {
+          "description": "Source code",
+          "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/blocking-reaction-user/create.ts"
+        },
+        "tags": [
+          "account"
+        ],
+        "security": [
+          {
+            "bearerAuth": []
+          }
+        ],
+        "requestBody": {
+          "required": true,
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "properties": {
+                  "userId": {
+                    "type": "string",
+                    "format": "misskey:id"
+                  }
+                },
+                "required": [
+                  "userId"
+                ]
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "OK (with results)",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "$ref": "#/components/schemas/UserDetailedNotMe"
+                }
+              }
+            }
+          },
+          "400": {
+            "description": "Client error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "NO_SUCH_USER": {
+                    "value": {
+                      "error": {
+                        "message": "No such user.",
+                        "code": "NO_SUCH_USER",
+                        "id": "7cc4f851-e2f1-4621-9633-ec9e1d00c01e"
+                      }
+                    }
+                  },
+                  "BLOCKEE_IS_YOURSELF": {
+                    "value": {
+                      "error": {
+                        "message": "Blockee is yourself.",
+                        "code": "BLOCKEE_IS_YOURSELF",
+                        "id": "88b19138-f28d-42c0-8499-6a31bbd0fdc6"
+                      }
+                    }
+                  },
+                  "ALREADY_BLOCKING": {
+                    "value": {
+                      "error": {
+                        "message": "You are already blocking that user.",
+                        "code": "ALREADY_BLOCKING",
+                        "id": "787fed64-acb9-464a-82eb-afbd745b9614"
+                      }
+                    }
+                  },
+                  "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"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/blocking-reaction-user/delete": {
+      "post": {
+        "operationId": "blocking-reaction-user___delete",
+        "summary": "blocking-reaction-user/delete",
+        "description": "No description provided.\n\n**Credential required**: *Yes* / **Permission**: *write:blocks*",
+        "externalDocs": {
+          "description": "Source code",
+          "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/blocking-reaction-user/delete.ts"
+        },
+        "tags": [
+          "account"
+        ],
+        "security": [
+          {
+            "bearerAuth": []
+          }
+        ],
+        "requestBody": {
+          "required": true,
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "properties": {
+                  "userId": {
+                    "type": "string",
+                    "format": "misskey:id"
+                  }
+                },
+                "required": [
+                  "userId"
+                ]
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "OK (with results)",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "object",
+                  "$ref": "#/components/schemas/UserDetailedNotMe"
+                }
+              }
+            }
+          },
+          "400": {
+            "description": "Client error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "NO_SUCH_USER": {
+                    "value": {
+                      "error": {
+                        "message": "No such user.",
+                        "code": "NO_SUCH_USER",
+                        "id": "8621d8bf-c358-4303-a066-5ea78610eb3f"
+                      }
+                    }
+                  },
+                  "BLOCKEE_IS_YOURSELF": {
+                    "value": {
+                      "error": {
+                        "message": "Blockee is yourself.",
+                        "code": "BLOCKEE_IS_YOURSELF",
+                        "id": "06f6fac6-524b-473c-a354-e97a40ae6eac"
+                      }
+                    }
+                  },
+                  "NOT_BLOCKING": {
+                    "value": {
+                      "error": {
+                        "message": "You are not blocking that user.",
+                        "code": "NOT_BLOCKING",
+                        "id": "291b2efa-60c6-45c0-9f6a-045c8f9b02cd"
+                      }
+                    }
+                  },
+                  "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"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    },
+    "/blocking-reaction-user/list": {
+      "post": {
+        "operationId": "blocking-reaction-user___list",
+        "summary": "blocking-reaction-user/list",
+        "description": "No description provided.\n\n**Credential required**: *Yes* / **Permission**: *read:blocks*",
+        "externalDocs": {
+          "description": "Source code",
+          "url": "https://github.com/misskey-dev/misskey/blob/develop/packages/backend/src/server/api/endpoints/blocking-reaction-user/list.ts"
+        },
+        "tags": [
+          "account"
+        ],
+        "security": [
+          {
+            "bearerAuth": []
+          }
+        ],
+        "requestBody": {
+          "required": true,
+          "content": {
+            "application/json": {
+              "schema": {
+                "type": "object",
+                "properties": {
+                  "limit": {
+                    "type": "integer",
+                    "minimum": 1,
+                    "maximum": 100,
+                    "default": 30
+                  },
+                  "sinceId": {
+                    "type": "string",
+                    "format": "misskey:id"
+                  },
+                  "untilId": {
+                    "type": "string",
+                    "format": "misskey:id"
+                  }
+                }
+              }
+            }
+          }
+        },
+        "responses": {
+          "200": {
+            "description": "OK (with results)",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "type": "array",
+                  "items": {
+                    "type": "object",
+                    "$ref": "#/components/schemas/Blocking"
+                  }
+                }
+              }
+            }
+          },
+          "400": {
+            "description": "Client error",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/Error"
+                },
+                "examples": {
+                  "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"
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      }
+    },
     "/channels/create": {
       "post": {
         "operationId": "channels___create",

Get diff files from Workflow Page

Copy link
Contributor

Thank you for sending us a great Pull Request! 👍
Please regenerate misskey-js type definitions! 🙏

example:

pnpm run build-misskey-js-with-types

Copy link
Contributor

@kakkokari-gtyih kakkokari-gtyih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ja-JP以外の翻訳ファイルはCrowdin以外から編集すると不整合が起きるため、ja-JP以外の翻訳の変更はすべて取り消してください
  • lint / code styleの修正を行ってください(見つけた分だけ下に足れ下げておきます)
  • ユーザーエンティティ関連のbackend testのスキーマが変更に追従していません。適切に修正してください
  • BlockingReactionUserのjson schema(/src/models/json-schema内)が定義されていないにもかかわらずPacked<'BlockingReactionUser'>が使用されています。スキーマを作成して適切にインポートしたうえで使用するようにしてください
  • ↑をやったうえでpnpm build-misskey-js-with-types を再度実行してください(misskey-jsのautogen配下は自動生成なので手動で変更しないでください)

@@ -82,6 +82,7 @@ import { MiReversiGame } from '@/models/ReversiGame.js';
import { Config } from '@/config.js';
import MisskeyLogger from '@/logger.js';
import { bindThis } from '@/decorators.js';
import {MiBlockingReactionUser} from "@/models/_.js";
Copy link
Contributor

@kakkokari-gtyih kakkokari-gtyih Nov 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import {MiBlockingReactionUser} from "@/models/_.js";
import { MiBlockingReactionUser } from '@/models/_.js';

lint / code style

import { DI } from '@/di-symbols.js';
import { GetterService } from '@/server/api/GetterService.js';
import { ApiError } from '../../error.js';
import {BlockingReactionUserService} from "@/core/BlockingReactionUserService.js";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import {BlockingReactionUserService} from "@/core/BlockingReactionUserService.js";
import { BlockingReactionUserService } from '@/core/BlockingReactionUserService.js';

lint / code style

import { UserWebhookService } from '@/core/UserWebhookService.js';
import { bindThis } from '@/decorators.js';
import { CacheService } from '@/core/CacheService.js';
import {MiBlockingReactionUser} from "@/models/_.js";
Copy link
Contributor

@kakkokari-gtyih kakkokari-gtyih Nov 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import {MiBlockingReactionUser} from "@/models/_.js";
import type { MiBlockingReactionUser } from '@/models/_.js';

lint / code style

blockerId: blocker.id,
blockee,
blockeeId: blockee.id,
} as MiBlockingReactionUser;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} as MiBlockingReactionUser;
} satisfies MiBlockingReactionUser;

import type { MiUser } from '@/models/User.js';
import { bindThis } from '@/decorators.js';
import { IdService } from '@/core/IdService.js';
import { MiBlockingReactionUser } from '@/models/BlockingReactionUser.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { MiBlockingReactionUser } from '@/models/BlockingReactionUser.js';
import type { MiBlockingReactionUser } from '@/models/BlockingReactionUser.js';

import ms from 'ms';
import { Inject, Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import type {UsersRepository, BlockingsRepository, BlockingReactionUsersRepository} from '@/models/_.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import type {UsersRepository, BlockingsRepository, BlockingReactionUsersRepository} from '@/models/_.js';
import type { UsersRepository, BlockingsRepository, BlockingReactionUsersRepository } from '@/models/_.js';

lint

@syuilo
Copy link
Member

syuilo commented Nov 17, 2024

新しいテーブルを作るより、既存のBlockingテーブルにカラムを追加する方がシンプルになりそうな気がしました

Comment on lines +90 to +93
// Since we already have the blocker and blockee, we do not need to fetch
// them in the query above and can just manually insert them here.
blocking.blocker = blocker;
blocking.blockee = blockee;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上記の処理は不要に見受けられるのですが、いかがでしょうか。
これ以降、blockingはidしか使われていないようです。

@sakuhanight
Copy link
Author

新しいテーブルを作るより、既存のBlockingテーブルにカラムを追加する方がシンプルになりそうな気がしました

既存箇所の変更を嫌ってテーブルを作成しましたが、たしかにカラム追加のほうがシンプルになる気がします。
カラム追加での変更を作成、指摘頂いた箇所を修正し、改めてPR出させてもらおうと思います。
レビューありがとうございました。

@sakuhanight sakuhanight deleted the misskey-dev branch November 18, 2024 06:50
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/frontend Client side specific issue/PR packages/misskey-js
Projects
None yet
Development

Successfully merging this pull request may close these issues.

リアクションブロック機能
4 participants