Lobby status change event, fix moderation in player list

This commit is contained in:
Natsumi
2022-02-13 10:30:26 +13:00
parent 33a8b079ab
commit 9349dc3fad
4 changed files with 141 additions and 50 deletions

View File

@@ -5976,17 +5976,16 @@ speechSynthesis.getVoices();
} else { } else {
API.endpointDomain = API.endpointDomainVrchat; API.endpointDomain = API.endpointDomainVrchat;
} }
return new Promise((resolve, reject) => { if (this.enablePrimaryPassword) {
if (this.enablePrimaryPassword) { API.logout();
API.logout(); } else {
} else { API.getConfig()
API.getConfig() .catch((err) => {
.catch((err) => { this.loginForm.loading = false;
this.loginForm.loading = false; throw err;
reject(err); })
}) .then(() => {
.then(() => { API.login({
API.login({
username: loginParmas.username, username: loginParmas.username,
password: loginParmas.password, password: loginParmas.password,
endpoint: loginParmas.endpoint endpoint: loginParmas.endpoint
@@ -5997,10 +5996,9 @@ speechSynthesis.getVoices();
}) })
.then(() => { .then(() => {
this.loginForm.loading = false; this.loginForm.loading = false;
}); });
}); });
} }
});
}; };
$app.methods.deleteSavedLogin = function (username) { $app.methods.deleteSavedLogin = function (username) {
@@ -7599,6 +7597,7 @@ speechSynthesis.getVoices();
this.photonLobbyCurrent = new Map(); this.photonLobbyCurrent = new Map();
this.photonLobbyMaster = 0; this.photonLobbyMaster = 0;
this.photonLobbyCurrentUser = 0; this.photonLobbyCurrentUser = 0;
this.photonLobbyUserData = new Map();
this.photonLobbyInVrMode = new Map(); this.photonLobbyInVrMode = new Map();
this.photonLobbyWatcherLoopStop(); this.photonLobbyWatcherLoopStop();
this.photonLobbyAvatars = new Map(); this.photonLobbyAvatars = new Map();
@@ -8102,6 +8101,7 @@ speechSynthesis.getVoices();
$app.data.photonLobby = new Map(); $app.data.photonLobby = new Map();
$app.data.photonLobbyMaster = 0; $app.data.photonLobbyMaster = 0;
$app.data.photonLobbyCurrentUser = 0; $app.data.photonLobbyCurrentUser = 0;
$app.data.photonLobbyUserData = new Map();
$app.data.photonLobbyInVrMode = new Map(); $app.data.photonLobbyInVrMode = new Map();
$app.data.photonLobbyCurrent = new Map(); $app.data.photonLobbyCurrent = new Map();
$app.data.photonLobbyAvatars = new Map(); $app.data.photonLobbyAvatars = new Map();
@@ -8326,13 +8326,14 @@ speechSynthesis.getVoices();
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId: id, photonId: id,
text, text,
type: 'PhotonBot',
color: 'yellow', color: 'yellow',
created_at: new Date().toJSON() created_at: new Date().toJSON()
}); });
var entry = { var entry = {
created_at: new Date().toJSON(), created_at: new Date().toJSON(),
type: 'Event', type: 'Event',
data: `${text} - ${this.getDisplayNameFromPhotonId( data: `${text} ${this.getDisplayNameFromPhotonId(
id id
)} (${this.getUserIdFromPhotonId(id)})` )} (${this.getUserIdFromPhotonId(id)})`
}; };
@@ -8607,6 +8608,7 @@ speechSynthesis.getVoices();
) { ) {
this.photonModerationUpdate( this.photonModerationUpdate(
ref, ref,
photonId,
block, block,
mute, mute,
gameLogDate gameLogDate
@@ -8617,14 +8619,6 @@ speechSynthesis.getVoices();
mute, mute,
gameLogDate gameLogDate
}); });
if (block || mute) {
this.addEntryPhotonEvent({
photonId,
text: `mute:${mute} block:${block}`,
color: 'yellow',
created_at: gameLogDate
});
}
} }
} else { } else {
var blockArray = data.Parameters[245]['10']; var blockArray = data.Parameters[245]['10'];
@@ -8632,14 +8626,23 @@ speechSynthesis.getVoices();
var idList = new Map(); var idList = new Map();
blockArray.forEach((photonId1) => { blockArray.forEach((photonId1) => {
if (muteArray.includes(photonId1)) { if (muteArray.includes(photonId1)) {
idList.set(photonId1, {mute: true, block: true}); idList.set(photonId1, {
isMute: true,
isBlock: true
});
} else { } else {
idList.set(photonId1, {mute: false, block: true}); idList.set(photonId1, {
isMute: false,
isBlock: true
});
} }
}); });
muteArray.forEach((photonId2) => { muteArray.forEach((photonId2) => {
if (!idList.has(photonId2)) { if (!idList.has(photonId2)) {
idList.set(photonId2, {mute: true, block: false}); idList.set(photonId2, {
isMute: true,
isBlock: false
});
} }
}); });
idList.forEach(({isMute, isBlock}, photonId3) => { idList.forEach(({isMute, isBlock}, photonId3) => {
@@ -8650,6 +8653,7 @@ speechSynthesis.getVoices();
) { ) {
this.photonModerationUpdate( this.photonModerationUpdate(
ref1, ref1,
photonId3,
isBlock, isBlock,
isMute, isMute,
gameLogDate gameLogDate
@@ -8732,6 +8736,7 @@ speechSynthesis.getVoices();
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId: senderId, photonId: senderId,
text: `DeletedPortal ${time}`, text: `DeletedPortal ${time}`,
type: 'DeletedPortal',
created_at: gameLogDate created_at: gameLogDate
}); });
return; return;
@@ -8800,6 +8805,7 @@ speechSynthesis.getVoices();
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId: senderId, photonId: senderId,
text, text,
type: 'Event',
created_at: gameLogDate created_at: gameLogDate
}); });
} else { } else {
@@ -8875,6 +8881,7 @@ speechSynthesis.getVoices();
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId, photonId,
text: `Photon Master Migrate`, text: `Photon Master Migrate`,
type: 'PhotonMasterMigrate',
created_at: gameLogDate created_at: gameLogDate
}); });
} }
@@ -8905,6 +8912,7 @@ speechSynthesis.getVoices();
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId, photonId,
text, text,
type: 'PhotonBot',
color: 'yellow', color: 'yellow',
created_at: gameLogDate created_at: gameLogDate
}); });
@@ -8941,6 +8949,7 @@ speechSynthesis.getVoices();
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId, photonId,
text, text,
type: 'PhotonBot',
color: 'yellow', color: 'yellow',
created_at: gameLogDate created_at: gameLogDate
}); });
@@ -8975,6 +8984,7 @@ speechSynthesis.getVoices();
}; };
this.photonLobby.set(photonId, photonUser); this.photonLobby.set(photonId, photonUser);
this.photonLobbyCurrent.set(photonId, photonUser); this.photonLobbyCurrent.set(photonId, photonUser);
this.photonLobbyUserDataUpdate(photonId, photonUser, gameLogDate);
var bias = Date.parse(gameLogDate) + 60 * 1000; // 1min var bias = Date.parse(gameLogDate) + 60 * 1000; // 1min
if (bias > Date.now()) { if (bias > Date.now()) {
@@ -8987,6 +8997,7 @@ speechSynthesis.getVoices();
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId, photonId,
text: `API/Photon platform mismatch ${ref.last_platform}/${photonUser.last_platform}`, text: `API/Photon platform mismatch ${ref.last_platform}/${photonUser.last_platform}`,
type: 'PhotonBot',
color: 'yellow', color: 'yellow',
created_at: Date.parse(gameLogDate) created_at: Date.parse(gameLogDate)
}); });
@@ -9024,14 +9035,44 @@ speechSynthesis.getVoices();
var {block, mute, gameLogDate} = var {block, mute, gameLogDate} =
this.moderationEventQueue.get(photonId); this.moderationEventQueue.get(photonId);
this.moderationEventQueue.delete(photonId); this.moderationEventQueue.delete(photonId);
this.photonModerationUpdate(ref, block, mute, gameLogDate); this.photonModerationUpdate(
ref,
photonId,
block,
mute,
gameLogDate
);
} }
} }
}; };
$app.methods.photonLobbyUserDataUpdate = function (
photonId,
photonUser,
gameLogDate
) {
var ref = this.photonLobbyUserData.get(photonId);
if (
typeof ref !== 'undefined' &&
(photonUser.status !== ref.status ||
photonUser.statusDescription !== ref.statusDescription)
) {
this.addEntryPhotonEvent({
photonId,
type: 'ChangeStatus',
status: photonUser.status,
previousStatus: ref.status,
statusDescription: photonUser.statusDescription,
previousStatusDescription: ref.statusDescription,
created_at: Date.parse(gameLogDate)
});
}
this.photonLobbyUserData.set(photonId, photonUser);
};
$app.methods.photonUserJoin = function (photonId, ref, gameLogDate) { $app.methods.photonUserJoin = function (photonId, ref, gameLogDate) {
if ( if (
photonId !== this.photonLobbyCurrentUser && photonId === this.photonLobbyCurrentUser ||
!this.photonEventOverlayJoinLeave !this.photonEventOverlayJoinLeave
) { ) {
return; return;
@@ -9039,6 +9080,7 @@ speechSynthesis.getVoices();
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId, photonId,
text: 'has joined', text: 'has joined',
type: 'OnPlayerJoined',
created_at: gameLogDate created_at: gameLogDate
}); });
}; };
@@ -9050,34 +9092,50 @@ speechSynthesis.getVoices();
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId, photonId,
text: 'has left', text: 'has left',
type: 'OnPlayerLeft',
created_at: gameLogDate created_at: gameLogDate
}); });
}; };
$app.methods.photonModerationUpdate = function ( $app.methods.photonModerationUpdate = function (
ref, ref,
photonId,
block, block,
mute, mute,
gameLogDate gameLogDate
) { ) {
database.getModeration(ref.id).then((row) => { database.getModeration(ref.id).then((row) => {
var type = ''; var type = '';
var text = '';
if (block) { if (block) {
type = 'Blocked'; type = 'Blocked';
text = 'Blocked';
} else if (mute) { } else if (mute) {
type = 'Muted'; type = 'Muted';
text = 'Muted';
} }
if (row.userId) { if (row.userId) {
if (!block && row.block) { if (!block && row.block) {
type = 'Unblocked'; type = 'Unblocked';
text = 'Unblocked';
} else if (!mute && row.mute) { } else if (!mute && row.mute) {
type = 'Unmuted'; type = 'Unmuted';
text = 'Unmuted';
} }
if (block === row.block && mute === row.mute) { if (block === row.block && mute === row.mute) {
// no change // no change
type = ''; type = '';
} }
} }
if (text) {
this.addEntryPhotonEvent({
photonId,
text: `Moderation ${text}`,
type: 'Moderation',
color: 'yellow',
created_at: gameLogDate
});
}
if (type) { if (type) {
var noty = { var noty = {
created_at: new Date().toJSON(), created_at: new Date().toJSON(),
@@ -9124,7 +9182,7 @@ speechSynthesis.getVoices();
if ( if (
oldAvatarId && oldAvatarId &&
oldAvatarId !== avatar.id && oldAvatarId !== avatar.id &&
user.id !== API.currentUser.id photonId !== this.photonLobbyCurrentUser
) { ) {
this.checkVRChatCache(avatar).then((cacheInfo) => { this.checkVRChatCache(avatar).then((cacheInfo) => {
var inCache = false; var inCache = false;
@@ -9151,6 +9209,7 @@ speechSynthesis.getVoices();
displayName: user.displayName, displayName: user.displayName,
userId: user.id, userId: user.id,
text: `ChangeAvatar ${avatar.name}`, text: `ChangeAvatar ${avatar.name}`,
type: 'AvatarChange',
created_at: gameLogDate, created_at: gameLogDate,
avatar, avatar,
inCache inCache
@@ -18757,6 +18816,15 @@ speechSynthesis.getVoices();
$app.methods.parseOperationResponse = function (data, dateTime) { $app.methods.parseOperationResponse = function (data, dateTime) {
switch (data.OperationCode) { switch (data.OperationCode) {
case 226: case 226:
if (
typeof data.Parameters[248] !== 'undefined' &&
typeof data.Parameters[248][248] !== 'undefined'
) {
this.setPhotonLobbyMaster(data.Parameters[248][248]);
}
if (typeof data.Parameters[254] !== 'undefined') {
this.photonLobbyCurrentUser = data.Parameters[254];
}
if (typeof data.Parameters[249] !== 'undefined') { if (typeof data.Parameters[249] !== 'undefined') {
for (var i in data.Parameters[249]) { for (var i in data.Parameters[249]) {
var id = parseInt(i, 10); var id = parseInt(i, 10);
@@ -18784,15 +18852,6 @@ speechSynthesis.getVoices();
if (typeof data.Parameters[252] !== 'undefined') { if (typeof data.Parameters[252] !== 'undefined') {
this.parsePhotonLobbyIds(data.Parameters[252]); this.parsePhotonLobbyIds(data.Parameters[252]);
} }
if (
typeof data.Parameters[248] !== 'undefined' &&
typeof data.Parameters[248][248] !== 'undefined'
) {
this.setPhotonLobbyMaster(data.Parameters[248][248]);
}
if (typeof data.Parameters[254] !== 'undefined') {
this.photonLobbyCurrentUser = data.Parameters[254];
}
break; break;
} }
}; };

View File

@@ -200,7 +200,7 @@ html
span.x-link(v-text="scope.row.displayName" @click="showUserFromPhotonId(scope.row.photonId)" style="padding-right:10px") span.x-link(v-text="scope.row.displayName" @click="showUserFromPhotonId(scope.row.photonId)" style="padding-right:10px")
el-table-column(label="Event" prop="text") el-table-column(label="Event" prop="text")
template(v-once #default="scope") template(v-once #default="scope")
span(v-if="scope.row.avatar") span(v-if="scope.row.type === 'AvatarChange'")
span ChangeAvatar span ChangeAvatar
span.x-link(v-text="scope.row.avatar.name" @click="showAvatarDialog(scope.row.avatar.id)") span.x-link(v-text="scope.row.avatar.name" @click="showAvatarDialog(scope.row.avatar.id)")
|   |  
@@ -208,6 +208,29 @@ html
span.avatar-info-own(v-else-if="scope.row.avatar.releaseStatus === 'private'") (Private) span.avatar-info-own(v-else-if="scope.row.avatar.releaseStatus === 'private'") (Private)
template(v-if="scope.row.avatar.description && scope.row.avatar.name !== scope.row.avatar.description") template(v-if="scope.row.avatar.description && scope.row.avatar.name !== scope.row.avatar.description")
| - {{ scope.row.avatar.description }} | - {{ scope.row.avatar.description }}
template(v-else-if="scope.row.type === 'ChangeStatus'")
span ChangeStatus
template(v-if="scope.row.status !== scope.row.previousStatus")
el-tooltip(placement="top")
template(#content)
span(v-if="scope.row.previousStatus === 'active'") Active
span(v-else-if="scope.row.previousStatus === 'join me'") Join Me
span(v-else-if="scope.row.previousStatus === 'ask me'") Ask Me
span(v-else-if="scope.row.previousStatus === 'busy'") Do Not Disturb
span(v-else) Offline
i.x-user-status(:class="statusClass(scope.row.previousStatus)" style="margin-left:10px")
span
i.el-icon-right
el-tooltip(placement="top")
template(#content)
span(v-if="scope.row.status === 'active'") Active
span(v-else-if="scope.row.status === 'join me'") Join Me
span(v-else-if="scope.row.status === 'ask me'") Ask Me
span(v-else-if="scope.row.status === 'busy'") Do Not Disturb
span(v-else) Offline
i.x-user-status(:class="statusClass(scope.row.status)")
span(v-if="scope.row.statusDescription !== scope.row.previousStatusDescription" v-text="scope.row.statusDescription" style="margin-left:10px")
span(v-else-if="scope.row.color === 'yellow'" v-text="scope.row.text" style="color:yellow")
span(v-else v-text="scope.row.text") span(v-else v-text="scope.row.text")
el-tab-pane(label="Previous") el-tab-pane(label="Previous")
data-tables(v-bind="photonEventTablePrevious" style="margin-bottom:10px") data-tables(v-bind="photonEventTablePrevious" style="margin-bottom:10px")

View File

@@ -573,22 +573,21 @@ Vue.component('marquee-text', MarqueeText);
}; };
$app.methods.addEntryHudFeed = function (json) { $app.methods.addEntryHudFeed = function (json) {
var {displayName, text, color, avatar, inCache} = JSON.parse(json); var data = JSON.parse(json);
var combo = 1; var combo = 1;
this.hudFeed.forEach((item) => { this.hudFeed.forEach((item) => {
if (item.displayName === displayName && item.text === text) { if (
item.displayName === data.displayName &&
item.text === data.text
) {
combo = item.combo + 1; combo = item.combo + 1;
removeFromArray(this.hudFeed, item); removeFromArray(this.hudFeed, item);
} }
}); });
this.hudFeed.unshift({ this.hudFeed.unshift({
time: Date.now(), time: Date.now(),
displayName,
text,
combo, combo,
color, ...data
avatar,
inCache
}); });
this.cleanHudFeed(); this.cleanHudFeed();
}; };

View File

@@ -428,12 +428,22 @@ html
.hud-feed .hud-feed
div(v-for="feed in hudFeed") div(v-for="feed in hudFeed")
.item #[span(v-if="feed.isMaster") 👑]<strong>{{ feed.displayName }}</strong> .item #[span(v-if="feed.isMaster") 👑]<strong>{{ feed.displayName }}</strong>
span(v-if="feed.avatar") span(v-if="feed.type === 'AvatarChange'")
span(style="margin-left:10px") ChangeAvatar span(style="margin-left:10px") ChangeAvatar
span(v-if="!feed.inCache" style="color:#aaa;margin-left:10px") #[i.el-icon-download] span(v-if="!feed.inCache" style="color:#aaa;margin-left:10px") #[i.el-icon-download]
span(v-text="feed.avatar.name" style="margin-left:10px") span(v-text="feed.avatar.name" style="margin-left:10px")
span(v-else-if="feed.color === 'yellow'" style="color:yellow;margin-left:10px") {{ feed.text }} span(v-if="feed.avatar.releaseStatus === 'public'" style="margin-left:10px;color:#67c23a") (Public)
span(v-else style="margin-left:10px") {{ feed.text }} span(v-else-if="feed.avatar.releaseStatus === 'private'" style="margin-left:10px;color:#e6a23c") (Private)
template(v-else-if="feed.type === 'ChangeStatus'")
span(style="margin-left:10px") ChangeStatus
template(v-if="feed.status !== feed.previousStatus")
i.x-user-status(:class="statusClass(feed.previousStatus)" style="margin-left:10px;width:20px;height:20px")
span
i.el-icon-right
i.x-user-status(:class="statusClass(feed.status)" style="width:20px;height:20px")
span(v-if="feed.statusDescription !== feed.previousStatusDescription" v-text="feed.statusDescription" style="margin-left:10px")
span(v-else-if="feed.color === 'yellow'" v-text="feed.text" style="color:yellow;margin-left:10px")
span(v-else style="margin-left:10px" v-text="feed.text")
template(v-if="feed.combo > 1") template(v-if="feed.combo > 1")
span.combo(style="margin-left:10px") x{{ feed.combo }} span.combo(style="margin-left:10px") x{{ feed.combo }}
.hud-timeout(v-if="hudTimeout.length > 0") .hud-timeout(v-if="hudTimeout.length > 0")