Can delete the Offline Messages sent to/from a user.

This is useful if the user is deleted.
master-beforevarregion
Oren Hurvitz 2013-10-29 16:38:03 +02:00 committed by Justin Clark-Casey (justincc)
parent 46c2791fe2
commit 2d9d6fe922
5 changed files with 44 additions and 0 deletions

View File

@ -261,6 +261,11 @@ namespace OpenSim.OfflineIM
return m_OfflineIMService.StoreMessage(im, out reason); return m_OfflineIMService.StoreMessage(im, out reason);
} }
public void DeleteMessages(UUID userID)
{
m_OfflineIMService.DeleteMessages(userID);
}
#endregion #endregion
} }
} }

View File

@ -117,6 +117,14 @@ namespace OpenSim.OfflineIM
return true; return true;
} }
public void DeleteMessages(UUID userID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();
sendData["UserID"] = userID;
MakeRequest("DELETE", sendData);
}
#endregion #endregion

View File

@ -102,6 +102,8 @@ namespace OpenSim.OfflineIM
return HandleGet(request); return HandleGet(request);
case "STORE": case "STORE":
return HandleStore(request); return HandleStore(request);
case "DELETE":
return HandleDelete(request);
} }
m_log.DebugFormat("[OFFLINE IM HANDLER]: unknown method request: {0}", method); m_log.DebugFormat("[OFFLINE IM HANDLER]: unknown method request: {0}", method);
} }
@ -158,6 +160,21 @@ namespace OpenSim.OfflineIM
return Util.UTF8NoBomEncoding.GetBytes(xmlString); return Util.UTF8NoBomEncoding.GetBytes(xmlString);
} }
byte[] HandleDelete(Dictionary<string, object> request)
{
if (!request.ContainsKey("UserID"))
{
return FailureResult();
}
else
{
UUID userID = new UUID(request["UserID"].ToString());
m_OfflineIMService.DeleteMessages(userID);
return SuccessResult();
}
}
#region Helpers #region Helpers
private void NullResult(Dictionary<string, object> result, string reason) private void NullResult(Dictionary<string, object> result, string reason)

View File

@ -124,5 +124,12 @@ namespace OpenSim.OfflineIM
return m_Database.Store(data); return m_Database.Store(data);
} }
public void DeleteMessages(UUID userID)
{
m_Database.Delete("PrincipalID", userID.ToString());
m_Database.Delete("FromID", userID.ToString());
}
} }
} }

View File

@ -35,7 +35,14 @@ namespace OpenSim.Services.Interfaces
public interface IOfflineIMService public interface IOfflineIMService
{ {
List<GridInstantMessage> GetMessages(UUID principalID); List<GridInstantMessage> GetMessages(UUID principalID);
bool StoreMessage(GridInstantMessage im, out string reason); bool StoreMessage(GridInstantMessage im, out string reason);
/// <summary>
/// Delete messages to or from this user (or group).
/// </summary>
/// <param name="userID">A user or group ID</param>
void DeleteMessages(UUID userID);
} }
public class OfflineIMDataUtils public class OfflineIMDataUtils