public void Execute(ISender commandSender, string commandLabel, string[] args) { if (args.Length < 2) { return; } Guid id = ProfileCache.Instance.ParseEmailToGuid(args[1].ToLower()); if (id.Equals(Guid.Empty)) { PacChatServer.GetServer().Logger.Error("Email is not exists."); return; } ChatUser user = ChatUserManager.LoadUser(id); user.Banned = true; user.Save(); if (user.IsOnline()) { user.Kick(); } }
public void Handle(ISession session) { ChatSession chatSession = session as ChatSession; UserSearchResponse response = new UserSearchResponse(); List <String> UserIDs = new ChatUserStore().SearchUserIDByEmail(Email, (session as ChatSession).Owner); ConversationStore store = new ConversationStore(); foreach (var item in UserIDs) { Guid userId = Guid.Parse(item); ChatUser targetUser = ChatUserManager.LoadUser(userId); SearchResult result = new SearchResult(); result.ID = targetUser.ID.ToString(); result.FirstName = targetUser.FirstName; result.LastName = targetUser.LastName; result.IsOnline = targetUser.IsOnline(); result.LastLogout = targetUser.LastLogoff; result.PreviewCode = -1; result.ConversationID = "~"; var CommonConversation = targetUser.ConversationID.Intersect(chatSession.Owner.ConversationID); foreach (Guid id in CommonConversation) { AbstractConversation conversation = store.Load(id); if (conversation is SingleConversation) { result.ConversationID = conversation.ID.ToString(); AbstractMessage message = conversation.MessagesID.Count > 0 ? new MessageStore().Load(conversation.MessagesID.Last(), conversation.ID) : null; if (message == null) { break; } if (!message.Showable(chatSession.Owner.ID)) { result.PreviewCode = 0; break; } result.PreviewCode = message.GetPreviewCode(); if (message.GetPreviewCode() == 4) { result.LastMessage = (message as TextMessage).Message; } break; } } if (chatSession.Owner.Relationship.ContainsKey(targetUser.ID)) { result.Relationship = (int)Relation.Get(chatSession.Owner.Relationship[targetUser.ID]).RelationType; } else { result.Relationship = (int)Relation.Type.None; } response.Results.Add(result); } session.Send(response); }
public void Handle(ISession session) { ChatSession chatSession = session as ChatSession; ChatUser targetUser = ChatUserManager.LoadUser(TargetID); if (targetUser == null) { return; } ShortProfileResponse response = new ShortProfileResponse(); response.ID = targetUser.ID.ToString(); response.FirstName = targetUser.FirstName; response.LastName = targetUser.LastName; response.IsOnline = targetUser.IsOnline(); response.LastLogout = targetUser.LastLogoff; ConversationStore store = new ConversationStore(); response.PreviewCode = -1; response.ConversationID = "~"; var CommonConversation = targetUser.ConversationID.Intersect(chatSession.Owner.ConversationID); foreach (Guid id in CommonConversation) { AbstractConversation conversation = store.Load(id); if (conversation is SingleConversation) { response.ConversationID = conversation.ID.ToString(); AbstractMessage message = conversation.MessagesID.Count > 0 ? new MessageStore().Load(conversation.MessagesID.Last(), conversation.ID) : null; if (message == null) { break; } if (!message.Showable(chatSession.Owner.ID)) { response.PreviewCode = 0; break; } response.PreviewCode = message.GetPreviewCode(); if (message.GetPreviewCode() == 4) { response.LastMess = (message as TextMessage).Message; } break; } } if (chatSession.Owner.Relationship.ContainsKey(targetUser.ID)) { response.RelationshipType = (int)Relation.Get(chatSession.Owner.Relationship[targetUser.ID]).RelationType; } else { response.RelationshipType = (int)Relation.Type.None; } chatSession.Send(response); }