public void EjectGroupMember(IClientAPI remoteClient, UUID agentID, UUID groupID, UUID ejecteeID) { if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); // Todo: Security check? m_groupData.RemoveAgentFromGroup(agentID.ToString(), ejecteeID.ToString(), groupID); string agentName; RegionInfo regionInfo; // remoteClient provided or just agentID? if (remoteClient != null) { agentName = remoteClient.Name; regionInfo = remoteClient.Scene.RegionInfo; remoteClient.SendEjectGroupMemberReply(agentID, groupID, true); } else { IClientAPI client = GetActiveClient(agentID); if (client != null) { agentName = client.Name; regionInfo = client.Scene.RegionInfo; client.SendEjectGroupMemberReply(agentID, groupID, true); } else { regionInfo = m_sceneList[0].RegionInfo; UserAccount acc = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, agentID); if (acc != null) { agentName = acc.FirstName + " " + acc.LastName; } else { agentName = "Unknown member"; } } } GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID.ToString(), groupID, null); UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, ejecteeID); if ((groupInfo == null) || (account == null)) { return; } // Send Message to Ejectee GridInstantMessage msg = new GridInstantMessage(); msg.imSessionID = UUID.Zero.Guid; msg.fromAgentID = agentID.Guid; // msg.fromAgentID = info.GroupID; msg.toAgentID = ejecteeID.Guid; //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); msg.timestamp = 0; msg.fromAgentName = agentName; msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName); msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; msg.Position = Vector3.Zero; msg.RegionID = regionInfo.RegionID.Guid; msg.binaryBucket = new byte[0]; OutgoingInstantMessage(msg, ejecteeID); // Message to ejector // Interop, received special 210 code for ejecting a group member // this only works within the comms servers domain, and won't work hypergrid // TODO:FIXME: Use a presense server of some kind to find out where the // client actually is, and try contacting that region directly to notify them, // or provide the notification via xmlrpc update queue msg = new GridInstantMessage(); msg.imSessionID = UUID.Zero.Guid; msg.fromAgentID = agentID.Guid; msg.toAgentID = agentID.Guid; msg.timestamp = 0; msg.fromAgentName = agentName; if (account != null) { msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, account.FirstName + " " + account.LastName); } else { msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, "Unknown member"); } msg.dialog = (byte)210; //interop msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; msg.Position = Vector3.Zero; msg.RegionID = regionInfo.RegionID.Guid; msg.binaryBucket = new byte[0]; OutgoingInstantMessage(msg, agentID); // SL sends out messages to everyone in the group // Who all should receive updates and what should they be updated with? UpdateAllClientsWithGroupInfo(ejecteeID); }
public void EjectGroupMember(IClientAPI remoteClient, UUID agentID, UUID groupID, UUID ejecteeID) { if (m_debugEnabled) MainConsole.Instance.DebugFormat("[GROUPS]: {0} called", MethodBase.GetCurrentMethod().Name); if (!m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID)) return; m_cachedGroupMemberships.Remove(ejecteeID); string agentName; RegionInfo regionInfo; // remoteClient provided or just agentID? if (remoteClient != null) { agentName = remoteClient.Name; regionInfo = remoteClient.Scene.RegionInfo; remoteClient.SendEjectGroupMemberReply(agentID, groupID, true); } else { IClientAPI client = GetActiveClient(agentID); if (client != null) { agentName = client.Name; regionInfo = client.Scene.RegionInfo; client.SendEjectGroupMemberReply(agentID, groupID, true); } else { regionInfo = m_scene.RegionInfo; UserAccount acc = m_scene.UserAccountService.GetUserAccount(regionInfo.AllScopeIDs, agentID); if (acc != null) agentName = acc.FirstName + " " + acc.LastName; else agentName = "Unknown member"; } } GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); UserAccount account = m_scene.UserAccountService.GetUserAccount(regionInfo.AllScopeIDs, ejecteeID); if ((groupInfo == null) || (account == null)) return; // Send Message to avatar being ejected from the group GridInstantMessage msg = new GridInstantMessage { SessionID = UUID.Zero, FromAgentID = UUID.Zero, ToAgentID = ejecteeID, Timestamp = 0, FromAgentName = "System", Message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName), Dialog = 210, FromGroup = false, Offline = 0, ParentEstateID = 0, Position = Vector3.Zero, RegionID = remoteClient.Scene.RegionInfo.RegionID, BinaryBucket = new byte[0] }; OutgoingInstantMessage(msg, ejecteeID); //Do this here for local agents, otherwise it never gets done IClientAPI ejectee = GetActiveClient(ejecteeID); if (ejectee != null) { msg.Dialog = (byte) InstantMessageDialog.MessageFromAgent; OutgoingInstantMessage(msg, ejecteeID); ejectee.SendAgentDropGroup(groupID); } // Message to ejected person // Interop, received special 210 code for ejecting a group member // this only works within the comms servers domain, and won't work hypergrid m_cachedGroupTitles[ejecteeID] = null; RemoveFromGroupPowersCache(ejecteeID, groupID); UpdateAllClientsWithGroupInfo(ejecteeID, ""); if (m_imService != null) { // SL sends out notifcations to the group messaging session that the person has left GridInstantMessage im = new GridInstantMessage { FromAgentID = groupID, Dialog = (byte) InstantMessageDialog.SessionSend, BinaryBucket = new byte[0], FromAgentName = "System", FromGroup = true, SessionID = groupID, Message = account.Name + " has been ejected from the group by " + remoteClient.Name + ".", Offline = 1, RegionID = remoteClient.Scene.RegionInfo.RegionID, Timestamp = (uint) Util.UnixTimeSinceEpoch(), ToAgentID = UUID.Zero }; m_imService.EnsureSessionIsStarted(groupID); m_imService.SendChatToSession(groupID, im); } }
public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) { if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); if (!m_groupData.RemoveAgentFromGroup(GetRequestingAgentID(remoteClient), ejecteeID, groupID)) return; remoteClient.SendEjectGroupMemberReply(GetRequestingAgentID(remoteClient), groupID, true); GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, ejecteeID); if ((groupInfo == null) || (account == null)) { return; } // Send Message to Ejectee GridInstantMessage msg = new GridInstantMessage(); msg.imSessionID = UUID.Zero.Guid; msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; msg.toAgentID = ejecteeID.Guid; msg.timestamp = 0; msg.fromAgentName = remoteClient.Name; msg.message = string.Format("You have been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName); msg.dialog = (byte)210; msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; msg.Position = Vector3.Zero; msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; msg.binaryBucket = new byte[0]; OutgoingInstantMessage(msg, ejecteeID); //Do this here for local agents, otherwise it never gets done IClientAPI ejectee = GetActiveClient(ejecteeID); if (ejectee != null) { msg.dialog = (byte)InstantMessageDialog.MessageFromAgent; OutgoingInstantMessage(msg, ejecteeID); ejectee.SendAgentDropGroup(groupID); } // Message to ejector // Interop, received special 210 code for ejecting a group member // this only works within the comms servers domain, and won't work hypergrid msg = new GridInstantMessage(); msg.imSessionID = UUID.Zero.Guid; msg.fromAgentID = GetRequestingAgentID(remoteClient).Guid; msg.toAgentID = GetRequestingAgentID(remoteClient).Guid; msg.timestamp = 0; msg.fromAgentName = remoteClient.Name; if (account != null) { msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, account.FirstName + " " + account.LastName); } else { msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", remoteClient.Name, groupInfo.GroupName, "Unknown member"); } msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; msg.Position = Vector3.Zero; msg.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; msg.binaryBucket = new byte[0]; OutgoingInstantMessage(msg, GetRequestingAgentID(remoteClient)); UpdateAllClientsWithGroupInfo(ejecteeID); if (m_groupsMessagingModule != null) { // SL sends out notifcations to the group messaging session that the person has left GridInstantMessage im = new GridInstantMessage(); im.fromAgentID = groupID.Guid; im.dialog = (byte)InstantMessageDialog.SessionSend; im.binaryBucket = new byte[0]; im.fromAgentName = "System"; im.fromGroup = true; im.imSessionID = groupID.Guid; im.message = remoteClient.Name + " has left the group."; im.offline = 1; im.RegionID = remoteClient.Scene.RegionInfo.RegionID.Guid; im.timestamp = (uint)Util.UnixTimeSinceEpoch(); im.toAgentID = Guid.Empty; m_groupsMessagingModule.SendMessageToGroup(im, groupID); } }
// agentID and agentName are only used if remoteClient is null. // agentID/agentName is the requesting user, typically owner of the script requesting it. public int EjectGroupMemberRequest(IClientAPI remoteClient, UUID agentID, string agentName, UUID groupID, UUID ejecteeID) { if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); GroupRequestID grID = GetClientGroupRequestID(remoteClient); IScene scene = m_sceneList[0]; if (remoteClient != null) { agentID = remoteClient.AgentId; agentName = remoteClient.Name; scene = remoteClient.Scene; } int rc = m_groupData.RemoveAgentFromGroup(grID, agentID, ejecteeID, groupID); if (rc != 0) return rc; // After this point, always return SUCCESS. if (remoteClient != null) remoteClient.SendEjectGroupMemberReply(remoteClient.AgentId, groupID, true); GroupRecord groupInfo = m_groupData.GetGroupRecord(grID, groupID, null); UserProfileData userProfile = m_sceneList[0].CommsManager.UserService.GetUserProfile(ejecteeID); if ((groupInfo == null) || (userProfile == null)) { // The user was removed from the group but we don't have the data to notify them. // This is not likely to ever happen in practice or the RemoveAgentFromGroup call // would have returned false, however, this is here for safety and to indicate to // the calling script that the actual eject succeeded. return (int)Constants.GenericReturnCodes.SUCCESS; } // Send Message to Ejectee GridInstantMessage msg = new GridInstantMessage(); msg.imSessionID = UUID.Zero.Guid; msg.fromAgentID = agentID.Guid; // msg.fromAgentID = info.GroupID; msg.toAgentID = ejecteeID.Guid; //msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); msg.timestamp = 0; msg.fromAgentName = agentName; msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName); msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; msg.fromGroup = false; msg.offline = (byte)1; // Allow this message to be stored offline for fetch on login msg.ParentEstateID = 0; msg.Position = Vector3.Zero; msg.RegionID = scene.RegionInfo.RegionID.Guid; msg.binaryBucket = new byte[0]; OutgoingInstantMessage(msg, ejecteeID); // Message to ejector // Interop, received special 210 code for ejecting a group member // this only works within the comms servers domain, and won't work hypergrid // TODO:FIXME: Use a presense server of some kind to find out where the // client actually is, and try contacting that region directly to notify them, // or provide the notification via xmlrpc update queue msg = new GridInstantMessage(); msg.imSessionID = UUID.Zero.Guid; msg.fromAgentID = agentID.Guid; msg.toAgentID = agentID.Guid; msg.timestamp = 0; msg.fromAgentName = agentName; if (userProfile != null) { msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, userProfile.Name); } else { msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, "Unknown member"); } msg.dialog = (byte)210; //interop msg.fromGroup = false; msg.offline = (byte)0; msg.ParentEstateID = 0; msg.Position = Vector3.Zero; msg.RegionID = scene.RegionInfo.RegionID.Guid; msg.binaryBucket = new byte[0]; OutgoingInstantMessage(msg, agentID); // SL sends out messages to everyone in the group // Who all should receive updates and what should they be updated with? UpdateAllClientsWithGroupInfo(ejecteeID); return (int)Constants.GenericReturnCodes.SUCCESS; }