Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for receiving SMS/MMS messages #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/com/github/sheigutn/pushbullet/Pushbullet.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ public class Pushbullet implements Pushable {
.registerSubtype(ClipEphemeral.class, "clip")
.registerSubtype(DismissalEphemeral.class, "dismissal")
.registerSubtype(NotificationEphemeral.class, "mirror")
.registerSubtype(SmsReplyEphemeral.class, "message_extension_reply"))
.registerSubtype(SmsReplyEphemeral.class, "message_extension_reply")
.registerSubtype(SmsChangedEphemeral.class, "sms_changed"))
.registerTypeAdapterFactory(
RuntimeTypeAdapterFactory.of(SmsNotification.class)
)
.registerTypeAdapterFactory(new EphemeralEncryptionHandler(this))
.create();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public enum EphemeralType {
@SerializedName("messaging_extension_reply")
SMS_REPLY,

@SerializedName("sms_changed")
SMS_CHANGED,

/**
* Used for universal copy paste
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.github.sheigutn.pushbullet.ephemeral;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;

@Accessors(chain = true)
@Data
@ToString(callSuper = true)
public
class SmsChangedEphemeral extends Ephemeral
{

public
SmsChangedEphemeral()
{
setType(EphemeralType.SMS_CHANGED);
}

/**
* The identity of the originating device
*/
@SerializedName("source_device_iden")
private String sourceDeviceIdentity;

/**
* An array of SMS messages.
*/
private SmsNotification[] notifications;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.github.sheigutn.pushbullet.ephemeral;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.experimental.Accessors;

/**
* Note, the originating phone number is not always available through the pushbullet API.
*/
@Accessors(chain = true)
@Data
public
class SmsNotification
{
@SerializedName("thread_id")
private String threadId;

/**
* The person/company name that sent this text message (if the sender has an entry in the device's
* contacts database), otherwise this is usually the originating phone number (of varying degrees
* of normalization).
*
* e.g. "Hubby"
*/
private String title;

/**
* The actual SMS/text message.
*
* e.g. "Hello"
*/
private String body;

/**
* The unix-time (in seconds from 1970) that this message was received by the remote device.
*
* e.g. 1545606829
*/
private Long timestamp;

}