Display user badges
This commit is contained in:
parent
927c22ef73
commit
f647c4e053
95 changed files with 2891 additions and 424 deletions
|
@ -16,6 +16,8 @@ import {
|
|||
import { getSendOptions } from './getSendOptions';
|
||||
import { isMe } from './whatTypeOfConversation';
|
||||
import * as log from '../logging/log';
|
||||
import { getUserLanguages } from './userLanguages';
|
||||
import { parseBadgesFromServer } from '../badges/parseBadgesFromServer';
|
||||
|
||||
export async function getProfile(
|
||||
providedUuid?: string,
|
||||
|
@ -27,6 +29,11 @@ export async function getProfile(
|
|||
);
|
||||
}
|
||||
|
||||
const { updatesUrl } = window.SignalContext.config;
|
||||
if (typeof updatesUrl !== 'string') {
|
||||
throw new Error('getProfile expected updatesUrl to be a defined string');
|
||||
}
|
||||
|
||||
const id = window.ConversationController.ensureContactIds({
|
||||
uuid: providedUuid,
|
||||
e164: providedE164,
|
||||
|
@ -41,6 +48,11 @@ export async function getProfile(
|
|||
window.getServerPublicParams()
|
||||
);
|
||||
|
||||
const userLanguages = getUserLanguages(
|
||||
navigator.languages,
|
||||
window.getLocale()
|
||||
);
|
||||
|
||||
let profile;
|
||||
|
||||
try {
|
||||
|
@ -92,6 +104,7 @@ export async function getProfile(
|
|||
accessKey: getInfo.accessKey,
|
||||
profileKeyVersion: profileKeyVersionHex,
|
||||
profileKeyCredentialRequest: profileKeyCredentialRequestHex,
|
||||
userLanguages,
|
||||
});
|
||||
} catch (error) {
|
||||
if (error.code === 401 || error.code === 403) {
|
||||
|
@ -102,6 +115,7 @@ export async function getProfile(
|
|||
profile = await window.textsecure.messaging.getProfile(identifier, {
|
||||
profileKeyVersion: profileKeyVersionHex,
|
||||
profileKeyCredentialRequest: profileKeyCredentialRequestHex,
|
||||
userLanguages,
|
||||
});
|
||||
} else {
|
||||
throw error;
|
||||
|
@ -111,6 +125,7 @@ export async function getProfile(
|
|||
profile = await window.textsecure.messaging.getProfile(identifier, {
|
||||
profileKeyVersion: profileKeyVersionHex,
|
||||
profileKeyCredentialRequest: profileKeyCredentialRequestHex,
|
||||
userLanguages,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -214,6 +229,24 @@ export async function getProfile(
|
|||
c.unset('capabilities');
|
||||
}
|
||||
|
||||
const badges = parseBadgesFromServer(profile.badges, updatesUrl);
|
||||
if (badges.length) {
|
||||
await window.reduxActions.badges.updateOrCreate(badges);
|
||||
c.set({
|
||||
badges: badges.map(badge => ({
|
||||
id: badge.id,
|
||||
...('expiresAt' in badge
|
||||
? {
|
||||
expiresAt: badge.expiresAt,
|
||||
isVisible: badge.isVisible,
|
||||
}
|
||||
: {}),
|
||||
})),
|
||||
});
|
||||
} else {
|
||||
c.unset('badges');
|
||||
}
|
||||
|
||||
if (profileCredentialRequestContext) {
|
||||
if (profile.credential) {
|
||||
const profileKeyCredential = handleProfileKeyCredential(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue