public LFollowedByAll ( System.Guid accountId ) : HashSetBlob |
||
accountId | System.Guid | |
return | HashSetBlob |
public void Add(Guid listId, Guid accountId) { // Set WIP to true HashSetBlob <Guid> bAddRmvMsgs = blobFactory.LAddRmvMsgs(listId); if (!bAddRmvMsgs.AddIfNotInWithRetry(accountId, new ListNotFound())) { return; } // Add list and accounts to the sets if (!blobFactory.LFollowedByAll(accountId).AddWithRetry(listId)) { bAddRmvMsgs.RemoveWithRetry(accountId); throw new AccountNotFound(); } blobFactory.LFollowedAccounts(listId).AddWithRetry(accountId); if (!blobFactory.LInfo(listId).Get().IsPrivate) { blobFactory.LFollowedByPublic(accountId).AddWithRetry(listId); } // add msgs Guid PersonnalListId = blobFactory.LPersonnalList(accountId).Get(); blobFactory.MListMessages(listId).UnionWith(blobFactory.MListMessages(PersonnalListId)); // set WIP to false bAddRmvMsgs.RemoveWithRetry(accountId); }
public Guid Post(Guid accountId, string content) { Guid messageId = Guid.NewGuid(); Blob <Message> bMessage = blobFactory.MMessage(messageId); try { IAccountInfo accountInfo = blobFactory.AInfo(accountId).GetIfExists(new AccountNotFound()); Guid personnalListId = blobFactory.LPersonnalList(accountId).GetIfExists(new AccountNotFound()); Message message = new Message(messageId, accountId, accountInfo.Name, "", DateTime.Now, content); MsgSetBlobPack bPersonnalListMsgs = blobFactory.MListMessages(personnalListId); // Save the message bMessage.Set(message); if (!bPersonnalListMsgs.AddMessage(message)) { throw new AccountNotFound(); } // Add in listMsg -- if a list is added during the foreach, then the message will be added by the addition of the list foreach (Guid listId in blobFactory.LFollowedByAll(accountId).GetIfExists(new AccountNotFound())) { try { blobFactory.MListMessages(listId).AddMessage(message); } catch { } } List <Message> lastmessages = blobFactory.MLastMessage().GetWithDefault(new List <Message>()); lastmessages.Add(message); // TODO: Take does *NOT* modify lastmessages :-) lastmessages.Take(100); blobFactory.MLastMessage().Set(lastmessages); } catch { bMessage.Delete(); throw; } // TODO : Add in accountMsg return(messageId); }
public Guid Create(Guid adminId, string name, string description, bool bypassNameReservation = false) { Blob <Guid> bIdByName = blobFactory.AIdByName(name); // lock the name if (!bypassNameReservation) { if (!bIdByName.SetIfNotExists(Guid.Empty)) { throw new AccountAlreadyExists(); } } Guid accountId = Guid.NewGuid(); // TODO : we could do it without a lock - or at least store the data before using (blobFactory.UAccountsLock(adminId)) { Guid personnalListId = Guid.NewGuid(); // store the data HashSet <Guid> users = new HashSet <Guid>(); users.Add(adminId); blobFactory.AUsers(accountId).Set(users); HashSet <Guid> followedByAll = new HashSet <Guid>(); followedByAll.Add(personnalListId); blobFactory.LFollowedByAll(accountId).Set(followedByAll); blobFactory.AInfo(accountId).Set(new AccountInfo(name, description)); blobFactory.AAdminId(accountId).Set(adminId); blobFactory.LOwnedListsPublic(accountId).Set(new HashSet <Guid>()); blobFactory.LOwnedListsPrivate(accountId).Set(new HashSet <Guid>()); blobFactory.LFollowedListsData(accountId).Set(new HashSet <Guid>()); blobFactory.LFollowedByPublic(accountId).Set(new HashSet <Guid>()); blobFactory.LFollowedListsLockInit(accountId); blobFactory.MTaggedMessages(accountId).Init(); blobFactory.AAutocompletion().Add(new KeyValuePair <string, string>(name.GenerateDoubleMetaphone(), name)); // Setup the personnal list blobFactory.LPersonnalList(accountId).Set(personnalListId); blobFactory.LInfo(personnalListId).Set(new ListInfo("", "", true, true)); blobFactory.LOwner(personnalListId).Set(accountId); blobFactory.MListMessages(personnalListId).Init(); blobFactory.LFollowedAccounts(personnalListId).Set(new Dictionary <Guid, bool>()); // we finish by unlocking the name bIdByName.Set(accountId); // we make this account accessible blobFactory.UAccountsData(adminId).Add(accountId); } return(accountId); }