2026-02-04 15:44:23 +01:00
|
|
|
// Copyright (c) 2026 Duplicati Inc. All rights reserved.
|
|
|
|
|
|
|
|
|
|
using Duplicati.Library.Common.IO;
|
|
|
|
|
using Google.Apis.HangoutsChat.v1.Data;
|
|
|
|
|
using System.Text.Json;
|
|
|
|
|
|
|
|
|
|
namespace Duplicati.Proprietary.GoogleWorkspace.SourceItems;
|
|
|
|
|
|
2026-02-16 11:31:19 +01:00
|
|
|
internal class ChatMessageContentSourceEntry(string parentPath, Message message)
|
2026-02-04 15:44:23 +01:00
|
|
|
: StreamResourceEntryBase(SystemIO.IO_OS.PathCombine(parentPath, "message.json"),
|
|
|
|
|
message.CreateTimeDateTimeOffset.HasValue ? message.CreateTimeDateTimeOffset.Value.UtcDateTime : DateTime.UnixEpoch,
|
|
|
|
|
DateTime.UnixEpoch)
|
|
|
|
|
{
|
|
|
|
|
public override long Size => -1;
|
|
|
|
|
|
|
|
|
|
public override Task<Stream> OpenRead(CancellationToken cancellationToken)
|
2026-02-16 11:31:19 +01:00
|
|
|
=> Task.FromResult<Stream>(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(JsonSerializer.Serialize(message))));
|
2026-02-04 15:44:23 +01:00
|
|
|
|
|
|
|
|
public override Task<Dictionary<string, string?>> GetMinorMetadata(CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
return Task.FromResult(new Dictionary<string, string?>
|
|
|
|
|
{
|
|
|
|
|
{ "gsuite:v", "1" },
|
2026-02-16 11:31:19 +01:00
|
|
|
{ "gsuite:Type", SourceItemType.ChatMessageContent.ToString() },
|
2026-02-04 15:44:23 +01:00
|
|
|
{ "gsuite:Name", "message.json" },
|
2026-02-11 16:23:27 +01:00
|
|
|
{ "gsuite:Id", message.Name }
|
2026-02-04 15:44:23 +01:00
|
|
|
}
|
|
|
|
|
.Where(kv => !string.IsNullOrEmpty(kv.Value))
|
|
|
|
|
.ToDictionary(kv => kv.Key, kv => kv.Value));
|
|
|
|
|
}
|
|
|
|
|
}
|