Add: Misskey v11 streaming method
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
@@ -279,12 +252,12 @@ function notfCommon(acct_id, tlid, sys) {
|
||||
$("[toot-id=" + obj + "]").hide();
|
||||
$("[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"
|
||||
|
Reference in New Issue
Block a user