Verify friend/unfriends

This commit is contained in:
Natsumi
2022-02-12 19:28:33 +13:00
parent 1b135e1f15
commit 33a8b079ab
+48 -37
View File
@@ -10467,34 +10467,33 @@ speechSynthesis.getVoices();
if (!this.friendLogInitStatus || this.friendLog.has(id)) { if (!this.friendLogInitStatus || this.friendLog.has(id)) {
return; return;
} }
var ctx = {
id,
displayName: null,
trustLevel: null
};
var ref = API.cachedUsers.get(id); var ref = API.cachedUsers.get(id);
if (typeof ref !== 'undefined') { if (typeof ref !== 'undefined') {
ctx.displayName = ref.displayName; API.getFriendStatus({
ctx.trustLevel = ref.$trustLevel; userId: id
var friendLogHistory = { }).then((args) => {
created_at: new Date().toJSON(), if (args.json.isFriend) {
type: 'Friend', var friendLogHistory = {
userId: id, created_at: new Date().toJSON(),
displayName: ctx.displayName type: 'Friend',
}; userId: id,
this.friendLogTable.data.push(friendLogHistory); displayName: ref.displayName
database.addFriendLogHistory(friendLogHistory); };
this.queueFriendLogNoty(friendLogHistory); this.friendLogTable.data.push(friendLogHistory);
var friendLogCurrent = { database.addFriendLogHistory(friendLogHistory);
userId: id, this.queueFriendLogNoty(friendLogHistory);
displayName: ctx.displayName, var friendLogCurrent = {
trustLevel: ctx.trustLevel userId: id,
}; displayName: ref.displayName,
this.friendLog.set(id, friendLogCurrent); trustLevel: ref.$trustLevel
database.setFriendLogCurrent(friendLogCurrent); };
this.notifyMenu('friendLog'); this.friendLog.set(id, friendLogCurrent);
this.deleteFriendRequest(id); database.setFriendLogCurrent(friendLogCurrent);
this.updateSharedFeed(true); this.notifyMenu('friendLog');
this.deleteFriendRequest(id);
this.updateSharedFeed(true);
}
});
} }
}; };
@@ -10516,9 +10515,13 @@ speechSynthesis.getVoices();
if (typeof ctx === 'undefined') { if (typeof ctx === 'undefined') {
return; return;
} }
var friendLogHistory = { API.getFriendStatus({
created_at: new Date().toJSON(), userId: id
type: 'Unfriend', }).then((args) => {
if (!args.json.isFriend) {
var friendLogHistory = {
created_at: new Date().toJSON(),
type: 'Unfriend',
userId: id, userId: id,
displayName: ctx.displayName displayName: ctx.displayName
}; };
@@ -10526,9 +10529,11 @@ speechSynthesis.getVoices();
database.addFriendLogHistory(friendLogHistory); database.addFriendLogHistory(friendLogHistory);
this.queueFriendLogNoty(friendLogHistory); this.queueFriendLogNoty(friendLogHistory);
this.friendLog.delete(id); this.friendLog.delete(id);
database.deleteFriendLogCurrent(id); database.deleteFriendLogCurrent(id);
this.notifyMenu('friendLog'); this.notifyMenu('friendLog');
this.updateSharedFeed(true); this.updateSharedFeed(true);
}
});
}; };
$app.methods.updateFriendships = function (ref) { $app.methods.updateFriendships = function (ref) {
@@ -10553,9 +10558,13 @@ speechSynthesis.getVoices();
return; return;
} }
if (ctx.displayName !== ref.displayName) { if (ctx.displayName !== ref.displayName) {
if (ctx.displayName) { API.getFriendStatus({
var friendLogHistory = { userId: ref.id
created_at: new Date().toJSON(), }).then((args) => {
if (args.json.isFriend) {
if (ctx.displayName) {
var friendLogHistory = {
created_at: new Date().toJSON(),
type: 'DisplayName', type: 'DisplayName',
userId: ref.id, userId: ref.id,
displayName: ref.displayName, displayName: ref.displayName,
@@ -10580,8 +10589,10 @@ speechSynthesis.getVoices();
this.friendLog.set(ref.id, friendLogCurrent); this.friendLog.set(ref.id, friendLogCurrent);
database.setFriendLogCurrent(friendLogCurrent); database.setFriendLogCurrent(friendLogCurrent);
ctx.displayName = ref.displayName; ctx.displayName = ref.displayName;
this.notifyMenu('friendLog'); this.notifyMenu('friendLog');
this.updateSharedFeed(true); this.updateSharedFeed(true);
}
});
} }
if ( if (
ref.$trustLevel && ref.$trustLevel &&