Skip to content
Extraits de code Groupes Projets
Valider 58acfa17 rédigé par Will Hunt's avatar Will Hunt
Parcourir les fichiers

Update profile on new profile set

parent 57733f51
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -62,7 +62,7 @@ export class MatrixEventProcessor {
private discord: DiscordBot;
private matrixMsgProcessor: MatrixMessageProcessor;
private mxCommandHandler: MatrixCommandHandler;
private mxUserProfileCache: TimedCache<string, {displayname: string, avatar_url: string}>;
private mxUserProfileCache: TimedCache<string, {displayname: string, avatar_url: string|undefined}>;
constructor(opts: MatrixEventProcessorOpts, cm?: MatrixCommandHandler) {
this.config = opts.config;
......@@ -212,6 +212,12 @@ export class MatrixEventProcessor {
const membership = event.content!.membership;
if (membership === "join") {
this.mxUserProfileCache.delete(`${event.room_id}:${event.sender}`);
if (event.content!.displayname) {
this.mxUserProfileCache.set(`${event.room_id}:${event.sender}`, {
avatar_url: event.content!.avatar_url,
displayname: event.content!.displayname!,
});
}
// We don't know if the user also updated their profile, but to be safe..
this.mxUserProfileCache.delete(event.sender);
}
......@@ -368,7 +374,7 @@ export class MatrixEventProcessor {
private async GetUserProfileForRoom(roomId: string, userId: string) {
const mxClient = this.bridge.getClientFactory().getClientAs();
const intent = this.bridge.getIntent();
let profile: {displayname: string, avatar_url: string} | undefined;
let profile: {displayname: string, avatar_url: string|undefined} | undefined;
try {
// First try to pull out the room-specific profile from the cache.
profile = this.mxUserProfileCache.get(`${roomId}:${userId}`);
......@@ -433,7 +439,7 @@ export class MatrixEventProcessor {
private async SetEmbedAuthor(embed: Discord.RichEmbed, sender: string, profile?: {
displayname: string,
avatar_url: string}) {
avatar_url: string|undefined }) {
let displayName = sender;
let avatarUrl;
......
......@@ -23,6 +23,7 @@ export interface IMatrixEventContent {
msgtype?: string;
url?: string;
displayname?: string;
avatar_url?: string;
reason?: string;
"m.relates_to"?: any; // tslint:disable-line no-any
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter