SHA256
Добавить состояние чтения каналов
This commit is contained in:
@@ -1595,13 +1595,13 @@ export class AuthService {
|
||||
return response.payload || {};
|
||||
}
|
||||
|
||||
async getMessageLikes(message, limit = 1000) {
|
||||
async getMessageLikes(message) {
|
||||
const normalizedMessage = {
|
||||
blockchainName: String(message?.blockchainName || '').trim(),
|
||||
blockNumber: Number(message?.blockNumber),
|
||||
blockHash: String(message?.blockHash || '').trim(),
|
||||
};
|
||||
const response = await this.ws.request('GetMessageLikes', { message: normalizedMessage, limit });
|
||||
const response = await this.ws.request('GetMessageLikes', { message: normalizedMessage });
|
||||
if (response.status !== 200) throw opError('GetMessageLikes', response);
|
||||
return response.payload || {};
|
||||
}
|
||||
@@ -3056,6 +3056,56 @@ export class AuthService {
|
||||
return response.payload || {};
|
||||
}
|
||||
|
||||
async setChannelReadState({
|
||||
login,
|
||||
ownerBlockchainName,
|
||||
channelName,
|
||||
readCount,
|
||||
timeMs,
|
||||
storagePwd,
|
||||
}) {
|
||||
const cleanLogin = String(login || '').trim();
|
||||
const cleanOwnerBch = String(ownerBlockchainName || '').trim();
|
||||
const cleanChannelName = String(channelName || '').trim();
|
||||
const cleanReadCount = Math.max(0, Math.trunc(Number(readCount || 0)));
|
||||
const cleanTimeMs = Math.trunc(Number(timeMs));
|
||||
if (!cleanLogin || !cleanOwnerBch || !cleanChannelName) {
|
||||
throw new Error('Не переданы login/ownerBlockchainName/channelName');
|
||||
}
|
||||
if (!Number.isFinite(cleanTimeMs) || cleanTimeMs <= 0) {
|
||||
throw new Error('Не передан корректный timeMs');
|
||||
}
|
||||
if (!storagePwd) throw new Error('Не передан storagePwd для подписи SetChannelReadState.');
|
||||
|
||||
const secrets = await loadEncryptedUserSecrets(cleanLogin, storagePwd);
|
||||
const clientPrivPkcs8 = String(secrets?.clientKey || '').trim();
|
||||
if (!clientPrivPkcs8) throw new Error('Не найден приватный clientKey');
|
||||
const privateKey = await importPkcs8Ed25519(clientPrivPkcs8);
|
||||
const clientKey = await publicKeyB64FromPkcs8Ed25519(clientPrivPkcs8);
|
||||
|
||||
const preimage = [
|
||||
'SHiNe/ChannelReadState:',
|
||||
escapeUserSettingPart(cleanLogin),
|
||||
escapeUserSettingPart(cleanOwnerBch),
|
||||
escapeUserSettingPart(cleanChannelName),
|
||||
String(cleanTimeMs),
|
||||
String(cleanReadCount),
|
||||
].join('|');
|
||||
const signature = await signBase64(privateKey, preimage);
|
||||
|
||||
const response = await this.ws.request('SetChannelReadState', {
|
||||
login: cleanLogin,
|
||||
owner_bch_name: cleanOwnerBch,
|
||||
channel_name: cleanChannelName,
|
||||
read_count: cleanReadCount,
|
||||
time_ms: cleanTimeMs,
|
||||
client_key: clientKey,
|
||||
signature,
|
||||
});
|
||||
if (response.status !== 200) throw opError('SetChannelReadState', response);
|
||||
return response.payload || {};
|
||||
}
|
||||
|
||||
async upsertUserSetting({
|
||||
login,
|
||||
settingType,
|
||||
|
||||
Reference in New Issue
Block a user