Skip to content

Commit

Permalink
Get rid of warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bradystroud committed Oct 24, 2023
1 parent 1ee76af commit 9a5f751
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/TimesheetGPT.Core/Models/Email.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace TimesheetGPT.Core.Models;
public class Email
{
public string? Subject { get; set; }
public string Body { get; set; }
public string To { get; set; }
public string? Body { get; set; }
public string? To { get; set; }
public string? Id { get; set; }
}
2 changes: 1 addition & 1 deletion src/TimesheetGPT.Core/Plugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace TimesheetGPT.Core;
public class GraphPlugins(IGraphService graphService)
{
[SKFunction, Description("Get email body from Id")]
public async Task<string> GetEmailBody(string id)
public async Task<string?> GetEmailBody(string id)
{
return (await graphService.GetEmailBody(id)).Body;
}
Expand Down
14 changes: 7 additions & 7 deletions src/TimesheetGPT.Core/Services/GraphService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public async Task<List<Email>> GetSentEmails(DateTime date, CancellationToken ca
return new List<Email>(messages.Value.Select(m => new Email
{
Subject = m.Subject,
Body = m.BodyPreview,
To = string.Join(", ", m.ToRecipients.Select(r => r.EmailAddress.Name).ToList()),
Body = m.BodyPreview ?? "",
To = string.Join(", ", m.ToRecipients?.Select(r => r.EmailAddress?.Name).ToList() ?? new List<string?>()),
Id = m.Id
}));
}
Expand Down Expand Up @@ -70,8 +70,8 @@ public async Task<List<Meeting>> GetMeetings(DateTime date, CancellationToken ca
{
return meetings.Value.Select(m => new Meeting
{
Name = m.Subject,
Length = DateTime.Parse(m.End.DateTime) - DateTime.Parse(m.Start.DateTime),
Name = m.Subject ?? "",
Length = DateTime.Parse(m.End?.DateTime ?? string.Empty) - DateTime.Parse(m.Start?.DateTime ?? string.Empty),
Repeating = m.Type == EventType.Occurrence,
// Sender = m.EmailAddress.Address TODO: Why is Organizer and attendees null? permissions?
}).ToList();
Expand Down Expand Up @@ -99,7 +99,7 @@ public async Task<List<TeamsCall>> GetTeamsCalls(DateTime date)
{
return calls.Value.Select(m => new TeamsCall
{
Attendees = m.Participants.Select(p => p.User.DisplayName).ToList(),
Attendees = m.Participants?.Select(p => p.User?.DisplayName).ToList() ?? new List<string?>(),
Length = m.EndDateTime - m.StartDateTime ?? TimeSpan.Zero,
}).ToList();
}
Expand All @@ -126,7 +126,7 @@ public async Task<Email> GetEmailBody(string id)
return new Email
{
Body = message.BodyPreview,
To = string.Join(", ", message.ToRecipients.Select(r => r.EmailAddress.Name).ToList())
To = string.Join(", ", (message.ToRecipients ?? new List<Recipient>()).Select(r => r.EmailAddress?.Name).ToList())
};
}

Expand All @@ -136,6 +136,6 @@ public async Task<Email> GetEmailBody(string id)

public class TeamsCall
{
public List<string> Attendees { get; set; }
public List<string?>? Attendees { get; set; }
public TimeSpan Length { get; set; }
}

0 comments on commit 9a5f751

Please sign in to comment.