@inline-openclaw/inline 0.0.55 → 0.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48463,6 +48463,7 @@ function mapTranslation(translation) {
48463
48463
  }
48464
48464
  function mapChatEntry(params) {
48465
48465
  const dialog = params.dialogByChatId.get(String(params.chat.id));
48466
+ const lastMessage = params.chat.lastMsgId != null ? params.messagesById.get(String(params.chat.lastMsgId)) : undefined;
48466
48467
  const peer = params.chat.peerId?.type;
48467
48468
  let peerUser = null;
48468
48469
  if (peer?.oneofKind === "user") {
@@ -48476,6 +48477,7 @@ function mapChatEntry(params) {
48476
48477
  isPublic: params.chat.isPublic ?? false,
48477
48478
  createdBy: params.chat.createdBy != null ? String(params.chat.createdBy) : null,
48478
48479
  date: params.chat.date != null ? Number(params.chat.date) * 1000 : null,
48480
+ lastMessageDate: lastMessage?.date != null ? Number(lastMessage.date) * 1000 : null,
48479
48481
  unreadCount: dialog?.unreadCount ?? 0,
48480
48482
  archived: Boolean(dialog?.archived),
48481
48483
  pinned: Boolean(dialog?.pinned),
@@ -48484,22 +48486,32 @@ function mapChatEntry(params) {
48484
48486
  id: String(peer.user.userId),
48485
48487
  target: `user:${String(peer.user.userId)}`,
48486
48488
  username: peerUser?.username ?? null,
48487
- name: peerUser ? buildInlineUserDisplayName(peerUser) : null
48489
+ name: peerUser ? buildInlineUserDisplayName(peerUser) : null,
48490
+ bot: peerUser?.bot ?? false
48488
48491
  } : peer?.oneofKind === "chat" ? { kind: "chat", id: String(peer.chat.chatId), target: `chat:${String(peer.chat.chatId)}` } : null
48489
48492
  };
48490
48493
  }
48491
- function normalizeInlineListQuery(query) {
48492
- return query?.trim().toLowerCase() ?? "";
48494
+ function compareInlineChatActivityDesc(left, right) {
48495
+ const activityOrder = (right.lastMessageDate ?? 0) - (left.lastMessageDate ?? 0);
48496
+ if (activityOrder !== 0)
48497
+ return activityOrder;
48498
+ const leftId = BigInt(left.id);
48499
+ const rightId = BigInt(right.id);
48500
+ return rightId > leftId ? 1 : rightId < leftId ? -1 : 0;
48493
48501
  }
48494
- function mapUserPeerEntry(user) {
48502
+ function projectInlinePeer(entry) {
48503
+ if (entry.peer?.kind !== "user")
48504
+ return null;
48495
48505
  return {
48496
- id: String(user.id),
48497
- target: `user:${String(user.id)}`,
48498
- username: user.username ?? null,
48499
- name: buildInlineUserDisplayName(user),
48500
- bot: user.bot ?? false
48506
+ ...entry.peer,
48507
+ chatId: entry.id,
48508
+ chatTarget: entry.target,
48509
+ lastMessageDate: entry.lastMessageDate
48501
48510
  };
48502
48511
  }
48512
+ function normalizeInlineListQuery(query) {
48513
+ return query?.trim().toLowerCase() ?? "";
48514
+ }
48503
48515
  function mapPeerBotCommandGroup(group) {
48504
48516
  const bot = group.bot ?? null;
48505
48517
  const commands = (group.commands ?? []).map((command) => ({
@@ -50356,26 +50368,38 @@ var inlineMessageActions = {
50356
50368
  }
50357
50369
  const dialogByChatId = buildDialogMap(result.getChats.dialogs ?? []);
50358
50370
  const usersById = buildUserMap2(result.getChats.users ?? []);
50359
- const chats = (result.getChats.chats ?? []).map((chat) => mapChatEntry({ chat, dialogByChatId, usersById }));
50360
- const groups = chats.filter((entry) => entry.peer?.kind !== "user");
50361
- const peers = (result.getChats.users ?? []).map((user) => mapUserPeerEntry(user));
50371
+ const messagesById = new Map((result.getChats.messages ?? []).map((message) => [String(message.id), message]));
50372
+ const chats = (result.getChats.chats ?? []).map((chat) => mapChatEntry({ chat, dialogByChatId, usersById, messagesById }));
50362
50373
  const normalizedQuery = normalizeInlineListQuery(query);
50363
50374
  const filteredChats = chats.filter((entry) => matchesInlineListQuery([entry.id, entry.target, entry.title, entry.peer?.kind === "user" ? entry.peer.username ?? "" : "", entry.peer?.kind === "user" ? entry.peer.name ?? "" : ""].join(`
50364
50375
  `), normalizedQuery));
50365
- const filteredGroups = groups.filter((entry) => matchesInlineListQuery([entry.id, entry.target, entry.title].join(`
50376
+ const filteredGroups = filteredChats.filter((entry) => entry.peer?.kind !== "user" && matchesInlineListQuery([entry.id, entry.target, entry.title].join(`
50366
50377
  `), normalizedQuery));
50367
- const filteredPeers = peers.filter((entry) => matchesInlineListQuery([entry.id, entry.target, entry.username ?? "", entry.name ?? ""].join(`
50378
+ const filteredPeerChats = filteredChats.filter((entry) => entry.peer?.kind === "user" && matchesInlineListQuery([
50379
+ entry.id,
50380
+ entry.target,
50381
+ entry.peer.id,
50382
+ entry.peer.target,
50383
+ entry.peer.username ?? "",
50384
+ entry.peer.name ?? ""
50385
+ ].join(`
50368
50386
  `), normalizedQuery));
50387
+ const groupScope = ["groups", "group", "channels", "channel"].includes(scope);
50388
+ const peerScope = ["peers", "peer", "members", "member", "users", "user"].includes(scope);
50389
+ const scopedChats = groupScope ? filteredGroups : peerScope ? filteredPeerChats : filteredChats;
50390
+ const selectedChats = [...scopedChats].sort(compareInlineChatActivityDesc).slice(0, limit);
50391
+ const selectedGroups = selectedChats.filter((entry) => entry.peer?.kind !== "user");
50392
+ const selectedPeers = selectedChats.map(projectInlinePeer).filter((entry) => entry != null);
50369
50393
  return jsonResult(toJsonSafe({
50370
50394
  ok: true,
50371
50395
  scope,
50372
50396
  query: query ?? null,
50373
50397
  count: filteredChats.length,
50374
50398
  groupsCount: filteredGroups.length,
50375
- peersCount: filteredPeers.length,
50376
- chats: scope === "groups" || scope === "group" || scope === "channels" || scope === "channel" ? [] : scope === "peers" || scope === "peer" || scope === "members" || scope === "member" || scope === "users" || scope === "user" ? [] : filteredChats.slice(0, limit),
50377
- groups: scope === "peers" || scope === "peer" || scope === "members" || scope === "member" || scope === "users" || scope === "user" ? [] : filteredGroups.slice(0, limit),
50378
- peers: scope === "groups" || scope === "group" || scope === "channels" || scope === "channel" ? [] : filteredPeers.slice(0, limit)
50399
+ peersCount: filteredPeerChats.length,
50400
+ chats: groupScope || peerScope ? [] : selectedChats,
50401
+ groups: peerScope ? [] : selectedGroups,
50402
+ peers: groupScope ? [] : selectedPeers
50379
50403
  }));
50380
50404
  }
50381
50405
  });
@@ -60248,5 +60272,5 @@ export {
60248
60272
  inlineChannelPlugin
60249
60273
  };
60250
60274
 
60251
- //# debugId=F2598E57ED3C7FDC64756E2164756E21
60275
+ //# debugId=F2D6616CC174522364756E2164756E21
60252
60276
  //# sourceMappingURL=channel-plugin-api.js.map