RPC TelegramService.ReadSource + ISessionClient.GetMessageAsync, порт ITelegramGateway.ReadSourceAsync и провайдер TelegramSourceContentProvider в ядре; GET /api/cards/{id}/source догружает исходник у сервиса-владельца, в UI — кнопка «Обновить из источника». Медиа-посты пропускаются.
101 lines
3.5 KiB
C#
101 lines
3.5 KiB
C#
using Deal.Contracts.Integrations.Abstractions;
|
|
using Deal.Contracts.Integrations.Models;
|
|
|
|
namespace Deal.Infrastructure.Integrations.Services;
|
|
|
|
/// <summary>
|
|
/// Локальная заглушка <see cref="ITelegramGateway"/> без telegram-service.
|
|
/// </summary>
|
|
public sealed class LocalTelegramGateway : ITelegramGateway
|
|
{
|
|
// Фаза idle-формы (аккаунт не подключён — сервиса нет).
|
|
private const string IdlePhase = "idle";
|
|
|
|
/// <inheritdoc />
|
|
public Task<TelegramAccountStatusDto> StatusAsync(CancellationToken ct)
|
|
{
|
|
return Task.FromResult(new TelegramAccountStatusDto(IdlePhase, false, false, string.Empty, null, null));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public Task<TelegramAuthResultDto> StartPhoneAsync(
|
|
string phone,
|
|
int apiId,
|
|
string apiHash,
|
|
CancellationToken ct)
|
|
=> Task.FromResult(new TelegramAuthResultDto(IdlePhase, null));
|
|
|
|
/// <inheritdoc />
|
|
public Task<TelegramAuthResultDto> StartQrAsync(
|
|
int apiId,
|
|
string apiHash,
|
|
CancellationToken ct)
|
|
=> Task.FromResult(new TelegramAuthResultDto(IdlePhase, null));
|
|
|
|
/// <inheritdoc />
|
|
public Task<string> SendCodeAsync(string code, CancellationToken ct) => Task.FromResult(IdlePhase);
|
|
|
|
/// <inheritdoc />
|
|
public Task<string> SendPasswordAsync(string password, CancellationToken ct) => Task.FromResult(IdlePhase);
|
|
|
|
/// <inheritdoc />
|
|
public Task LogoutAsync(CancellationToken ct) => Task.CompletedTask;
|
|
|
|
/// <inheritdoc />
|
|
public Task<IReadOnlyList<TelegramDialogEntryDto>> RefreshDialogsAsync(CancellationToken ct)
|
|
=> Task.FromResult<IReadOnlyList<TelegramDialogEntryDto>>([]);
|
|
|
|
/// <inheritdoc />
|
|
public Task SetMonitorAsync(
|
|
string dialogId,
|
|
bool enabled,
|
|
CancellationToken ct) => Task.CompletedTask;
|
|
|
|
/// <inheritdoc />
|
|
public Task SetMonitorAllAsync(bool enabled, CancellationToken ct) => Task.CompletedTask;
|
|
|
|
/// <inheritdoc />
|
|
public Task<int> BackfillAsync(
|
|
string dialogId,
|
|
bool force,
|
|
CancellationToken ct) => Task.FromResult(0);
|
|
|
|
/// <inheritdoc />
|
|
public Task<IReadOnlyList<TelegramRecentMessageDto>> ReadRecentAsync(
|
|
string dialogId,
|
|
int limit,
|
|
CancellationToken ct)
|
|
=> Task.FromResult<IReadOnlyList<TelegramRecentMessageDto>>([]);
|
|
|
|
/// <inheritdoc />
|
|
public Task<TelegramSourceContentDto> ReadSourceAsync(
|
|
string dialogId,
|
|
long msgId,
|
|
CancellationToken ct)
|
|
=> Task.FromResult(new TelegramSourceContentDto(false, null, null));
|
|
|
|
/// <inheritdoc />
|
|
public Task<IReadOnlyList<TelegramDialogEntryDto>> SearchAsync(
|
|
string query,
|
|
int limit,
|
|
CancellationToken ct)
|
|
=> Task.FromResult<IReadOnlyList<TelegramDialogEntryDto>>([]);
|
|
|
|
/// <inheritdoc />
|
|
public Task<TelegramChannelInfoDto> InfoAsync(string dialogId, CancellationToken ct)
|
|
=> Task.FromResult(new TelegramChannelInfoDto(dialogId, string.Empty, string.Empty, string.Empty, SourceDefaults.DefaultHue, null, false));
|
|
|
|
/// <inheritdoc />
|
|
public Task<TelegramEvalReadDto> ReadForEvalAsync(
|
|
string dialogId,
|
|
int limit,
|
|
CancellationToken ct)
|
|
=> Task.FromResult(new TelegramEvalReadDto(false, "no_history", []));
|
|
|
|
/// <inheritdoc />
|
|
public Task JoinAsync(string username, CancellationToken ct) => Task.CompletedTask;
|
|
|
|
/// <inheritdoc />
|
|
public Task LeaveAsync(string dialogId, CancellationToken ct) => Task.CompletedTask;
|
|
}
|