mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 19:15:08 +03:00
Remove the user fetch endpoint
This commit is contained in:
@@ -5,7 +5,7 @@ import { request } from "@/core/websocket";
|
|||||||
import type { DmEnvelope, User } from "@/core/types";
|
import type { DmEnvelope, User } from "@/core/types";
|
||||||
import { ub64 } from "@/utils/utils";
|
import { ub64 } from "@/utils/utils";
|
||||||
import { fetchUserPublicKey } from "../crypto/identity";
|
import { fetchUserPublicKey } from "../crypto/identity";
|
||||||
import { fetchUsers, searchUsers } from "../user/search";
|
import { searchUsers } from "../user/search";
|
||||||
import { deriveWrappingKey, importAesGcmKey, aesGcmDecrypt } from "@fromchat/protocol";
|
import { deriveWrappingKey, importAesGcmKey, aesGcmDecrypt } from "@fromchat/protocol";
|
||||||
import tweetnacl from "tweetnacl";
|
import tweetnacl from "tweetnacl";
|
||||||
|
|
||||||
@@ -320,4 +320,4 @@ export async function editMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-export user functions for convenience
|
// Re-export user functions for convenience
|
||||||
export { fetchUsers, searchUsers, fetchUserPublicKey };
|
export { searchUsers, fetchUserPublicKey };
|
||||||
@@ -3,7 +3,7 @@ import { getAuthHeaders } from "./account";
|
|||||||
import { request } from "@/core/websocket";
|
import { request } from "@/core/websocket";
|
||||||
import type { DmEnvelope, User } from "@/core/types";
|
import type { DmEnvelope, User } from "@/core/types";
|
||||||
import { fetchUserPublicKey } from "./crypto";
|
import { fetchUserPublicKey } from "./crypto";
|
||||||
import { fetchUsers, searchUsers } from "./users";
|
import { searchUsers } from "./users";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypt a DM envelope using client-side MEK unwrapping.
|
* Decrypt a DM envelope using client-side MEK unwrapping.
|
||||||
@@ -25,7 +25,7 @@ export async function fetchDMHistory(userId: number, token: string, limit: numbe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-export user functions for convenience
|
// Re-export user functions for convenience
|
||||||
export { fetchUsers, searchUsers, fetchUserPublicKey };
|
export { searchUsers, fetchUserPublicKey };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send DM via WebSocket using transport encryption.
|
* Send DM via WebSocket using transport encryption.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { getAuthHeaders } from "./account";
|
|||||||
import { request } from "@/core/websocket";
|
import { request } from "@/core/websocket";
|
||||||
import type { DmEnvelope, User } from "@/core/types";
|
import type { DmEnvelope, User } from "@/core/types";
|
||||||
import { fetchUserPublicKey } from "./crypto";
|
import { fetchUserPublicKey } from "./crypto";
|
||||||
import { fetchUsers, searchUsers } from "./users";
|
import { searchUsers } from "./users";
|
||||||
|
|
||||||
export async function decryptDm(envelope: DmEnvelope): Promise<string> {
|
export async function decryptDm(envelope: DmEnvelope): Promise<string> {
|
||||||
const { decrypt } = await import("./chats/dm");
|
const { decrypt } = await import("./chats/dm");
|
||||||
@@ -20,7 +20,7 @@ export async function fetchDMHistory(userId: number, token: string, limit: numbe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-export user functions for convenience
|
// Re-export user functions for convenience
|
||||||
export { fetchUsers, searchUsers, fetchUserPublicKey };
|
export { searchUsers, fetchUserPublicKey };
|
||||||
|
|
||||||
export async function sendDMViaWebSocket(recipientId: number, recipientPublicKeyB64: string, plaintext: string, authToken: string, replyToId?: number): Promise<void> {
|
export async function sendDMViaWebSocket(recipientId: number, recipientPublicKeyB64: string, plaintext: string, authToken: string, replyToId?: number): Promise<void> {
|
||||||
const { send } = await import("./chats/dm");
|
const { send } = await import("./chats/dm");
|
||||||
|
|||||||
@@ -2,16 +2,6 @@ import { API_BASE_URL } from "@/core/config";
|
|||||||
import { getAuthHeaders } from "./auth";
|
import { getAuthHeaders } from "./auth";
|
||||||
import type { User } from "@/core/types";
|
import type { User } from "@/core/types";
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches a list of all users (excluding current user)
|
|
||||||
*/
|
|
||||||
export async function fetchUsers(token: string): Promise<User[]> {
|
|
||||||
const res = await fetch(`${API_BASE_URL}/users`, { headers: getAuthHeaders(token, true) });
|
|
||||||
if (!res.ok) return [];
|
|
||||||
const data = await res.json();
|
|
||||||
return data.users || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for users by username query
|
* Searches for users by username query
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2,16 +2,6 @@ import { API_BASE_URL } from "@/core/config";
|
|||||||
import { getAuthHeaders } from "./account";
|
import { getAuthHeaders } from "./account";
|
||||||
import type { User } from "@/core/types";
|
import type { User } from "@/core/types";
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches a list of all users (excluding current user)
|
|
||||||
*/
|
|
||||||
export async function fetchUsers(token: string): Promise<User[]> {
|
|
||||||
const res = await fetch(`${API_BASE_URL}/users`, { headers: getAuthHeaders(token, true) });
|
|
||||||
if (!res.ok) return [];
|
|
||||||
const data = await res.json();
|
|
||||||
return data.users || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Searches for users by username query
|
* Searches for users by username query
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user