Add support for custom names for aliases. Synchronization of names for the gmail api. (#365)

This commit is contained in:
Burak Kaan Köse
2024-09-12 01:14:40 +02:00
committed by GitHub
parent 310943590b
commit f85085de41
4 changed files with 16 additions and 2 deletions

View File

@@ -33,6 +33,13 @@ namespace Wino.Core.Domain.Entities
/// It can't be deleted or changed.
/// </summary>
public bool IsRootAlias { get; set; }
/// <summary>
/// Optional sender name for the alias.
/// Falls back to account's sender name if not set when preparing messages.
/// Used for Gmail only.
/// </summary>
public string AliasSenderName { get; set; }
}
public class MailAccountAlias : RemoteAccountAlias

View File

@@ -210,6 +210,7 @@ namespace Wino.Core.Extensions
IsRootAlias = a.IsDefault.GetValueOrDefault(),
IsPrimary = a.IsPrimary.GetValueOrDefault(),
ReplyToAddress = a.ReplyToAddress,
AliasSenderName = a.DisplayName,
IsVerified = a.VerificationStatus == "accepted" || a.IsDefault.GetValueOrDefault(),
}).ToList();
}

View File

@@ -412,7 +412,8 @@ namespace Wino.Core.Services
IsVerified = remoteAlias.IsVerified,
ReplyToAddress = remoteAlias.ReplyToAddress,
Id = Guid.NewGuid(),
IsRootAlias = remoteAlias.IsRootAlias
IsRootAlias = remoteAlias.IsRootAlias,
AliasSenderName = remoteAlias.AliasSenderName
};
await Connection.InsertAsync(newAlias);
@@ -424,6 +425,7 @@ namespace Wino.Core.Services
existingAlias.IsPrimary = remoteAlias.IsPrimary;
existingAlias.IsVerified = remoteAlias.IsVerified;
existingAlias.ReplyToAddress = remoteAlias.ReplyToAddress;
existingAlias.AliasSenderName = remoteAlias.AliasSenderName;
await Connection.UpdateAsync(existingAlias);
}

View File

@@ -449,7 +449,11 @@ namespace Wino.Mail.ViewModels
if (SelectedAlias == null) return;
CurrentMimeMessage.From.Clear();
CurrentMimeMessage.From.Add(new MailboxAddress(ComposingAccount.SenderName, SelectedAlias.AliasAddress));
// Try to get the sender name from the alias. If not, fallback to account sender name.
var senderName = SelectedAlias.AliasSenderName ?? ComposingAccount.SenderName;
CurrentMimeMessage.From.Add(new MailboxAddress(senderName, SelectedAlias.AliasAddress));
}
private void SaveReplyToAddress()