mattermost-mobile-upstream/app/products/agents/requester.ts
Christopher Speller 92bf28a4bb
Add conversation-entity support for plugin-agents v2.0 (#9704)
* Add conversation-entity support for mattermost-plugin-agents v2.0

* Align mobile agent post with plugin-agents v2.0 approval flow and fix rendering bugs

* Lint: add blank line before comment in streaming_store test

* Address coderabbitai feedback: scope auto-approval per-tool, harden conversation store, tighten tests

* Self-review cleanup: clear stores on logout, type cleanup, comment trim, test naming

* Fix i18n key ordering in en.json

* Address coderabbitai feedback: anchor selection, REASONING_DONE fallback, decision-state race

* Scope agent stores per-server and move fetch ownership to the action layer

* Drop dead all-server clear helpers; tests use per-server clears
2026-05-25 07:20:07 -07:00

26 lines
845 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {isPostRequester} from '@agents/utils';
import type {ConversationResponse} from '@agents/types';
import type PostModel from '@typings/database/models/servers/post';
interface Params {
post: PostModel | Post;
conversation?: ConversationResponse;
currentUserId?: string;
}
// Loaded conversation is authoritative; otherwise fall back to the legacy
// llm_requester_user_id prop set by older plugins and meeting-summary posts.
export function isConversationRequester({post, conversation, currentUserId}: Params): boolean {
if (!currentUserId) {
return false;
}
if (conversation) {
return conversation.user_id === currentUserId;
}
return isPostRequester(post, currentUserId);
}