Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 846edb7

Browse files
Sam1301timabbott
authored andcommitted
Add UpdateMessageWrapper class to catch update message events.
1 parent ec940d4 commit 846edb7

File tree

3 files changed

+85
-1
lines changed

3 files changed

+85
-1
lines changed

app/src/main/java/com/zulip/android/networking/AsyncGetEvents.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ public Message convert(MessageWrapper messageWrapper) {
348348
+ " realm event");
349349
processMessageEditParam(messageTimeLimit);
350350
}
351+
352+
// update message
353+
// TODO: handle update message event
351354
}
352355

353356
/**

app/src/main/java/com/zulip/android/networking/response/events/EventsBranch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public enum BranchType {
2626
PRESENCE(PresenceWrapper.class, "presence"),
2727
SUBSCRIPTIONS(SubscriptionWrapper.class, "subscription"),
2828
MUTED_TOPICS(MutedTopicsWrapper.class, "muted_topics"),
29-
EDIT_MESSAGE_TIME_LIMIT(EditMessageWrapper.class, "realm");
29+
EDIT_MESSAGE_TIME_LIMIT(EditMessageWrapper.class, "realm"),
30+
UPDATE_MESSAGE(UpdateMessageWrapper.class, "update_message");
3031

3132

3233
private final Class<? extends EventsBranch> klazz;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.zulip.android.networking.response.events;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import com.j256.ormlite.dao.Dao;
5+
import com.zulip.android.ZulipApp;
6+
import com.zulip.android.models.Message;
7+
import com.zulip.android.util.ZLog;
8+
9+
import java.sql.Date;
10+
import java.sql.SQLException;
11+
import java.util.List;
12+
13+
/**
14+
* TODO: Add description
15+
* example: {"rendered_content":"<p>(deleted</p>","sender":"[email protected]",
16+
* "edit_timestamp":1485954038,"orig_content":"(deleted)","message_ids":[142650],
17+
* "content":"(deleted","orig_rendered_content":"<p>(deleted)</p>","flags":["read"],"id":31,
18+
* "type":"update_message","message_id":142650}
19+
*/
20+
21+
public class UpdateMessageWrapper extends EventsBranch {
22+
@SerializedName("rendered_content")
23+
private String formattedContent;
24+
25+
@SerializedName("sender")
26+
private String senderEmail;
27+
28+
@SerializedName("edit_timestamp")
29+
private Date editedTimeStamp;
30+
31+
@SerializedName("orig_content")
32+
private String origContent;
33+
34+
@SerializedName("message_ids")
35+
private List<Integer> messageIds;
36+
37+
@SerializedName("content")
38+
private String content;
39+
40+
@SerializedName("orig_rendered_content")
41+
private String origFormattedContent;
42+
43+
@SerializedName("flags")
44+
private List<?> flags;
45+
46+
@SerializedName("message_id")
47+
private int messageId;
48+
49+
/**
50+
* Returns old form of edited message.
51+
*
52+
* @return {@link Message} message
53+
*/
54+
public Message getMessage() {
55+
try {
56+
Dao<Message, Integer> messageDao = ZulipApp.get().getDao(Message.class);
57+
return messageDao.queryBuilder().where().eq(Message.ID_FIELD, this.messageId).queryForFirst();
58+
} catch (SQLException e) {
59+
ZLog.logException(e);
60+
}
61+
62+
return null;
63+
}
64+
65+
public String getContent() {
66+
return this.content;
67+
}
68+
69+
public void setContent(String content) {
70+
this.content = content;
71+
}
72+
73+
public String getFormattedContent() {
74+
return this.formattedContent;
75+
}
76+
77+
public void setFormattedContent(String formattedContent) {
78+
this.formattedContent = formattedContent;
79+
}
80+
}

0 commit comments

Comments
 (0)