fix: enhance muc settings api

This commit is contained in:
2022-09-09 07:56:34 +02:00
parent ba12f3d0e3
commit b5ecee7d32
+23 -3
View File
@@ -50,16 +50,34 @@ function setMucData(actor, muc, data) {
if (dres.rows[0].config.publicroom) {
publicroom = "1";
}
if (!!data.hidden) {
publicroom = "0";
} else {
publicroom = "1";
}
let membersonly = "0";
if (dres.rows[0].config.members_only) {
membersonly = "1";
}
if (!!data.members_only) {
membersonly = "1";
}
if (data.members_only === false) {
membersonly = "0";
}
let roomname = "";
if (dres.rows[0].config.roomname) {
roomname = dres.rows[0].config.roomname;
}
let moderatedroom = "0";
let membersonly = "0";
let whois = "";
let whois = "anyone";
if (dres.rows[0].config.whois) {
whois = dres.rows[0].config.whois;
}
if (!!data.whois && ((data.whois === "anyone") || (data.whois === "moderators"))) {
whois = data.whois;
}
let historylength = 5;
if (dres.rows[0].config.historylength) {
historylength = dres.rows[0].config.historylength;
@@ -85,7 +103,7 @@ function setMucData(actor, muc, data) {
messageStanza += "<field var=\"muc#roomconfig_publicroom\"><value>" + publicroom + "</value></field>";
messageStanza += "<field var=\"muc#roomconfig_roomname\"><value>" + roomname + "</value></field>";
messageStanza += "<field var=\"muc#roomconfig_moderatedroom\"><value>0</value></field>";
messageStanza += "<field var=\"muc#roomconfig_membersonly\"><value>0</value></field>";
messageStanza += "<field var=\"muc#roomconfig_membersonly\"><value>" + membersonly + "</value></field>";
messageStanza += "<field var=\"muc#roomconfig_whois\"><value>" + whois + "</value></field>";
messageStanza += "<field var=\"muc#roomconfig_historylength\"><value>" + historylength.toString() + "</value></field>";
messageStanza += "<field var=\"muc#roomconfig_e2e\"><value>" + e2e + "</value></field>";
@@ -181,7 +199,9 @@ router.get('/groupchats/:target', async function (req, res) {
var queryparams = [];
queryparams[0] = target.split("@")[0];
queryparams[1] = target.split("@")[1];
var sqlquery="select value, created, updated from prosody INNER JOIN group_owners ON split_part(group_owners.room, '@', 1) = prosody.user AND split_part(group_owners.room, '@', 2) = prosody.host where prosody.store='config' and prosody.key='_data' and prosody.user=$1 and prosody.host=$2";
var sqlquery="select value, created, updated from prosody INNER JOIN group_owners ON split_part(group_owners.room, '@', 1) = ";
sqlquery += "prosody.user AND split_part(group_owners.room, '@', 2) = prosody.host where prosody.store='config' and ";
sqlquery += "prosody.key='_data' and prosody.user=$1 and prosody.host=$2";
dbpool.query(sqlquery, queryparams, function (derr, dres) {
if (derr == null) {
if (dres.rowCount > 0) {