Skip to content

Commit

Permalink
feat: add ReadMessageLINEEvent to handle read message notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
nakasyou committed Jan 3, 2025
1 parent 5896610 commit c20a8bc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/linejs/client/events/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Operation, SquareEvent } from "@evex/linejs-types";
import { MessageSquareLINEEvent, MessageTalkLINEEvent, type MessageLINEEvent } from "./message.ts";
import { UnknownLINEEvent } from "./unknown.ts";
import type { Client } from "../client.ts";
import { ReadMessageLINEEvent } from "./read-message.ts";

export type SourceEvent = {
type: "square";
Expand All @@ -17,14 +18,18 @@ export const wrapEvents = async (source: SourceEvent, client: Client): Promise<L
case "RECEIVE_MESSAGE":
case "SEND_MESSAGE":
return await MessageTalkLINEEvent.fromSource(source, client);
case "NOTIFIED_READ_MESSAGE":
return new ReadMessageLINEEvent(source);
}
} else {
switch (source.event.type) {
case "RECEIVE_MESSAGE":
case "NOTIFICATION_MESSAGE":
return new MessageSquareLINEEvent(source, client);
}
}
return new UnknownLINEEvent(source);
};

export type LINEEvent = MessageLINEEvent | UnknownLINEEvent;
export type LINEEvent = MessageLINEEvent | UnknownLINEEvent | ReadMessageLINEEvent;

19 changes: 19 additions & 0 deletions packages/linejs/client/events/read-message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { SourceEvent } from "./mod.ts";
import { LINEEventBase } from "./shared.ts";

/**
* An event that indicates a message has been read.
*/
export class ReadMessageLINEEvent extends LINEEventBase {
type: "read-message" = "read-message";

/**
* The mid of the user who read the message.
* This is a placeholder property and will be replaced in the future.
*/
readonly readUserMid: string;
constructor(source: SourceEvent & { type: "talk" }) {
super(source);
this.readUserMid = source.event.param1
}
}

0 comments on commit c20a8bc

Please sign in to comment.