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: AiScriptでリモートサーバーのAPIを叩く関数を追加 #11887

Merged
merged 11 commits into from
Sep 29, 2023

Conversation

FineArchs
Copy link
Contributor

@FineArchs FineArchs commented Sep 24, 2023

What

リモートサーバー用Mk:apiのMk:apiExternalを追加します。

Why

#11886

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

@github-actions github-actions bot added the packages/frontend Client side specific issue/PR label Sep 24, 2023
@codecov
Copy link

codecov bot commented Sep 24, 2023

Codecov Report

Patch coverage: 8.51% and project coverage change: -0.07% ⚠️

Comparison is base (30b2312) 78.82% compared to head (423746e) 78.76%.
Report is 11 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #11887      +/-   ##
===========================================
- Coverage    78.82%   78.76%   -0.07%     
===========================================
  Files          929      928       -1     
  Lines        98646    98623      -23     
  Branches      7852     7849       -3     
===========================================
- Hits         77762    77680      -82     
- Misses       20884    20943      +59     
Files Changed Coverage Δ
packages/frontend/src/scripts/api.ts 13.95% <4.44%> (-4.88%) ⬇️
packages/frontend/src/os.ts 17.61% <100.00%> (ø)

... and 8 files with indirect coverage changes

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

const fullUrl = (host.value.slice(-1) === '/' ? host.value.slice(0, -1) : host.value)
+ '/' + (ep.value.slice(0, 1) === '/' ? ep.value.slice(1) : ep.value);
if (token) utils.assertString(token);
return os.api(fullUrl, utils.valToJs(param), token?.value).then(res => {
Copy link
Member

Choose a reason for hiding this comment

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

token?.value ?? null にしないと自分のトークンがセットされそうな気がする

Copy link
Contributor Author

Choose a reason for hiding this comment

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

修正しました。

@syuilo
Copy link
Member

syuilo commented Sep 24, 2023

os.apiについても他のサーバーのAPIを叩く想定ではなかった気がするからそこから変えた方が安全かも

@FineArchs FineArchs closed this Sep 24, 2023
@FineArchs FineArchs reopened this Sep 24, 2023
@FineArchs
Copy link
Contributor Author

os.apiからos.apiExternalに分けました。

@Sayamame-beans
Copy link
Member

https://github.com/misskey-dev/misskey/pull/11887/files#diff-b05ec85108e30f0df14a119036c103460d0991730b9166985326af8e95641122R67-R68
この部分、hostのURLに/apiを追加する必要があるのではないでしょうか?

@FineArchs
Copy link
Contributor Author

@Sayamame-beans 忘れていました、ありがとうございます。

@Sayamame-beans
Copy link
Member

この部分、token?.valueはtokenが無い時にundefinedを返すので、Mk:apiの実装に揃えるならtoken?.value ?? nullnullにしておいた方が良いのかもしれません…? (tsの仕様には詳しくないので、意味のない変更だったらすみません)

https://github.com/misskey-dev/misskey/pull/11887/files#diff-9b050611610121693721c8b7cbc8edcfd5cd3f8f5fdc613af621367bac0ac91bR55

@FineArchs
Copy link
Contributor Author

この部分、token?.valueはtokenが無い時にundefinedを返すので、Mk:apiの実装に揃えるならtoken?.value ?? nullnullにしておいた方が良いのかもしれません…?

Mk:apiの場合はos.api関数にundefinedを渡すと自分のトークンがセットされるのでnullに変える必要がありますが、
Mk:apiExternalはos.apiの代わりにos.apiExternal関数を使っており、undefinedを渡すと単にトークンがundefinedになるだけなので問題ないです。

@Sayamame-beans
Copy link
Member

なるほど。失礼いたしました…

@FineArchs
Copy link
Contributor Author

/deploy sha=33f651354d8513873a5ff98348339f9ae8ed6a04

@syuilo syuilo merged commit f269841 into misskey-dev:develop Sep 29, 2023
15 checks passed
@syuilo
Copy link
Member

syuilo commented Sep 29, 2023

👍🏻

@FineArchs FineArchs deleted the api-ext branch September 30, 2023 08:45
u1-liquid added a commit to u1-liquid/misskey that referenced this pull request Dec 8, 2023
u1-liquid added a commit to MisskeyIO/misskey that referenced this pull request Dec 8, 2023
* Revert "Feat: AiScriptでリモートサーバーのAPIを叩く関数を追加 (misskey-dev#11887)"

This reverts commit f269841.
n1lsqn pushed a commit to n1lsqn/misskey that referenced this pull request Dec 8, 2023
…skeyIO#281)

* Revert "Feat: AiScriptでリモートサーバーのAPIを叩く関数を追加 (misskey-dev#11887)"

This reverts commit f269841.
n1lsqn added a commit to n1lsqn/misskey that referenced this pull request Jan 4, 2024
Revert "Feat: AiScriptでリモートサーバーのAPIを叩く関数を追加 (misskey-dev#11887)" (MisskeyIO#281)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages/frontend Client side specific issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants