Add: Misskey v11 streaming method

This commit is contained in:
Cutls 2019-05-08 00:48:59 +09:00
parent 8991cb5a96
commit edbe3c164f
7 changed files with 688 additions and 620 deletions

View File

@ -14,23 +14,6 @@ function ck() {
} }
var domainz = localStorage.getItem("domain_0"); var domainz = localStorage.getItem("domain_0");
var at = localStorage.getItem("acct_0_at"); var at = localStorage.getItem("acct_0_at");
var oldat = localStorage.getItem(domainz + "_at");
if(oldat){
console.log("Move to New Account Management System")
var multi = localStorage.getItem("multi");
if (!multi) {
var acctlen=1;
} else {
var obj = JSON.parse(multi);
var acctlen=obj.length;
}
for(i=0;acctlen>i;i++){
var domain = localStorage.getItem("domain_"+i);
var oldat = localStorage.getItem(domain + "_at");
var newat = localStorage.setItem("acct_"+ i + "_at",oldat);
localStorage.removeItem(domain + "_at");
}
}
//コード受信 //コード受信
if(location.search){ if(location.search){
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/); var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
@ -50,6 +33,11 @@ function ck() {
var acct=obj[key]; var acct=obj[key];
if(acct.domain){ if(acct.domain){
refresh(key,true) refresh(key,true)
var domain = localStorage.getItem("domain_" + key);
if(localStorage.getItem("mode_" + domain)=="misskey"){
localStorage.removeItem("misskey_wss_" + key)
connectMisskey(key)
}
} }
}); });
if (obj[0].domain) { if (obj[0].domain) {

View File

@ -363,8 +363,7 @@ function misskeyLogin(url) {
"reaction-read", "reaction-read",
"reaction-write", "reaction-write",
"vote-read", "vote-read",
"vote-write" "vote-write",
/*
"read:account", "read:account",
"write:account", "write:account",
"read:drive", "read:drive",
@ -385,7 +384,6 @@ function misskeyLogin(url) {
"read:reactions", "read:reactions",
"write:reactions", "write:reactions",
"write:votes" "write:votes"
*/
] ]
})); }));
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ function notfColumn(acct_id, tlid, sys){
if(localStorage.getItem("mode_" + domain)=="misskey"){ if(localStorage.getItem("mode_" + domain)=="misskey"){
var misskey=true; var misskey=true;
var start = "https://" + domain + "/api/i/notifications"; var start = "https://" + domain + "/api/i/notifications";
httpreq.open(POST, start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader('Content-Type', 'application/json');
var body=JSON.stringify({ var body=JSON.stringify({
i:at i:at
@ -44,7 +44,10 @@ function notfColumn(acct_id, tlid, sys){
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1]; var max_id = httpreq.getResponseHeader("link");
if(max_id){
max_id=max_id.match(/[?&]{1}max_id=([0-9]+)/)[1]
}
if(json[0]){ if(json[0]){
var templete=""; var templete="";
var lastnotf=localStorage.getItem("lastnotf_" + acct_id); var lastnotf=localStorage.getItem("lastnotf_" + acct_id);
@ -211,10 +214,6 @@ function notfCommon(acct_id, tlid, sys) {
} }
var start = wss + "/api/v1/streaming/?stream=user&access_token=" + var start = wss + "/api/v1/streaming/?stream=user&access_token=" +
at; at;
}else{
var start = "wss://" + domain + "/?i=" +
at;
}
console.log(start); console.log(start);
var wsid = websocketNotf.length; var wsid = websocketNotf.length;
@ -233,32 +232,6 @@ function notfCommon(acct_id, tlid, sys) {
popup = 0; popup = 0;
} }
console.log(domain) console.log(domain)
if(misskey){
console.log("misskey")
console.log(JSON.parse(mess.data));
if (JSON.parse(mess.data).type == "notification") {
var obj = JSON.parse(mess.data).body;
console.log(obj);
if(obj.type!="follow"){
templete = misskeyParse([obj], 'notf', acct_id, 'notf', popup);
}else{
templete = misskeyUserparse([obj], 'notf', acct_id, 'notf', popup);
}
if(obj.type=="reaction"){
console.log("refresh")
reactRefresh(acct_id,obj.note.id)
}
if(!$("div[data-notfIndv=" + acct_id +"_"+obj.id+"]").length){
$("div[data-notf=" + acct_id +"]").prepend(templete);
$("div[data-const=notf_"+acct_id+"]").prepend(templete);
}
jQuery("time.timeago").timeago();
}else if(JSON.parse(mess.data).type == "note-updated"){
var obj = JSON.parse(mess.data).body.note;
reactRefreshCore(obj)
}
}else{
var obj = JSON.parse(JSON.parse(mess.data).payload); var obj = JSON.parse(JSON.parse(mess.data).payload);
console.log(obj); console.log(obj);
var type = JSON.parse(mess.data).event; var type = JSON.parse(mess.data).event;
@ -280,11 +253,11 @@ function notfCommon(acct_id, tlid, sys) {
$("[toot-id=" + obj + "]").remove(); $("[toot-id=" + obj + "]").remove();
} }
} }
}
websocketNotf[acct_id].onerror = function(error) { websocketNotf[acct_id].onerror = function(error) {
console.error('WebSocket Error ' + error); console.error('WebSocket Error ' + error);
}; };
} }
}
//一定のスクロールで発火 //一定のスクロールで発火
function notfmore(tlid) { function notfmore(tlid) {
console.log(moreloading); console.log(moreloading);

View File

@ -164,33 +164,13 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
localStorage.setItem("now", type); localStorage.setItem("now", type);
if(localStorage.getItem("mode_" + domain)=="misskey"){ if(localStorage.getItem("mode_" + domain)=="misskey"){
var misskey=true; var misskey=true;
console.log(type); var key=localStorage.getItem("misskey_wss_" + acct_id)
if (type == "home") { var send='{"type":"connect","body":{"channel":"'+typePs(type)+'","id":"'+tlid+'"}}'
var start = "wss://" + domain + while(1){
"/?i=" + at; if(misskeywsstate[key]){
} else if (type == "pub") { misskeyws[key].send(send)
var start = "wss://" + domain + break
"/global-timeline?i=" + at; }
} else if (type == "pub-media") {
var start = "wss://" + domain +
"/global-timeline?i=" + at;
} else if (type == "local") {
var start = "wss://" + domain +
"/local-timeline?i=" + at;
} else if (type == "local-media") {
var start = "wss://" + domain +
"/local-timeline?i=" + at;
} else if (type == "mix") {
var start = "wss://" + domain +
"/hybrid-timeline?i=" + at;
} else if (type == "tag") {
Materialize.toast(lang.lang_misskeyparse_tagnostr, 3000);
} else if (type == "noauth") {
var start = "wss://" + acct_id +
"/local-timeline?i=" + at;
} else if (type=="list"){
var start = "wss://" + domain +
"/user-list?i=" + at+"&listId="+data;
} }
}else{ }else{
var misskey=false; var misskey=false;
@ -233,8 +213,6 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
var start = wss + var start = wss +
"/api/v1/streaming/?stream=direct&access_token=" + at; "/api/v1/streaming/?stream=direct&access_token=" + at;
} }
}
console.log(start); console.log(start);
var wsid = websocket.length; var wsid = websocket.length;
localStorage.setItem("wss_" + tlid, wsid); localStorage.setItem("wss_" + tlid, wsid);
@ -351,7 +329,7 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
} }
return false; return false;
}; };
}
} }
//一定のスクロールで発火 //一定のスクロールで発火
@ -710,6 +688,24 @@ function com(type, data) {
return "direct?" return "direct?"
} }
} }
//Misskey
function typePs(type){
if (type == "home") {
return "homeTimeline"
} else if (type == "local" || type == "noauth") {
return "localTimeline"
} else if (type == "local-media") {
return "localTimeline"
} else if (type == "pub") {
return "globalTimeline"
} else if (type == "mix") {
return "hybridTimeline"
} else if (type == "tag") {
return "hashtag"
}else if (type == "list") {
return "userList"
}
}
function misskeycom(type, data) { function misskeycom(type, data) {
if (type == "home") { if (type == "home") {
return "timeline" return "timeline"

View File

@ -180,9 +180,17 @@ function parseColumn() {
if(key===0){ if(key===0){
left_hold=''; left_hold='';
} }
if(localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct.domain))=="misskey"){
var isMisRed=""
exclude=""
var if_misskey_hide="hide"
}else{
var isMisRed="red-text"
var if_misskey_hide=""
}
var html='<div class="boxIn" id="timeline_box_' + key + '_box" tlid="' + key + var html='<div class="boxIn" id="timeline_box_' + key + '_box" tlid="' + key +
'" data-acct="'+acct.domain+'"><div class="notice-box z-depth-2" id="menu_'+key+'" style="'+insert+' ">'+ '" data-acct="'+acct.domain+'"><div class="notice-box z-depth-2" id="menu_'+key+'" style="'+insert+' ">'+
'<div class="area-notice"><i class="material-icons waves-effect red-text" id="notice_icon_' + key + '"'+notf_attr+' style="font-size:40px; padding-top:25%;" onclick="checkStr(\''+acct.type+'\', \''+data+'\', \''+acct.domain+'\', \''+key+'\', \''+delc+'\',\''+voice+'\',null)" title="'+lang.lang_layout_gotop +'"></i></div>'+ '<div class="area-notice"><i class="material-icons waves-effect '+isMisRed+'" id="notice_icon_' + key + '"'+notf_attr+' style="font-size:40px; padding-top:25%;" onclick="checkStr(\''+acct.type+'\', \''+data+'\', \''+acct.domain+'\', \''+key+'\', \''+delc+'\',\''+voice+'\',null)" title="'+lang.lang_layout_gotop +'"></i></div>'+
'<div class="area-notice_name"><span id="notice_' + key + '" class="tl-title"></span></div>'+ '<div class="area-notice_name"><span id="notice_' + key + '" class="tl-title"></span></div>'+
'<div class="area-a1"><a onclick="notfToggle(' + acct.domain + ',' + key + '<div class="area-a1"><a onclick="notfToggle(' + acct.domain + ',' + key +
')" class="setting nex '+if_notf+'" title="'+unique_notf+'"'+icnsert+'><i class="material-icons waves-effect nex notf-icon_' + ')" class="setting nex '+if_notf+'" title="'+unique_notf+'"'+icnsert+'><i class="material-icons waves-effect nex notf-icon_' +
@ -201,7 +209,7 @@ function parseColumn() {
key + '">On</span></a>'+lang.lang_layout_linkana +'<br><a onclick="voiceToggle(' + key + key + '">On</span></a>'+lang.lang_layout_linkana +'<br><a onclick="voiceToggle(' + key +
')" class="setting nex"><i class="material-icons waves-effect nex" title="'+lang.lang_layout_tts +'">hearing</i><span id="sta-voice-' + ')" class="setting nex"><i class="material-icons waves-effect nex" title="'+lang.lang_layout_tts +'">hearing</i><span id="sta-voice-' +
key + '">On</span></a>'+lang.lang_layout_tts +'TL<br><a onclick="reconnector(' + key + key + '">On</span></a>'+lang.lang_layout_tts +'TL<br><a onclick="reconnector(' + key +
',\''+acct.type+'\',\''+acct.domain+'\',\''+escapeHTML(acct.data)+'\')" class="setting nex '+if_notf+'"><i class="material-icons waves-effect nex '+if_notf+'" title="'+lang.lang_layout_reconnect+'">low_priority</i></a><span class="'+if_notf+'">'+lang.lang_layout_reconnect+'</span><br>'+lang.lang_layout_headercolor +'<br><div id="picker_'+key+'" class="color-picker"></div></div><div class="tl-box" tlid="' + key + '"><div id="timeline_' + key + ',\''+acct.type+'\',\''+acct.domain+'\',\''+escapeHTML(acct.data)+'\')" class="setting nex '+if_notf+' '+if_misskey_hide+'"><i class="material-icons waves-effect nex '+if_notf+'" title="'+lang.lang_layout_reconnect+'">low_priority</i></a><span class="'+if_notf+'">'+lang.lang_layout_reconnect+'</span><br>'+lang.lang_layout_headercolor +'<br><div id="picker_'+key+'" class="color-picker"></div></div><div class="tl-box" tlid="' + key + '"><div id="timeline_' + key +
'" class="tl '+acct.type+'-timeline " tlid="' + key + '" data-type="' + acct.type + '" data-acct="'+acct.domain+'" data-const="' + acct.type + '_'+acct.domain+'"><div id="landing_'+key+'" style="text-align:center">'+lang.lang_layout_nodata +'</div></div></div>' '" class="tl '+acct.type+'-timeline " tlid="' + key + '" data-type="' + acct.type + '" data-acct="'+acct.domain+'" data-const="' + acct.type + '_'+acct.domain+'"><div id="landing_'+key+'" style="text-align:center">'+lang.lang_layout_nodata +'</div></div></div>'
$('#timeline_box_' + basekey + '_parentBox').append(html); $('#timeline_box_' + basekey + '_parentBox').append(html);
localStorage.removeItem("pool_" + key); localStorage.removeItem("pool_" + key);

View File

@ -658,15 +658,7 @@
Entyでは支援者様限定で様々なTheDeskに関する記事をご覧いただけます。<br> Entyでは支援者様限定で様々なTheDeskに関する記事をご覧いただけます。<br>
困ったときは、<a href="https://docs.thedesk.top">TheDesk Docs</a>をご覧ください。 困ったときは、<a href="https://docs.thedesk.top">TheDesk Docs</a>をご覧ください。
<h5>Release Note Usamin (18.3.3)</h5> <h5>Release Note Usamin (18.3.3)</h5>
・不具合修正<br> ・caution:読み上げナシMisskey<br>
・blurhashに対応(2.8.1~)<br>
18.3.2<br>
・絵文字の描画修正<br>
・旗系絵文字の入力修正<br>
・このトゥートより後ローカルタイムライン<br>
・このトゥートより後ユーザータイムライン<br>
・このトゥートより後連合タイムライン<br>
・Notestock公開時にリンクを表示<br>
<br> <br>
</div> </div>
<div id="release-en"> <div id="release-en">