예제 #1
0
        MessageSubmitAccount GenerateSubmitAccount(Chain.Index index)
        {
            (var friendAccountId, var friendKeyIndex, var accountId, var keyIndex) = GetFriendAccountId(index);

            if (accountId != AccountId)
            {
                return(null);
            }

            var submitAccount = ServiceNode.GetSubmitAccount <MessageSubmitAccount>(keyIndex, index);

            if (submitAccount != null)
            {
                return(submitAccount);
            }

            foreach (var account in ServiceNode.ServiceAccounts.Values)
            {
                if (!account.IsDecrypted)
                {
                    continue;
                }

                if (account.AccountId == accountId && account.KeyIndex == keyIndex)
                {
                    submitAccount = new MessageSubmitAccount(account, this, friendAccountId, friendKeyIndex, keyIndex, index, true);
                    ServiceNode.AddSubmitAccount(submitAccount);

                    return(submitAccount);
                }
            }

            return(null);
        }
예제 #2
0
        public bool GenerateSubmitAccounts(long friendAccountId, short friendKeyIndex)
        {
            foreach (var account in ServiceNode.ServiceAccounts.Values)
            {
                if (!account.IsDecrypted)
                {
                    continue;
                }

                var index         = MessageServiceInfo.GetConversationIndex(account.AccountId, account.KeyIndex, friendAccountId, friendKeyIndex);
                var submitAccount = ServiceNode.GetSubmitAccount <MessageSubmitAccount>(account.KeyIndex, index);
                if (submitAccount == null)
                {
                    submitAccount = new MessageSubmitAccount(account, this, friendAccountId, friendKeyIndex, account.KeyIndex, index, true);
                    ServiceNode.AddSubmitAccount(submitAccount);
                }
            }

            return(true);
        }