Skip to content

Commit 1b7deeb

Browse files
authored
feat: Add MMS Text, File and Content message types (#571)
* feat: Add MMS text, file and content types * chore: Bump version * ci: Bump action versions * fix: Validate MMS content types * refactor: MMS content add media methods
1 parent 7401c36 commit 1b7deeb

20 files changed

+710
-37
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
# Initializes the CodeQL tools for scanning.
2929
- name: Initialize CodeQL
30-
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a
30+
uses: github/codeql-action/init@1a7989f3955e0c69f0e0ccc14aee54a387a0fd31
3131
with:
3232
languages: java-kotlin
3333
build-mode: none

.github/workflows/scorecard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
persist-credentials: false
3333

3434
- name: Run analysis
35-
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46
35+
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186
3636
with:
3737
results_file: results.sarif
3838
results_format: sarif
@@ -47,7 +47,7 @@ jobs:
4747
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
4848
# format to the repository Actions tab.
4949
- name: Upload artifact
50-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
50+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1
5151
with:
5252
name: SARIF file
5353
path: results.sarif

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
# [8.18.0] - 2025-03-??
6+
- Added MMS Text, File and Content outbound message types
7+
- Added `getFileName` and `getFileCaption` to `com.vonage.client.messages.InboundMessage`
8+
59
# [8.17.0] - 2025-02-28
610
- Added user/domain name support to `com.vonage.client.voice.ncco.SipEndpoint`
711
- Improved Voice API documentation

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.vonage</groupId>
77
<artifactId>server-sdk</artifactId>
8-
<version>8.17.0</version>
8+
<version>8.18.0</version>
99

1010
<name>Vonage Java Server SDK</name>
1111
<description>Java client for Vonage APIs</description>
@@ -92,7 +92,7 @@
9292
<dependency>
9393
<groupId>org.mockito</groupId>
9494
<artifactId>mockito-core</artifactId>
95-
<version>5.15.2</version>
95+
<version>5.16.0</version>
9696
<scope>test</scope>
9797
</dependency>
9898
<dependency>

src/main/java/com/vonage/client/HttpWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
public class HttpWrapper {
3838
private static final String
3939
CLIENT_NAME = "vonage-java-sdk",
40-
CLIENT_VERSION = "8.17.0",
40+
CLIENT_VERSION = "8.18.0",
4141
JAVA_VERSION = System.getProperty("java.version"),
4242
USER_AGENT = String.format("%s/%s java/%s", CLIENT_NAME, CLIENT_VERSION, JAVA_VERSION);
4343

src/main/java/com/vonage/client/common/MessageType.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@
2424
* @since 8.4.0
2525
*/
2626
public enum MessageType {
27-
TEXT, IMAGE, AUDIO, VIDEO, FILE, VCARD, TEMPLATE, CUSTOM, LOCATION,
28-
STICKER, UNSUPPORTED, REPLY, ORDER, RANDOM, BUTTON, REACTION, CONTACT;
27+
TEXT, IMAGE, AUDIO, VIDEO, FILE, VCARD, TEMPLATE, CUSTOM, LOCATION, STICKER,
28+
UNSUPPORTED, REPLY, ORDER, RANDOM, BUTTON, REACTION, CONTACT, CONTENT;
2929

30+
/**
31+
* Parse a message type from a string.
32+
*
33+
* @param value The message type as a string.
34+
*
35+
* @return The message type as an enum, or {@code null} if the string is null.
36+
* @throws IllegalArgumentException If the string does not match a known message type.
37+
*/
3038
@JsonCreator
3139
public static MessageType fromString(String value) {
3240
if (value == null) return null;

src/main/java/com/vonage/client/messages/Channel.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
public enum Channel {
2929
SMS (TEXT),
30-
MMS (TEXT, IMAGE, VCARD, AUDIO, VIDEO),
30+
MMS (TEXT, IMAGE, VCARD, AUDIO, VIDEO, FILE, CONTENT),
3131
RCS (TEXT, IMAGE, VIDEO, FILE, CUSTOM, AUDIO, LOCATION, VCARD, REPLY, BUTTON),
3232
WHATSAPP (TEXT, IMAGE, AUDIO, VIDEO, FILE, TEMPLATE, CUSTOM, LOCATION,
3333
STICKER, ORDER, REPLY, REACTION, CONTACT, BUTTON, UNSUPPORTED),
@@ -59,13 +59,19 @@ public Set<MessageType> getSupportedOutboundMessageTypes() {
5959
return getSupportedMessageTypes().stream().filter(mt -> mt != MessageType.UNSUPPORTED &&
6060
mt != MessageType.REPLY && mt != MessageType.ORDER &&
6161
mt != MessageType.CONTACT && mt != MessageType.BUTTON &&
62-
(this != Channel.MMS || mt != MessageType.TEXT) &&
63-
(this != Channel.RCS || (
64-
mt != AUDIO && mt != LOCATION && mt != VCARD
65-
))
62+
(this != Channel.RCS || (mt != AUDIO && mt != LOCATION && mt != VCARD))
6663
).collect(Collectors.toSet());
6764
}
6865

66+
/**
67+
* Creates a Channel enum from its string representation.
68+
*
69+
* @param value The string value to convert.
70+
*
71+
* @return The Channel enum that corresponds to the given string, or {@code null} if the string is {@code null}.
72+
*
73+
* @throws IllegalArgumentException If the provided value does not correspond to a known Channel enum.
74+
*/
6975
@JsonCreator
7076
public static Channel fromString(String value) {
7177
if (value == null) return null;

src/main/java/com/vonage/client/messages/InboundMessage.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ public class InboundMessage extends JsonableBaseObject {
4242
protected static class UrlWrapper extends JsonableBaseObject {
4343
@JsonProperty("url") protected URI url;
4444
@JsonProperty("name") protected String name;
45-
}
46-
47-
protected static class UrlWrapperWithCaption extends UrlWrapper {
4845
@JsonProperty("caption") protected String caption;
4946
}
5047

@@ -71,7 +68,7 @@ protected InboundMessage() {}
7168
@JsonProperty("_self") UrlContainer self;
7269

7370
@JsonProperty("text") protected String text;
74-
@JsonProperty("image") protected UrlWrapperWithCaption image;
71+
@JsonProperty("image") protected UrlWrapper image;
7572
@JsonProperty("audio") protected UrlWrapper audio;
7673
@JsonProperty("video") protected UrlWrapper video;
7774
@JsonProperty("file") protected UrlWrapper file;
@@ -199,7 +196,6 @@ public URI getImageUrl() {
199196
* Additional text accompanying the image. Applicable to MMS image messages only.
200197
*
201198
* @return The image caption if present, or {@code null} if not applicable.
202-
*
203199
* @since 8.1.0
204200
*/
205201
@JsonIgnore
@@ -237,6 +233,28 @@ public URI getFileUrl() {
237233
return file != null ? file.url : null;
238234
}
239235

236+
/**
237+
* If {@linkplain #getMessageType()} is {@linkplain MessageType#FILE}, returns the name of the file if available.
238+
*
239+
* @return The file name, or {@code null} if not applicable.
240+
* @since 8.18.0
241+
*/
242+
@JsonIgnore
243+
public String getFileName() {
244+
return file != null ? file.name : null;
245+
}
246+
247+
/**
248+
* If {@linkplain #getMessageType()} is {@linkplain MessageType#FILE}, returns the caption of the file if available.
249+
*
250+
* @return The file caption, or {@code null} if not applicable.
251+
* @since 8.18.0
252+
*/
253+
@JsonIgnore
254+
public String getFileCaption() {
255+
return file != null ? file.caption : null;
256+
}
257+
240258
/**
241259
* If {@linkplain #getMessageType()} is {@linkplain MessageType#VCARD}, returns the URL of the vCard.
242260
*

src/main/java/com/vonage/client/messages/MessageType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
@Deprecated
2727
public enum MessageType {
2828
TEXT, IMAGE, AUDIO, VIDEO, FILE, VCARD, TEMPLATE, CUSTOM, LOCATION,
29-
STICKER, UNSUPPORTED, REPLY, ORDER, CONTACT, BUTTON, REACTION;
29+
STICKER, UNSUPPORTED, REPLY, ORDER, CONTACT, BUTTON, REACTION, CONTENT;
3030

3131
@JsonCreator
3232
public static MessageType fromString(String value) {

src/main/java/com/vonage/client/messages/internal/MessagePayload.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ public class MessagePayload extends JsonableBaseObject {
3232
protected String caption, name;
3333

3434
public MessagePayload(String url) {
35-
this.url = URI.create(Objects.requireNonNull(url, "URL is required."));
35+
if (Objects.requireNonNull(url, "URL is required.").trim().isEmpty()) {
36+
throw new IllegalArgumentException("URL cannot be blank.");
37+
}
38+
this.url = URI.create(url);
3639
}
3740

3841
public MessagePayload(String url, String caption) {

0 commit comments

Comments
 (0)