Skip to content

Commit

Permalink
v1.53.3 Misskey APIで認証に成功後は、次回の認証をスキップする機能を改良。別サーバ選択時は認証をクリア。
Browse files Browse the repository at this point in the history
  • Loading branch information
satopian committed Oct 2, 2024
1 parent f92c39d commit 386aaf8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
5 changes: 3 additions & 2 deletions petitnote/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,15 +529,16 @@
["misskey.io","https://misskey.io"],
["misskey.design","https://misskey.design"],
["nijimiss.moe","https://nijimiss.moe"],
["sushi.ski","https://sushi.ski"],
["misskey.art","https://misskey.art"],
["oekakiskey.com","https://oekakiskey.com"],
["misskey.gamelore.fun","https://misskey.gamelore.fun"],
["novelskey.tarbin.net","https://novelskey.tarbin.net"],
["tyazzkey.work","https://tyazzkey.work"],
["sushi.ski","https://sushi.ski"],
["misskey.delmulin.com","https://misskey.delmulin.com"],
["side.misskey.productions","https://side.misskey.productions"],

["mk.shrimpia.network","https://mk.shrimpia.network"],

];

//通常は変更しません
Expand Down
4 changes: 2 additions & 2 deletions petitnote/index.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
//Petit Note (c)さとぴあ @satopian 2021-2024
//1スレッド1ログファイル形式のスレッド式画像掲示板
$petit_ver='v1.53.2';
$petit_lot='lot.20240930';
$petit_ver='v1.53.3';
$petit_lot='lot.20241002';
$lang = ($http_langs = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : '')
? explode( ',', $http_langs )[0] : '';
$en= (stripos($lang,'ja')!==0);
Expand Down
19 changes: 15 additions & 4 deletions petitnote/misskey_note.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//Petit Note 2021-2023 (c)satopian MIT LICENCE
//https://paintbbs.sakura.ne.jp/
//APIを使ってお絵かき掲示板からMisskeyにノート
$misskey_note_ver=20240510;
$misskey_note_ver=20241002;

class misskey_note{

Expand Down Expand Up @@ -196,13 +196,16 @@ public static function create_misskey_note_sessiondata(){
["misskey.io","https://misskey.io"],
["misskey.design","https://misskey.design"],
["nijimiss.moe","https://nijimiss.moe"],
["sushi.ski","https://sushi.ski"],
["misskey.art","https://misskey.art"],
["oekakiskey.com","https://oekakiskey.com"],
["misskey.gamelore.fun","https://misskey.gamelore.fun"],
["novelskey.tarbin.net","https://novelskey.tarbin.net"],
["tyazzkey.work","https://tyazzkey.work"],
["sushi.ski","https://sushi.ski"],
["misskey.delmulin.com","https://misskey.delmulin.com"],

["side.misskey.productions","https://side.misskey.productions"],
["mk.shrimpia.network","https://mk.shrimpia.network"],

];
$misskey_servers[]=[($en?"Direct input":"直接入力"),"direct"];//直接入力の箇所はそのまま。

Expand Down Expand Up @@ -244,10 +247,17 @@ public static function create_misskey_authrequesturl(){
$sns_api_session_id=hash('sha256', $sns_api_session_id);

$_SESSION['sns_api_session_id']=$sns_api_session_id;
$_SESSION['misskey_server_radio']=$misskey_server_radio;

$encoded_root_url = urlencode($root_url);

//別のサーバを選択した時はトークンをクリア
if(!isset($_SESSION['misskey_server_radio']) ||
$_SESSION['misskey_server_radio']!==$misskey_server_radio){
unset($_SESSION['accessToken']);//トークンをクリア
}
//投稿完了画面に表示するサーバのURl
$_SESSION['misskey_server_radio']=$misskey_server_radio;

if(isset($_SESSION['accessToken'])){

// ダミーの投稿を試みる(textフィールドを空にする)
Expand All @@ -270,6 +280,7 @@ public static function create_misskey_authrequesturl(){
// HTTPステータスコードが403の時は、トークン不一致と判断しアプリを認証
if ($postStatusCode === 403) {
$Location = "{$misskey_server_radio}/miauth/{$sns_api_session_id}?name=Petit%20Note&callback={$encoded_root_url}connect_misskey_api.php&permission=write:notes,write:drive";
unset($_SESSION['accessToken']);//トークンをクリア
} else {
$Location = "{$root_url}connect_misskey_api.php?noauth=on&s_id={$sns_api_session_id}";
}
Expand Down

0 comments on commit 386aaf8

Please sign in to comment.