Skip to content

Commit 77cc1b3

Browse files
committed
Apply code review fixes
1 parent ef1be86 commit 77cc1b3

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

android/app/src/main/java/com/httpsms/Constants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ class Constants {
1919

2020
const val TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'000000'ZZZZZ"
2121

22-
const val MAX_MMS_ATTACHMENT_SIZE = 1.5 * 1024 * 1024;
22+
const val MAX_MMS_ATTACHMENT_SIZE: Long = (3L * 1024 * 1024) / 2
2323
}
2424
}

android/app/src/main/java/com/httpsms/HttpSmsApiService.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
185185
return bytesCopied
186186
}
187187

188-
// Downloads the attachment URL content locally
189188
fun downloadAttachment(context: Context, urlString: String, messageId: String, attachmentIndex: Int): Pair<File?, MediaType?> {
190189
val request = Request.Builder().url(urlString).build()
191190

@@ -216,7 +215,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
216215
}
217216
}
218217

219-
return Pair(tempFile, response.body.contentType())
218+
return Pair(tempFile, body.contentType())
220219
}
221220
} catch (e: Exception) {
222221
Timber.e(e, "Exception while downloading attachment")
@@ -253,7 +252,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
253252
}
254253

255254
if (!response.isSuccessful) {
256-
Timber.e("error response [${response.body?.string()}] with code [${response.code}] while sending [${event}] event [${body}] for message with ID [${messageId}]")
255+
Timber.e("error response [${response.body.string()}] with code [${response.code}] while sending [${event}] event [${body}] for message with ID [${messageId}]")
257256
response.close()
258257
return false
259258
}

api/pkg/requests/bulk_message_request.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ func (input *BulkMessage) ToMessageSendParams(userID entities.UserID, requestID
5050
RequestReceivedAt: time.Now().UTC(),
5151
Contact: input.sanitizeAddress(input.ToPhoneNumber),
5252
Content: input.Content,
53-
Attachments: strings.Split(input.AttachmentURLs, ","),
53+
Attachments: input.removeEmptyStrings(strings.Split(input.AttachmentURLs, ",")),
5454
}
5555
}

api/pkg/requests/request.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ func (input *request) removeStringDuplicates(values []string) []string {
108108
return result
109109
}
110110

111+
func (input *request) removeEmptyStrings(values []string) []string {
112+
var result []string
113+
for _, value := range values {
114+
value = strings.TrimSpace(value)
115+
if value != "" {
116+
result = append(result, value)
117+
}
118+
}
119+
120+
return result
121+
}
122+
111123
func (input *request) sanitizeMessageID(value string) string {
112124
id := strings.Builder{}
113125
for _, char := range value {

api/pkg/validators/validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func init() {
9494
govalidator.AddCustomRule(multipleAttachmentURLRule, func(field string, rule string, message string, value interface{}) error {
9595
attachments, ok := value.([]string)
9696
if !ok {
97-
return fmt.Errorf("The %s field must be an array of valid attachment URL's", field)
97+
return fmt.Errorf("The %s field must be an array of valid attachment URLs", field)
9898
}
9999

100100
for index, attachment := range attachments {

web/pages/threads/_id/index.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,15 @@
173173
>
174174
</v-card-text>
175175
</v-card>
176-
<v-card rounded v-if="message.attachments?.length">
176+
<v-card v-if="message.attachments?.length">
177177
<v-card-text class="pb-2">
178178
<a
179179
v-for="(attachment, index) in message.attachments"
180+
:key="index"
180181
target="_blank"
182+
rel="noopener noreferrer"
181183
:href="attachment"
182184
class="text-decoration-none hover:text-decoration-underline body-2 mb-2 d-flex w-full"
183-
:key="index"
184185
>
185186
<v-icon x-small class="text--secondary mt-1">{{
186187
mdiPaperclip

0 commit comments

Comments
 (0)