Skip to content

Commit 7165293

Browse files
github-actions[bot]github-actions
andauthored
Support mark as read by token API (#1774)
line/line-openapi#115 ## Support for "Mark as Read" by Token API We have released a new **Mark as Read API** that allows developers to mark a user’s messages as read. Previously, this functionality was available only to partners, but it is now publicly available. When your server receives a user message via Webhook, the `MessageEvent` will include a new field: `markAsReadToken`. By calling the Mark as Read API with this token, all messages in the chat room **up to and including** that message will be marked as read. > **Note:** This feature assumes that your service uses the chat feature through Official Account Manager. > If chat is not enabled, messages from users are automatically marked as read, making this API unnecessary. For more details, please refer to the release note: https://developers.line.biz/en/news/2025/11/05/mark-as-read/ Co-authored-by: github-actions <github-actions@github.com>
1 parent 8ba7553 commit 7165293

File tree

11 files changed

+139
-15
lines changed

11 files changed

+139
-15
lines changed

clients/line-bot-messaging-api-client/.openapi-generator/FILES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ src/main/java/com/linecorp/bot/messaging/model/LocationAction.java
118118
src/main/java/com/linecorp/bot/messaging/model/LocationMessage.java
119119
src/main/java/com/linecorp/bot/messaging/model/LotteryAcquisitionConditionRequest.java
120120
src/main/java/com/linecorp/bot/messaging/model/LotteryAcquisitionConditionResponse.java
121+
src/main/java/com/linecorp/bot/messaging/model/MarkMessagesAsReadByTokenRequest.java
121122
src/main/java/com/linecorp/bot/messaging/model/MarkMessagesAsReadRequest.java
122123
src/main/java/com/linecorp/bot/messaging/model/MembersIdsResponse.java
123124
src/main/java/com/linecorp/bot/messaging/model/Membership.java

clients/line-bot-messaging-api-client/src/main/java/com/linecorp/bot/messaging/client/MessagingApiClient.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import com.linecorp.bot.messaging.model.GroupSummaryResponse;
4040
import com.linecorp.bot.messaging.model.GroupUserProfileResponse;
4141
import com.linecorp.bot.messaging.model.IssueLinkTokenResponse;
42+
import com.linecorp.bot.messaging.model.MarkMessagesAsReadByTokenRequest;
4243
import com.linecorp.bot.messaging.model.MarkMessagesAsReadRequest;
4344
import com.linecorp.bot.messaging.model.MembersIdsResponse;
4445
import com.linecorp.bot.messaging.model.MembershipListResponse;
@@ -630,6 +631,17 @@ CompletableFuture<Result<MessagingApiPagerCouponListResponse>> listCoupon(
630631
CompletableFuture<Result<Void>> markMessagesAsRead(
631632
@Body MarkMessagesAsReadRequest markMessagesAsReadRequest);
632633

634+
/**
635+
* Mark messages from users as read by token
636+
*
637+
* @param markMessagesAsReadByTokenRequest (required)
638+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#mark-as-read">
639+
* Documentation</a>
640+
*/
641+
@POST("/v2/bot/chat/markAsRead")
642+
CompletableFuture<Result<Void>> markMessagesAsReadByToken(
643+
@Body MarkMessagesAsReadByTokenRequest markMessagesAsReadByTokenRequest);
644+
633645
/**
634646
* An API that efficiently sends the same message to multiple user IDs. You can&#39;t send
635647
* messages to group chats or multi-person chats.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2023 LINE Corporation
3+
*
4+
* LINE Corporation licenses this file to you under the Apache License,
5+
* version 2.0 (the "License"); you may not use this file except in compliance
6+
* with the License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
/**
18+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
19+
* https://openapi-generator.tech Do not edit the class manually.
20+
*/
21+
package com.linecorp.bot.messaging.model;
22+
23+
24+
25+
import com.fasterxml.jackson.annotation.JsonInclude;
26+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
27+
import com.fasterxml.jackson.annotation.JsonProperty;
28+
29+
/**
30+
* MarkMessagesAsReadByTokenRequest
31+
*
32+
* @see <a href="https://developers.line.biz/en/reference/messaging-api/#mark-as-read-request-body">
33+
* Documentation</a>
34+
*/
35+
@JsonInclude(Include.NON_NULL)
36+
@javax.annotation.Generated(value = "com.linecorp.bot.codegen.LineJavaCodegenGenerator")
37+
public record MarkMessagesAsReadByTokenRequest(
38+
/** Token used to mark messages as read. */
39+
@JsonProperty("markAsReadToken") String markAsReadToken) {
40+
41+
public static class Builder {
42+
private String markAsReadToken;
43+
44+
public Builder(String markAsReadToken) {
45+
46+
this.markAsReadToken = markAsReadToken;
47+
}
48+
49+
public MarkMessagesAsReadByTokenRequest build() {
50+
return new MarkMessagesAsReadByTokenRequest(markAsReadToken);
51+
}
52+
}
53+
}

line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/AudioMessageContent.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ public record AudioMessageContent(
3737
/** Get contentProvider */
3838
@JsonProperty("contentProvider") ContentProvider contentProvider,
3939
/** Length of audio file (milliseconds) */
40-
@JsonProperty("duration") Long duration)
40+
@JsonProperty("duration") Long duration,
41+
/** Token used to mark the message as read. */
42+
@JsonProperty("markAsReadToken") String markAsReadToken)
4143
implements MessageContent {
4244

4345
public static class Builder {
4446
private String id;
4547
private ContentProvider contentProvider;
4648
private Long duration;
49+
private String markAsReadToken;
4750

4851
public Builder(String id, ContentProvider contentProvider) {
4952

@@ -57,8 +60,13 @@ public Builder duration(Long duration) {
5760
return this;
5861
}
5962

63+
public Builder markAsReadToken(String markAsReadToken) {
64+
this.markAsReadToken = markAsReadToken;
65+
return this;
66+
}
67+
6068
public AudioMessageContent build() {
61-
return new AudioMessageContent(id, contentProvider, duration);
69+
return new AudioMessageContent(id, contentProvider, duration, markAsReadToken);
6270
}
6371
}
6472
}

line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/FileMessageContent.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ public record FileMessageContent(
3737
/** File name */
3838
@JsonProperty("fileName") String fileName,
3939
/** File size in bytes */
40-
@JsonProperty("fileSize") Integer fileSize)
40+
@JsonProperty("fileSize") Integer fileSize,
41+
/** Token used to mark the message as read. */
42+
@JsonProperty("markAsReadToken") String markAsReadToken)
4143
implements MessageContent {
4244

4345
public static class Builder {
4446
private String id;
4547
private String fileName;
4648
private Integer fileSize;
49+
private String markAsReadToken;
4750

4851
public Builder(String id, String fileName, Integer fileSize) {
4952

@@ -54,8 +57,13 @@ public Builder(String id, String fileName, Integer fileSize) {
5457
this.fileSize = fileSize;
5558
}
5659

60+
public Builder markAsReadToken(String markAsReadToken) {
61+
this.markAsReadToken = markAsReadToken;
62+
return this;
63+
}
64+
5765
public FileMessageContent build() {
58-
return new FileMessageContent(id, fileName, fileSize);
66+
return new FileMessageContent(id, fileName, fileSize, markAsReadToken);
5967
}
6068
}
6169
}

line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/ImageMessageContent.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ public record ImageMessageContent(
3939
/** Get imageSet */
4040
@JsonProperty("imageSet") ImageSet imageSet,
4141
/** Quote token to quote this message. */
42-
@JsonProperty("quoteToken") String quoteToken)
42+
@JsonProperty("quoteToken") String quoteToken,
43+
/** Token used to mark the message as read. */
44+
@JsonProperty("markAsReadToken") String markAsReadToken)
4345
implements MessageContent {
4446

4547
public static class Builder {
4648
private String id;
4749
private ContentProvider contentProvider;
4850
private ImageSet imageSet;
4951
private String quoteToken;
52+
private String markAsReadToken;
5053

5154
public Builder(String id, ContentProvider contentProvider, String quoteToken) {
5255

@@ -62,8 +65,13 @@ public Builder imageSet(ImageSet imageSet) {
6265
return this;
6366
}
6467

68+
public Builder markAsReadToken(String markAsReadToken) {
69+
this.markAsReadToken = markAsReadToken;
70+
return this;
71+
}
72+
6573
public ImageMessageContent build() {
66-
return new ImageMessageContent(id, contentProvider, imageSet, quoteToken);
74+
return new ImageMessageContent(id, contentProvider, imageSet, quoteToken, markAsReadToken);
6775
}
6876
}
6977
}

line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/LocationMessageContent.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ public record LocationMessageContent(
4141
/** Latitude */
4242
@JsonProperty("latitude") Double latitude,
4343
/** Longitude */
44-
@JsonProperty("longitude") Double longitude)
44+
@JsonProperty("longitude") Double longitude,
45+
/** Token used to mark the message as read. */
46+
@JsonProperty("markAsReadToken") String markAsReadToken)
4547
implements MessageContent {
4648

4749
public static class Builder {
@@ -50,6 +52,7 @@ public static class Builder {
5052
private String address;
5153
private Double latitude;
5254
private Double longitude;
55+
private String markAsReadToken;
5356

5457
public Builder(String id, Double latitude, Double longitude) {
5558

@@ -70,8 +73,13 @@ public Builder address(String address) {
7073
return this;
7174
}
7275

76+
public Builder markAsReadToken(String markAsReadToken) {
77+
this.markAsReadToken = markAsReadToken;
78+
return this;
79+
}
80+
7381
public LocationMessageContent build() {
74-
return new LocationMessageContent(id, title, address, latitude, longitude);
82+
return new LocationMessageContent(id, title, address, latitude, longitude, markAsReadToken);
7583
}
7684
}
7785
}

line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/StickerMessageContent.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public record StickerMessageContent(
6464
* Message ID of a quoted message. Only included when the received message quotes a past
6565
* message.
6666
*/
67-
@JsonProperty("quotedMessageId") String quotedMessageId)
67+
@JsonProperty("quotedMessageId") String quotedMessageId,
68+
/** Token used to mark the message as read. */
69+
@JsonProperty("markAsReadToken") String markAsReadToken)
6870
implements MessageContent {
6971
/** Gets or Sets stickerResourceType */
7072
public enum StickerResourceType {
@@ -102,6 +104,7 @@ public static class Builder {
102104
private String text;
103105
private String quoteToken;
104106
private String quotedMessageId;
107+
private String markAsReadToken;
105108

106109
public Builder(
107110
String id,
@@ -136,6 +139,11 @@ public Builder quotedMessageId(String quotedMessageId) {
136139
return this;
137140
}
138141

142+
public Builder markAsReadToken(String markAsReadToken) {
143+
this.markAsReadToken = markAsReadToken;
144+
return this;
145+
}
146+
139147
public StickerMessageContent build() {
140148
return new StickerMessageContent(
141149
id,
@@ -145,7 +153,8 @@ public StickerMessageContent build() {
145153
keywords,
146154
text,
147155
quoteToken,
148-
quotedMessageId);
156+
quotedMessageId,
157+
markAsReadToken);
149158
}
150159
}
151160
}

line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/TextMessageContent.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public record TextMessageContent(
5050
* Message ID of a quoted message. Only included when the received message quotes a past
5151
* message.
5252
*/
53-
@JsonProperty("quotedMessageId") String quotedMessageId)
53+
@JsonProperty("quotedMessageId") String quotedMessageId,
54+
/** Token used to mark the message as read. */
55+
@JsonProperty("markAsReadToken") String markAsReadToken)
5456
implements MessageContent {
5557

5658
public static class Builder {
@@ -60,6 +62,7 @@ public static class Builder {
6062
private Mention mention;
6163
private String quoteToken;
6264
private String quotedMessageId;
65+
private String markAsReadToken;
6366

6467
public Builder(String id, String text, String quoteToken) {
6568

@@ -85,8 +88,14 @@ public Builder quotedMessageId(String quotedMessageId) {
8588
return this;
8689
}
8790

91+
public Builder markAsReadToken(String markAsReadToken) {
92+
this.markAsReadToken = markAsReadToken;
93+
return this;
94+
}
95+
8896
public TextMessageContent build() {
89-
return new TextMessageContent(id, text, emojis, mention, quoteToken, quotedMessageId);
97+
return new TextMessageContent(
98+
id, text, emojis, mention, quoteToken, quotedMessageId, markAsReadToken);
9099
}
91100
}
92101
}

line-bot-webhook/src/main/java/com/linecorp/bot/webhook/model/VideoMessageContent.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ public record VideoMessageContent(
3939
/** Get contentProvider */
4040
@JsonProperty("contentProvider") ContentProvider contentProvider,
4141
/** Quote token to quote this message. */
42-
@JsonProperty("quoteToken") String quoteToken)
42+
@JsonProperty("quoteToken") String quoteToken,
43+
/** Token used to mark the message as read. */
44+
@JsonProperty("markAsReadToken") String markAsReadToken)
4345
implements MessageContent {
4446

4547
public static class Builder {
4648
private String id;
4749
private Long duration;
4850
private ContentProvider contentProvider;
4951
private String quoteToken;
52+
private String markAsReadToken;
5053

5154
public Builder(String id, ContentProvider contentProvider, String quoteToken) {
5255

@@ -62,8 +65,13 @@ public Builder duration(Long duration) {
6265
return this;
6366
}
6467

68+
public Builder markAsReadToken(String markAsReadToken) {
69+
this.markAsReadToken = markAsReadToken;
70+
return this;
71+
}
72+
6573
public VideoMessageContent build() {
66-
return new VideoMessageContent(id, duration, contentProvider, quoteToken);
74+
return new VideoMessageContent(id, duration, contentProvider, quoteToken, markAsReadToken);
6775
}
6876
}
6977
}

0 commit comments

Comments
 (0)