public bool UserCurrencyTransfer(UUID toID, UUID fromID, UUID toObjectID, string toObjectName, UUID fromObjectID,
string fromObjectName, uint amount, string description, TransactionType type, UUID transactionID)
{
if (m_doRemoteOnly) {
object remoteValue = DoRemoteByURL ("CurrencyServerURI", toID, fromID, toObjectID, toObjectName, fromObjectID,
fromObjectName, amount, description, type, transactionID);
return remoteValue != null && (bool)remoteValue;
}
// check if the 'toID' is a group
var groupService = Framework.Utilities.DataManager.RequestPlugin<IGroupsServiceConnector> ();
if (groupService.IsGroup(toID))
return GroupCurrencyTransfer(toID, fromID, false, toObjectName, fromObjectID,
fromObjectName, (int) amount, description, type, transactionID);
// use transfer
UserCurrency toCurrency = GetUserCurrency(toID);
UserCurrency fromCurrency = fromID == UUID.Zero ? null : GetUserCurrency(fromID);
if (toCurrency == null)
return false;
// Groups (legacy) should not receive stipends
if ((type == TransactionType.StipendPayment) && toCurrency.IsGroup)
return false;
if (fromCurrency != null)
{
if (fromID == (UUID)Constants.BankerUUID)
{
// payment from the Banker
// 20150730 - greythane - need to fiddle 'the books' as -ve balances are not currently available
fromCurrency.Amount += amount;
} else
{
// Normal users cannot have a credit balance.. check to see whether they have enough money
if ((int)fromCurrency.Amount - (int)amount < 0)
return false; // Not enough money
}
// subtract this payment
fromCurrency.Amount -= amount;
UserCurrencyUpdate (fromCurrency, true);
}
if (fromID == toID)
toCurrency = GetUserCurrency (toID);
//Update the user who is getting paid
toCurrency.Amount += amount;
UserCurrencyUpdate(toCurrency, true);
//Must send out notifications to the users involved so that they get the updates
if (m_userInfoService == null)
{
m_userInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
m_userAccountService = m_registry.RequestModuleInterface<IUserAccountService> ();
}
if (m_userInfoService != null)
{
UserInfo toUserInfo = m_userInfoService.GetUserInfo(toID.ToString());
UserInfo fromUserInfo = fromID == UUID.Zero ? null : m_userInfoService.GetUserInfo(fromID.ToString());
UserAccount toAccount = m_userAccountService.GetUserAccount(null, toID);
UserAccount fromAccount = m_userAccountService.GetUserAccount(null, fromID);
if (m_config.SaveTransactionLogs)
AddTransactionRecord(
(transactionID == UUID.Zero ? UUID.Random() : transactionID),
description,
toID,
fromID,
amount,
type,
toCurrency.Amount,
(fromCurrency == null ? 0 : fromCurrency.Amount),
(toAccount == null ? "System" : toAccount.Name),
(fromAccount == null ? "System" : fromAccount.Name),
toObjectName,
fromObjectName,
(fromUserInfo == null ? UUID.Zero : fromUserInfo.CurrentRegionID)
);
if (fromID == toID)
{
if (toUserInfo != null && toUserInfo.IsOnline)
SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount,
toAccount == null ? "" : (toAccount.Name + " paid you " + InWorldCurrency + amount + (description == "" ? "" : ": " + description)));
} else
{
if (toUserInfo != null && toUserInfo.IsOnline)
{
SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount,
fromAccount == null ? "" : (fromAccount.Name + " paid you " + InWorldCurrency + amount + (description == "" ? "" : ": " + description)));
}
if (fromUserInfo != null && fromUserInfo.IsOnline)
{
SendUpdateMoneyBalanceToClient(fromID, transactionID, fromUserInfo.CurrentRegionURI, fromCurrency.Amount,
"You paid " + (toAccount == null ? "" : toAccount.Name) + " " + InWorldCurrency + amount);
}
}
}
return true;
}