Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_onUserQuery(matrixUser) {
// Avatar and name will eventually make it back to us from the profile service.
var handle = matrixUser.localpart.substring('_instagram_'.length); // no dashes in uuid
ProfileService.queueProfileCheck(handle);
return Promise.resolve({
remote: new RemoteUser(matrixUser.localpart)
});
}
}
return this.getThirdPartyUserDataById(thirdPartyUserId).then(thirdPartyUserData => {
info("got 3p user data:", thirdPartyUserData);
return new RemoteUser(thirdPartyUserId, {
senderName: thirdPartyUserData.senderName
});
}).then(rUser => {
return userStore.setRemoteUser(rUser);
return this.adapter.getUserData(b2a(thirdPartyUserId)).then(thirdPartyUserData => {
info("got 3p user data:", thirdPartyUserData);
return new RemoteUser(thirdPartyUserId, thirdPartyUserData);
}).then(rUser => {
return userStore.setRemoteUser(rUser);
return util.uploadContentFromUrl(bridge, twitter_user.profile_image_url_https, queriedUser.getId()).then((uri) => {
return {
name: twitter_user.name + " (@" + twitter_user.screen_name + ")",
url: uri,
remote: new RemoteUser(twitter_user.id_str)
};
});
}).catch((error) => {
private async _storeUser(userId: string, protocol: PurpleProtocol,
username: string, type: MUSER_TYPES, extraData: any = {})
: Promise<{remote: BifrostRemoteUser, matrix: MatrixUser}> {
const id = Util.createRemoteId(protocol.id, username);
const mxUser = (await this.userStore.getMatrixUser(userId)) || new MatrixUser(userId);
const existing = await this.userStore.getRemoteUser(id);
if (!existing) {
const remoteUser = new RemoteUser(Util.createRemoteId(protocol.id, username), extraData);
remoteUser.set("protocol_id", protocol.id);
remoteUser.set("username", username);
remoteUser.set("type", type);
await this.userStore.linkUsers(mxUser, remoteUser);
log.info(`Linked new ${type} ${userId} -> ${id}`);
return {remote: new BifrostRemoteUser(
remoteUser, userId, this.asBot.isRemoteUser(userId),
), matrix: mxUser};
} else {
const linkedMatrixUsers = await this.userStore.getMatrixLinks(id);
if (!linkedMatrixUsers.includes(mxUser.getId())) {
log.warn(`${id} was not correctly linked to ${mxUser.getId()}, resolving`);
await this.userStore.linkUsers(mxUser, existing);
}
for (const lnkUserId of linkedMatrixUsers) {
if (lnkUserId === mxUser.getId()) {