From fe6659e9554604c85e9e278ec39bf802a6727196 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 26 Dec 2022 16:21:55 -0600 Subject: create MessagingDbContext --- src/slskd/Program.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/slskd/Program.cs') diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 04d3b7e4..24420b7d 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -534,11 +534,13 @@ namespace slskd { services.AddDbContext($"Data Source=file:search?mode=memory;Cache=shared;Pooling=True;"); services.AddDbContext($"Data Source=file:transfers?mode=memory;Cache=shared;Pooling=True;"); + services.AddDbContext($"Data Source=file:messaging?mode=memory;Cache=shared;Pooling=True;"); } else { services.AddDbContext($"Data Source={Path.Combine(DataDirectory, "search.db")};Cache=shared;Pooling=True;"); services.AddDbContext($"Data Source={Path.Combine(DataDirectory, "transfers.db")};Cache=shared;Pooling=True;"); + services.AddDbContext($"Data Source={Path.Combine(DataDirectory, "messaging.db")};Cache=shared;Pooling=True;"); } services.AddSingleton(); -- cgit v1.2.3 From 55b1a3b53eedb8f1b0a179c8951c9fee88576bdf Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 26 Dec 2022 16:23:06 -0600 Subject: add new services to DI --- src/slskd/Program.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/slskd/Program.cs') diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 24420b7d..f961c610 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -547,6 +547,9 @@ namespace slskd services.AddSingleton(); services.AddSingleton(_ => new RoomTracker(messageLimit: 250)); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); services.AddTransient(); -- cgit v1.2.3 From 909b6e532721936e82914712d6228b62619d2fc1 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 27 Dec 2022 11:16:13 -0600 Subject: remove deprecated ConversationTracker --- src/slskd/Messaging/ConversationTracker.cs | 62 ----------------------------- src/slskd/Messaging/IConversationTracker.cs | 55 ------------------------- src/slskd/Program.cs | 1 - 3 files changed, 118 deletions(-) delete mode 100644 src/slskd/Messaging/ConversationTracker.cs delete mode 100644 src/slskd/Messaging/IConversationTracker.cs (limited to 'src/slskd/Program.cs') diff --git a/src/slskd/Messaging/ConversationTracker.cs b/src/slskd/Messaging/ConversationTracker.cs deleted file mode 100644 index 27d678ca..00000000 --- a/src/slskd/Messaging/ConversationTracker.cs +++ /dev/null @@ -1,62 +0,0 @@ -// -// Copyright (c) slskd Team. All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see https://www.gnu.org/licenses/. -// - -namespace slskd.Messaging -{ - using System.Collections.Concurrent; - using System.Collections.Generic; - - /// - /// Tracks private message conversations. - /// - public class ConversationTracker : IConversationTracker - { - /// - /// Tracked private message conversations. - /// - public ConcurrentDictionary> Conversations { get; } = new ConcurrentDictionary>(); - - /// - /// Adds a private message conversation and appends the specified , or just appends the - /// message if the conversation exists. - /// - /// - /// - public void AddOrUpdate(string username, PrivateMessage message) - { - Conversations.AddOrUpdate(username, new List() { message }, (_, messageList) => - { - messageList.Add(message); - return messageList; - }); - } - - /// - /// Returns the list of private messages for the specified , if any exist. - /// - /// - /// - /// - public bool TryGet(string username, out IList messages) => Conversations.TryGetValue(username, out messages); - - /// - /// Removes a tracked private message conversation for the specified user. - /// - /// - public void TryRemove(string username) => Conversations.TryRemove(username, out _); - } -} \ No newline at end of file diff --git a/src/slskd/Messaging/IConversationTracker.cs b/src/slskd/Messaging/IConversationTracker.cs deleted file mode 100644 index 8e7a90f4..00000000 --- a/src/slskd/Messaging/IConversationTracker.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// Copyright (c) slskd Team. All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see https://www.gnu.org/licenses/. -// - -namespace slskd.Messaging -{ - using System.Collections.Concurrent; - using System.Collections.Generic; - - /// - /// Tracks private message conversations. - /// - public interface IConversationTracker - { - /// - /// Tracked private message conversations. - /// - ConcurrentDictionary> Conversations { get; } - - /// - /// Adds a private message conversation and appends the specified , or just appends the - /// message if the conversation exists. - /// - /// - /// - void AddOrUpdate(string username, PrivateMessage message); - - /// - /// Returns the list of private messages for the specified , if any exist. - /// - /// - /// - /// - bool TryGet(string username, out IList messages); - - /// - /// Removes a tracked private message conversation for the specified user. - /// - /// - void TryRemove(string username); - } -} \ No newline at end of file diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index f961c610..c909d7a4 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -544,7 +544,6 @@ namespace slskd } services.AddSingleton(); - services.AddSingleton(); services.AddSingleton(_ => new RoomTracker(messageLimit: 250)); services.AddSingleton(); -- cgit v1.2.3