diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6e72608e0a..073fbf4492 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -129,6 +129,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected IMaterialsModule m_materialsModule = null; protected IEnvironmentModule m_envModule = null; + protected IEmailModule m_emailModule = null; protected Dictionary m_userInfoCache = new Dictionary(); protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. @@ -147,7 +148,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected int m_sleepMsOnMakeFire = 100; protected int m_sleepMsOnRezAtRoot = 100; protected int m_sleepMsOnInstantMessage = 2000; - protected int m_sleepMsOnEmail = 20000; + protected int m_sleepMsOnEmail = 30000; protected int m_sleepMsOnCreateLink = 1000; protected int m_sleepMsOnGiveInventory = 3000; protected int m_sleepMsOnRequestAgentData = 100; @@ -314,6 +315,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_SoundModule = m_ScriptEngine.World.RequestModuleInterface(); m_materialsModule = m_ScriptEngine.World.RequestModuleInterface(); + m_emailModule = m_ScriptEngine.World.RequestModuleInterface(); m_envModule = m_ScriptEngine.World.RequestModuleInterface< IEnvironmentModule>(); AsyncCommands = new AsyncCommandManager(m_ScriptEngine); @@ -3983,8 +3985,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llEmail(string address, string subject, string message) { m_host.AddScriptLPS(1); - IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface(); - if (emailModule == null) + if (m_emailModule == null) { Error("llEmail", "Email module not configured"); return; @@ -4014,22 +4015,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api address = account.Email; } - emailModule.SendEmail(m_host.UUID, address, subject, message); + m_emailModule.SendEmail(m_host.UUID, address, subject, message); ScriptSleep(m_sleepMsOnEmail); } public void llGetNextEmail(string address, string subject) { m_host.AddScriptLPS(1); - IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface(); - if (emailModule == null) + if (m_emailModule == null) { Error("llGetNextEmail", "Email module not configured"); return; } Email email; - email = emailModule.GetNextEmail(m_host.UUID, address, subject); + email = m_emailModule.GetNextEmail(m_host.UUID, address, subject); if (email == null) return; @@ -4046,42 +4046,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } - public void llTargetedEmail(LSL_Integer target, string subject, string message) + public void llTargetedEmail(LSL_Integer target, LSL_String subject, LSL_String message) { m_host.AddScriptLPS(1); - IEmailModule emailModule = m_ScriptEngine.World.RequestModuleInterface(); - if (emailModule == null) + + SceneObjectGroup parent = m_host.ParentGroup; + if (parent == null || parent.IsDeleted) + return; + + if (m_emailModule == null) { Error("llTargetedEmail", "Email module not configured"); return; } - string address; - - if(target == ScriptBaseClass.TARGETED_EMAIL_OBJECT_OWNER) + if (subject.Length + message.Length > 4096) { - UserAccount account = - World.UserAccountService.GetUserAccount( - World.RegionInfo.ScopeID, - m_host.OwnerID); - - if (account == null) - { - Error("llEmail", "Can't find user account for '" + m_host.OwnerID.ToString() + "'"); - return; - } - - if (String.IsNullOrEmpty(account.Email)) - { - Error("llEmail", "User account has not registered an email address."); - return; - } - - address = account.Email; + Error("llTargetedEmail", "Message is too large"); + return; } - else return; - emailModule.SendEmail(m_host.UUID, address, subject, message); + string address; + UserAccount account = null; + + if (target == ScriptBaseClass.TARGETED_EMAIL_OBJECT_OWNER) + { + if(parent.OwnerID == parent.GroupID) + return; + account = World.UserAccountService.GetUserAccount( + World.RegionInfo.ScopeID, + parent.OwnerID); + } + else if (target == ScriptBaseClass.TARGETED_EMAIL_ROOT_CREATOR) + { + // non standard avoid creator spam + if(((parent.RootPart.OwnerMask & (uint)PermissionMask.Modify) == 0) || m_item.CreatorID == parent.RootPart.CreatorID) + { + account = World.UserAccountService.GetUserAccount( + World.RegionInfo.ScopeID, + parent.RootPart.CreatorID); + } + } + else + return; + + if (account == null) + { + Error("llTargetedEmail", "Can't find user account for '" + m_host.OwnerID.ToString() + "'"); + return; + } + + address = account.Email; + if (String.IsNullOrEmpty(address)) + { + Error("llTargetedEmail", "User account has not registered an email address."); + return; + } + + m_emailModule.SendEmail(m_host.UUID, address, subject, message); ScriptSleep(m_sleepMsOnEmail); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 4ae1c7b980..8b105d9774 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -426,7 +426,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_Integer llTarget(LSL_Vector position, double range); void llTargetOmega(LSL_Vector axis, double spinrate, double gain); void llTargetRemove(int number); - void llTargetedEmail(LSL_Integer target, string subject, string message); + void llTargetedEmail(LSL_Integer target, LSL_String subject, LSL_String message); void llTeleportAgentHome(string agent); void llTeleportAgent(string agent, string simname, LSL_Vector pos, LSL_Vector lookAt); void llTeleportAgentGlobalCoords(string agent, LSL_Vector global, LSL_Vector pos, LSL_Vector lookAt); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 11aef3dcc4..d6dd7228ec 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -970,8 +970,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const string IMG_USE_BAKED_AUX1 = "9742065b-19b5-297c-858a-29711d539043"; public const string IMG_USE_BAKED_AUX2 = "03642e83-2bd1-4eb9-34b4-4c47ed586d2d"; public const string IMG_USE_BAKED_AUX3 = "edd51b77-fc10-ce7a-4b3d-011dfc349e4f"; - + // llTargetedEmail + public const int TARGETED_EMAIL_ROOT_CREATOR = 1; public const int TARGETED_EMAIL_OBJECT_OWNER = 2; } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 27e1ce1dde..2d57883319 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1921,7 +1921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llTargetRemove(number); } - public void llTargetedEmail(LSL_Integer target, string subject, string message) + public void llTargetedEmail(LSL_Integer target, LSL_String subject, LSL_String message) { m_LSL_Functions.llTargetedEmail(target, subject, message); }