SHA256
Добавлен канал личных публикаций
This commit is contained in:
@@ -2123,6 +2123,25 @@ export class AuthService {
|
||||
if (!Number.isFinite(cleanTargetBlockNumber) || cleanTargetBlockNumber < 0) {
|
||||
throw new Error('Invalid target block number');
|
||||
}
|
||||
if (cleanLogin.toLowerCase() === cleanTargetLogin.toLowerCase()) throw new Error('Cannot follow own channel');
|
||||
if (cleanTargetBlockNumber === 0 && unfollow) {
|
||||
const feed = await this.listSubscriptionsFeed(cleanLogin, 1000);
|
||||
const roots = (feed.followedUsersChannels || []).filter(row =>
|
||||
Number(row?.channel?.channelRoot?.blockNumber) === 0
|
||||
&& String(row?.channel?.ownerLogin || '').toLowerCase() === cleanTargetLogin.toLowerCase());
|
||||
const hashes = [...new Set(roots.map(row => normalizeHex32(row?.channel?.channelRoot?.blockHash, ZERO64)))];
|
||||
if (hashes.length) {
|
||||
let result;
|
||||
for (const hash of hashes) {
|
||||
result = await this.addBlockConnectionTarget({
|
||||
login: cleanLogin, storagePwd, subType: MSG_SUBTYPE_CONNECTION_UNFOLLOW,
|
||||
toLogin: cleanTargetLogin, toForkNumber: forkNumberFromBlockchainNameValue(cleanTargetBch),
|
||||
toBlockNumber: 0, toBlockHashHex: hash,
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
const seedHash = normalizeHex32(targetBlockHashHex, ZERO64);
|
||||
let targetHashHex = seedHash;
|
||||
if (targetHashHex === ZERO64) {
|
||||
@@ -2395,6 +2414,10 @@ export class AuthService {
|
||||
|
||||
let channelSlug = toCanonicalChannelSlug(String(selector?.channelName || selector?.slug || ''));
|
||||
let rootHashHex = normalizeHex32(selector?.channelRootBlockHash, ZERO64);
|
||||
if (lineCode === 0) {
|
||||
channelSlug = 'stories';
|
||||
rootHashHex = await this.resolveHeaderHashForBlockchain(blockchainName);
|
||||
}
|
||||
if (rootHashHex === ZERO64 || !channelSlug) {
|
||||
const ownChannels = await this.listOwnChannelsForBlockchain(login, blockchainName);
|
||||
const rootChannel = ownChannels.find((item) => item.rootBlockNumber === lineCode);
|
||||
@@ -2529,6 +2552,7 @@ export class AuthService {
|
||||
const selector = channel || {};
|
||||
const owner = String(selector?.ownerBlockchainName || '').trim();
|
||||
const root = Number(selector?.channelRootBlockNumber);
|
||||
if (root === 0) throw new Error(channelNameErrorText('reserved_stories'));
|
||||
const metaText = composeChannelMetaText({ title, description, avatar });
|
||||
const key = `channel-line:${cleanLogin}:${owner}:${root}`;
|
||||
|
||||
@@ -2573,6 +2597,7 @@ export class AuthService {
|
||||
const selector = channel || {};
|
||||
const owner = String(selector?.ownerBlockchainName || '').trim();
|
||||
const root = Number(selector?.channelRootBlockNumber);
|
||||
if (root === 0) throw new Error(channelNameErrorText('reserved_stories'));
|
||||
const key = `channel-line:${cleanLogin}:${owner}:${root}`;
|
||||
|
||||
return this.runLineWriteLocked(key, async () => {
|
||||
|
||||
Reference in New Issue
Block a user