Skip to content
Merged
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
1 change: 1 addition & 0 deletions line-bot-webhook/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ src/main/java/com/linecorp/bot/webhook/model/MembershipEvent.java
src/main/java/com/linecorp/bot/webhook/model/Mention.java
src/main/java/com/linecorp/bot/webhook/model/Mentionee.java
src/main/java/com/linecorp/bot/webhook/model/MessageContent.java
src/main/java/com/linecorp/bot/webhook/model/MessageEditedEvent.java
src/main/java/com/linecorp/bot/webhook/model/MessageEvent.java
src/main/java/com/linecorp/bot/webhook/model/ModuleContent.java
src/main/java/com/linecorp/bot/webhook/model/ModuleEvent.java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
@JsonSubTypes.Type(value = MemberLeftEvent.class, name = "memberLeft"),
@JsonSubTypes.Type(value = MembershipEvent.class, name = "membership"),
@JsonSubTypes.Type(value = MessageEvent.class, name = "message"),
@JsonSubTypes.Type(value = MessageEditedEvent.class, name = "messageEdited"),
@JsonSubTypes.Type(value = ModuleEvent.class, name = "module"),
@JsonSubTypes.Type(value = PostbackEvent.class, name = "postback"),
@JsonSubTypes.Type(value = UnfollowEvent.class, name = "unfollow"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright 2023 LINE Corporation
*
* LINE Corporation licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/

/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech Do not edit the class manually.
*/
package com.linecorp.bot.webhook.model;



import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;

/**
* Webhook event object which contains the edited message. This event is triggered when a user edits
* a text message. Currently, message editing is not available in one-on-one chats with LINE
* Official Accounts, so this event is only triggered in group chats. Multiple messageEdited webhook
* events may arrive out of order. The event with the largest timestamp represents the latest edit
* state.
*
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#edit-event">
* Documentation</a>
*/
@JsonTypeName("messageEdited")
@JsonInclude(Include.NON_NULL)
@javax.annotation.Generated(value = "com.linecorp.bot.codegen.LineJavaCodegenGenerator")
public record MessageEditedEvent(
/** Get source */
@JsonProperty("source") Source source,
/** Time of the event in milliseconds. */
@JsonProperty("timestamp") Long timestamp,
/** Get mode */
@JsonProperty("mode") EventMode mode,
/**
* Webhook Event ID. An ID that uniquely identifies a webhook event. This is a string in ULID
* format.
*/
@JsonProperty("webhookEventId") String webhookEventId,
/** Get deliveryContext */
@JsonProperty("deliveryContext") DeliveryContext deliveryContext,
/** Get replyToken */
@JsonProperty("replyToken") String replyToken,
/** Get message */
@JsonProperty("message") MessageContent message)
implements Event, ReplyEvent {

public static class Builder {
private Source source;
private Long timestamp;
private EventMode mode;
private String webhookEventId;
private DeliveryContext deliveryContext;
private String replyToken;
private MessageContent message;

public Builder(
Long timestamp,
EventMode mode,
String webhookEventId,
DeliveryContext deliveryContext,
MessageContent message) {

this.timestamp = timestamp;

this.mode = mode;

this.webhookEventId = webhookEventId;

this.deliveryContext = deliveryContext;

this.message = message;
}

public Builder source(Source source) {
this.source = source;
return this;
}

public Builder replyToken(String replyToken) {
this.replyToken = replyToken;
return this;
}

public MessageEditedEvent build() {
return new MessageEditedEvent(
source, timestamp, mode, webhookEventId, deliveryContext, replyToken, message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,40 @@ public void testUnknown() throws IOException {
});
}

@Test
public void testMessageEdited() throws IOException {
parse("callback/message-edited.json", callbackRequest -> {
assertDestination(callbackRequest);
Assertions.assertThat(callbackRequest.events()).hasSize(1);
Event event = callbackRequest.events().get(0);
assertThat(event).isInstanceOf(MessageEditedEvent.class);
Assertions.assertThat(event.source())
.isInstanceOf(GroupSource.class);
Assertions.assertThat(((GroupSource) event.source()).groupId())
.isEqualTo("cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
Assertions.assertThat(event.source().userId())
.isEqualTo("u206d25c2ea6bd87c17655609a1c37cb8");
Assertions.assertThat(event.timestamp())
.isEqualTo(Instant.parse("2016-05-07T13:57:59.859Z").toEpochMilli());
Assertions.assertThat(event.mode())
.isEqualTo(EventMode.ACTIVE);

MessageEditedEvent messageEditedEvent = (MessageEditedEvent) event;
Assertions.assertThat(messageEditedEvent.replyToken())
.isEqualTo("nHuyWiB7yP5Zw52FIkcQobQuGDXCTA");
Assertions.assertThat(messageEditedEvent.webhookEventId())
.isEqualTo("01G2KZKG2DS765NMRH3GZFD8AP");
Assertions.assertThat(messageEditedEvent.deliveryContext().isRedelivery())
.isEqualTo(false);

MessageContent message = messageEditedEvent.message();
assertThat(message).isInstanceOf(TextMessageContent.class);
TextMessageContent textMessage = (TextMessageContent) message;
Assertions.assertThat(textMessage.id()).isEqualTo("325708");
Assertions.assertThat(textMessage.text()).isEqualTo("Hello, edited world");
});
}

@Test
public void testWebhookRedelivery() throws IOException {
parse("callback/webhook-redelivery.json", callbackRequest -> {
Expand Down
25 changes: 25 additions & 0 deletions line-bot-webhook/src/test/resources/callback/message-edited.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"destination": "Uab012345678901234567890123456789",
"events": [
{
"replyToken": "nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
"type": "messageEdited",
"timestamp": 1462629479859,
"mode": "active",
"webhookEventId": "01G2KZKG2DS765NMRH3GZFD8AP",
"deliveryContext": {
"isRedelivery": false
},
"source": {
"type": "group",
"groupId": "cxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"userId": "u206d25c2ea6bd87c17655609a1c37cb8"
},
"message": {
"id": "325708",
"type": "text",
"text": "Hello, edited world"
}
}
]
}
2 changes: 1 addition & 1 deletion line-openapi
Submodule line-openapi updated 1 files
+22 −0 webhook.yml