From f72059f3757d10149f9c4ab89e84c7bc78b9af49 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 7 Jul 2026 05:19:20 +0000 Subject: [PATCH 1/2] Code are generated by openapi generator --- line-bot-webhook/.openapi-generator/FILES | 1 + .../com/linecorp/bot/webhook/model/Event.java | 1 + .../bot/webhook/model/MessageEditedEvent.java | 105 ++++++++++++++++++ line-openapi | 2 +- 4 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/MessageEditedEvent.java diff --git a/line-bot-webhook/.openapi-generator/FILES b/line-bot-webhook/.openapi-generator/FILES index ef04f4987..32551e7d6 100644 --- a/line-bot-webhook/.openapi-generator/FILES +++ b/line-bot-webhook/.openapi-generator/FILES @@ -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 diff --git a/line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/Event.java b/line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/Event.java index 948c97588..ff11be7a0 100644 --- a/line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/Event.java +++ b/line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/Event.java @@ -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"), diff --git a/line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/MessageEditedEvent.java b/line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/MessageEditedEvent.java new file mode 100644 index 000000000..65b8717fd --- /dev/null +++ b/line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/MessageEditedEvent.java @@ -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 + * Documentation + */ +@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); + } + } +} diff --git a/line-openapi b/line-openapi index 6e4c2a2a1..99df56b76 160000 --- a/line-openapi +++ b/line-openapi @@ -1 +1 @@ -Subproject commit 6e4c2a2a1b7b059ea3920456d4f88d03fd8ef0bb +Subproject commit 99df56b76bf1b8a8268456fa36c2d1538b4c086c From dc88bbc09af106e2570fab9b1ad75bf8f06738a2 Mon Sep 17 00:00:00 2001 From: habara keigo Date: Tue, 7 Jul 2026 14:32:40 +0900 Subject: [PATCH 2/2] Add tests --- .../webhook/model/CallbackRequestTest.java | 34 +++++++++++++++++++ .../resources/callback/message-edited.json | 25 ++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 line-bot-webhook/src/test/resources/callback/message-edited.json diff --git a/line-bot-webhook/src/test/java/com/linecorp/bot/webhook/model/CallbackRequestTest.java b/line-bot-webhook/src/test/java/com/linecorp/bot/webhook/model/CallbackRequestTest.java index 7afe5eeae..d543532d4 100644 --- a/line-bot-webhook/src/test/java/com/linecorp/bot/webhook/model/CallbackRequestTest.java +++ b/line-bot-webhook/src/test/java/com/linecorp/bot/webhook/model/CallbackRequestTest.java @@ -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 -> { diff --git a/line-bot-webhook/src/test/resources/callback/message-edited.json b/line-bot-webhook/src/test/resources/callback/message-edited.json new file mode 100644 index 000000000..3e5398a03 --- /dev/null +++ b/line-bot-webhook/src/test/resources/callback/message-edited.json @@ -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" + } + } + ] +}