Exemple #1
0
        public object DeleteDirectory(DirectoryIdRequest request)
        {
            lock (StorageLock)
            {
                if (!Storage.Directories.ContainsKey(request.Id))
                {
                    return(Success);
                }

                Storage.Directories.Remove(request.Id);
                return(Success);
            }
        }
Exemple #2
0
        public object Expunge(DirectoryIdRequest request)
        {
            lock (StorageLock)
            {
                if (!Storage.Directories.ContainsKey(request.Id))
                {
                    return(Fail);
                }

                Storage.Directories[request.Id].Messages
                .RemoveAll(m => m.Flags.Contains("\\Deleted"));
                return(Success);
            }
        }
Exemple #3
0
        public object GetDirectoryDetails(DirectoryIdRequest request)
        {
            lock (StorageLock)
            {
                if (request?.Id == null || !Storage.Directories.ContainsKey(request.Id))
                {
                    return(Fail);
                }

                var dir = Storage.Directories[request.Id];
                return(new
                {
                    exist_count = dir.Messages.Count,
                    flags = dir.AvailableFlags,
                    recent_count = dir.Messages.Count(m => m.Flags.Contains("\\Recent")),
                    uidnext = Storage.Directories.Values.SelectMany(d => d.Messages)
                              .Max(m => m.UId) + 1,
                    uidvalidity = 1337,
                    unseen_count = dir.Messages.Count(m => m.Flags.Contains("\\Unseen")),
                });
            }
        }