Add: Misskey v11 streaming method
This commit is contained in:
parent
8991cb5a96
commit
edbe3c164f
|
@ -14,23 +14,6 @@ function ck() {
|
|||
}
|
||||
var domainz = localStorage.getItem("domain_0");
|
||||
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){
|
||||
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
|
||||
|
@ -50,6 +33,11 @@ function ck() {
|
|||
var acct=obj[key];
|
||||
if(acct.domain){
|
||||
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) {
|
||||
|
|
|
@ -363,8 +363,7 @@ function misskeyLogin(url) {
|
|||
"reaction-read",
|
||||
"reaction-write",
|
||||
"vote-read",
|
||||
"vote-write"
|
||||
/*
|
||||
"vote-write",
|
||||
"read:account",
|
||||
"write:account",
|
||||
"read:drive",
|
||||
|
@ -385,7 +384,6 @@ function misskeyLogin(url) {
|
|||
"read:reactions",
|
||||
"write:reactions",
|
||||
"write:votes"
|
||||
*/
|
||||
]
|
||||
}));
|
||||
httpreq.onreadystatechange = function() {
|
||||
|
|
|
@ -343,9 +343,13 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
|
|||
var via = '<span style="font-style: italic;">Mobile</span>';
|
||||
} else {
|
||||
var via = '';
|
||||
viashow = "via-hide";
|
||||
}
|
||||
} else {
|
||||
var via = toot.app.name;
|
||||
var via = escapeHTML(toot.app.name);
|
||||
if (!toot.app.name) {
|
||||
viashow = "via-hide";
|
||||
}
|
||||
//強調チェック
|
||||
Object.keys(emp).forEach(function (key6) {
|
||||
var cli = emp[key6];
|
||||
|
@ -514,7 +518,7 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
|
|||
mentions = '<div style="float:right"><a onclick="udg(\'' + menck.user.id + '\',' +
|
||||
acct_id + ')" class="pointer">@' + menck.user.username + '</a></div>';
|
||||
}
|
||||
var tagck = toot.tags[0];
|
||||
var tagck = toot.tags;
|
||||
var tags = "";
|
||||
//タグであれば
|
||||
if (tagck) {
|
||||
|
@ -841,7 +845,7 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
|
|||
acct_id +
|
||||
')" class="waves-effect waves-dark btn-flat" style="padding:0" title="' + lang.lang_parse_redraft + '"><i class="material-icons">redo</i></a></div>' + trans +
|
||||
'<span class="cbadge viabadge waves-effect ' + viashow + ' ' + mine_via + '" onclick="client(\'' + $.strip_tagstemp(via) + '\')" title="via ' + $.strip_tagstemp(via) + '">via ' +
|
||||
escapeHTML(via) +
|
||||
via +
|
||||
'</span>' +
|
||||
'</div><div class="area-side ' + mouseover + '"><div class="action ' + if_mine + ' ' + noauth + '"><a onclick="toggleAction(\'' + toot.id + '\',\'' + tlid + '\',\'' + acct_id + '\')" class="waves-effect waves-dark btn-flat" style="padding:0"><i class="text-darken-3 material-icons act-icon">expand_more</i></a></div>' +
|
||||
'<div class="action ' + noauth + '"><a onclick="details(\'' + toot.id + '\',' + acct_id +
|
||||
|
@ -854,11 +858,14 @@ function misskeyParse(obj, mix, acct_id, tlid, popup, mutefilter) {
|
|||
|
||||
//オブジェクトパーサー(ユーザーデータ)
|
||||
function misskeyUserparse(obj, auth, acct_id, tlid, popup) {
|
||||
console.log(obj)
|
||||
if (popup > 0 || popup == -1) {
|
||||
|
||||
} else {
|
||||
if(obj.users){
|
||||
var obj = obj.users;
|
||||
}
|
||||
}
|
||||
var templete = '';
|
||||
var datetype = localStorage.getItem("datetype");
|
||||
Object.keys(obj).forEach(function (key) {
|
||||
|
@ -952,3 +959,109 @@ function goGoogle(id){
|
|||
|
||||
shell.openExternal(url);
|
||||
}
|
||||
var misskeyws=[]
|
||||
var misskeywsstate=[]
|
||||
function connectMisskey(acct_id) {
|
||||
console.log("C Msky:"+acct_id)
|
||||
|
||||
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem("acct_"+ acct_id + "_at");
|
||||
var start = "wss://" + domain +
|
||||
"/streaming?i="+at;
|
||||
var wsid = misskeyws.length;
|
||||
localStorage.setItem("misskey_wss_" + acct_id, wsid);
|
||||
misskeyws[wsid] = new WebSocket(start);
|
||||
misskeyws[wsid].onopen = function (mess) {
|
||||
console.log(tlid + ":Connect Streaming API:"+domain);
|
||||
console.log(mess);
|
||||
misskeywsstate[wsid]=true
|
||||
//$("#notice_icon_" + tlid).removeClass("red-text");
|
||||
var send='{"type":"connect","body":{"channel":"main","id":"notf:'+acct_id+'"}}'
|
||||
misskeyws[wsid].send(send)
|
||||
}
|
||||
misskeyws[wsid].onmessage = function (mess) {
|
||||
console.log(acct_id + ":Receive Streaming API:");
|
||||
var data=JSON.parse(mess.data)
|
||||
var obj=data.body.body
|
||||
|
||||
if (data.body.id.indexOf("notf:")!== -1) {
|
||||
var obj = JSON.parse(mess.data).body;
|
||||
console.log(obj);
|
||||
var popup = localStorage.getItem("popup");
|
||||
if (!popup) {
|
||||
popup = 0;
|
||||
}
|
||||
if(JSON.parse(mess.data).body.type!="follow"){
|
||||
|
||||
templete = misskeyParse([obj.body], 'notf', acct_id, 'notf', popup);
|
||||
}else{
|
||||
templete = misskeyUserparse([obj.body], 'notf', acct_id, 'notf', popup);
|
||||
}
|
||||
if(JSON.parse(mess.data).body.type=="reaction"){
|
||||
console.log("refresh")
|
||||
reactRefresh(acct_id,obj.body.note.id)
|
||||
}
|
||||
if(!$("div[data-notfIndv=" + acct_id +"_"+obj.body.id+"]").length){
|
||||
$("div[data-notf=" + acct_id +"]").prepend(templete);
|
||||
$("div[data-const=notf_"+acct_id+"]").prepend(templete);
|
||||
}
|
||||
jQuery("time.timeago").timeago();
|
||||
}else if (data.body.type == "note") {
|
||||
var tlid=data.body.id*1
|
||||
var multi = localStorage.getItem("column");
|
||||
var col = JSON.parse(multi)[tlid];
|
||||
if(localStorage.getItem("voice_" + tlid)){
|
||||
var voice=true;
|
||||
}else{
|
||||
var voice=false;
|
||||
}
|
||||
if (voice) {
|
||||
say(obj.text)
|
||||
}
|
||||
var templete = misskeyParse([obj], col.type, acct_id, tlid, "", mute);
|
||||
var pool = localStorage.getItem("pool_" + tlid);
|
||||
if (pool) {
|
||||
pool = templete + pool;
|
||||
} else {
|
||||
pool = templete
|
||||
}
|
||||
localStorage.setItem("pool_" + tlid, pool);
|
||||
scrollck();
|
||||
jQuery("time.timeago").timeago();
|
||||
}
|
||||
}
|
||||
misskeyws[wsid].onerror = function (error) {
|
||||
console.error("Error closing");
|
||||
console.error(error);
|
||||
misskeywsstate[wsid]=false
|
||||
if (mode == "error") {
|
||||
$("#notice_icon_" + tlid).addClass("red-text");
|
||||
todo('WebSocket Error ' + error);
|
||||
} else {
|
||||
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
|
||||
localStorage.setItem("wserror_" + tlid, errorct);
|
||||
if (errorct < 3) {
|
||||
//reconnector(tlid, type, acct_id, data, "error");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
misskeyws[wsid].onclose = function () {
|
||||
console.log("Closing");
|
||||
console.log(tlid);
|
||||
misskeywsstate[wsid]=false
|
||||
if (mode == "error") {
|
||||
$("#notice_icon_" + tlid).addClass("red-text");
|
||||
todo('WebSocket Closed');
|
||||
} else {
|
||||
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
|
||||
localStorage.setItem("wserror_" + tlid, errorct);
|
||||
if (errorct < 3) {
|
||||
//reconnector(tlid, type, acct_id, data, "error");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@ function notfColumn(acct_id, tlid, sys){
|
|||
if(localStorage.getItem("mode_" + domain)=="misskey"){
|
||||
var misskey=true;
|
||||
var start = "https://" + domain + "/api/i/notifications";
|
||||
httpreq.open(POST, start, true);
|
||||
httpreq.open("POST", start, true);
|
||||
httpreq.setRequestHeader('Content-Type', 'application/json');
|
||||
var body=JSON.stringify({
|
||||
i:at
|
||||
|
@ -44,7 +44,10 @@ function notfColumn(acct_id, tlid, sys){
|
|||
httpreq.onreadystatechange = function() {
|
||||
if (httpreq.readyState === 4) {
|
||||
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]){
|
||||
var templete="";
|
||||
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=" +
|
||||
at;
|
||||
}else{
|
||||
var start = "wss://" + domain + "/?i=" +
|
||||
at;
|
||||
}
|
||||
|
||||
console.log(start);
|
||||
var wsid = websocketNotf.length;
|
||||
|
@ -233,32 +232,6 @@ function notfCommon(acct_id, tlid, sys) {
|
|||
popup = 0;
|
||||
}
|
||||
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);
|
||||
console.log(obj);
|
||||
var type = JSON.parse(mess.data).event;
|
||||
|
@ -280,11 +253,11 @@ function notfCommon(acct_id, tlid, sys) {
|
|||
$("[toot-id=" + obj + "]").remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
websocketNotf[acct_id].onerror = function(error) {
|
||||
console.error('WebSocket Error ' + error);
|
||||
};
|
||||
}
|
||||
}
|
||||
//一定のスクロールで発火
|
||||
function notfmore(tlid) {
|
||||
console.log(moreloading);
|
||||
|
|
|
@ -164,33 +164,13 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
|
|||
localStorage.setItem("now", type);
|
||||
if(localStorage.getItem("mode_" + domain)=="misskey"){
|
||||
var misskey=true;
|
||||
console.log(type);
|
||||
if (type == "home") {
|
||||
var start = "wss://" + domain +
|
||||
"/?i=" + at;
|
||||
} else if (type == "pub") {
|
||||
var start = "wss://" + domain +
|
||||
"/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;
|
||||
var key=localStorage.getItem("misskey_wss_" + acct_id)
|
||||
var send='{"type":"connect","body":{"channel":"'+typePs(type)+'","id":"'+tlid+'"}}'
|
||||
while(1){
|
||||
if(misskeywsstate[key]){
|
||||
misskeyws[key].send(send)
|
||||
break
|
||||
}
|
||||
}
|
||||
}else{
|
||||
var misskey=false;
|
||||
|
@ -233,8 +213,6 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
|
|||
var start = wss +
|
||||
"/api/v1/streaming/?stream=direct&access_token=" + at;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(start);
|
||||
var wsid = websocket.length;
|
||||
localStorage.setItem("wss_" + tlid, wsid);
|
||||
|
@ -351,7 +329,7 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
|
|||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//一定のスクロールで発火
|
||||
|
@ -710,6 +688,24 @@ function com(type, data) {
|
|||
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) {
|
||||
if (type == "home") {
|
||||
return "timeline"
|
||||
|
|
|
@ -180,9 +180,17 @@ function parseColumn() {
|
|||
if(key===0){
|
||||
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 +
|
||||
'" 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-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_' +
|
||||
|
@ -201,7 +209,7 @@ function parseColumn() {
|
|||
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-' +
|
||||
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>'
|
||||
$('#timeline_box_' + basekey + '_parentBox').append(html);
|
||||
localStorage.removeItem("pool_" + key);
|
||||
|
|
|
@ -658,15 +658,7 @@
|
|||
Entyでは支援者様限定で様々なTheDeskに関する記事をご覧いただけます。<br>
|
||||
困ったときは、<a href="https://docs.thedesk.top">TheDesk Docs</a>をご覧ください。
|
||||
<h5>Release Note Usamin (18.3.3)</h5>
|
||||
・不具合修正<br>
|
||||
・blurhashに対応(2.8.1~)<br>
|
||||
18.3.2<br>
|
||||
・絵文字の描画修正<br>
|
||||
・旗系絵文字の入力修正<br>
|
||||
・このトゥートより後ローカルタイムライン<br>
|
||||
・このトゥートより後ユーザータイムライン<br>
|
||||
・このトゥートより後連合タイムライン<br>
|
||||
・Notestock公開時にリンクを表示<br>
|
||||
・caution:読み上げナシMisskey<br>
|
||||
<br>
|
||||
</div>
|
||||
<div id="release-en">
|
||||
|
|
Loading…
Reference in New Issue
Block a user