From d296beb8df50d881bf4c05fb5a09db331cc374be Mon Sep 17 00:00:00 2001 From: Ephraim Kunz Date: Fri, 20 Sep 2024 12:01:14 -0600 Subject: [PATCH] Fix bug where messages didn't send because recipients weren't strings --- StudentOutreach/Models/CanvasTypes.swift | 2 +- StudentOutreach/Models/Networking.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/StudentOutreach/Models/CanvasTypes.swift b/StudentOutreach/Models/CanvasTypes.swift index 89ff911..0201b6a 100644 --- a/StudentOutreach/Models/CanvasTypes.swift +++ b/StudentOutreach/Models/CanvasTypes.swift @@ -64,7 +64,7 @@ struct Assignment: Decodable, Identifiable, Hashable { } struct PostMessageData: Encodable { - let recipients: [Int] + let recipients: [String] let subject: String let body: String let contextCode: String diff --git a/StudentOutreach/Models/Networking.swift b/StudentOutreach/Models/Networking.swift index 60e25f9..293e9ce 100644 --- a/StudentOutreach/Models/Networking.swift +++ b/StudentOutreach/Models/Networking.swift @@ -163,7 +163,7 @@ struct Networking { request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField:"Content-Type"); - let postData = PostMessageData(recipients: recipients.map({ $0.id }), subject: subject, body: body, contextCode: contextCode) + let postData = PostMessageData(recipients: recipients.map({ String($0.id) }), subject: subject, body: body, contextCode: contextCode) do { let data = try encoder.encode(postData); @@ -187,7 +187,7 @@ struct Networking { request.httpMethod = "POST" request.setValue("application/json", forHTTPHeaderField:"Content-Type"); - let postData = PostMessageData(recipients: [recipient.id], subject: subject, body: body, contextCode: contextCode) + let postData = PostMessageData(recipients: [String(recipient.id)], subject: subject, body: body, contextCode: contextCode) do { let data = try encoder.encode(postData);