mirror of
https://github.com/d0zingcat/alert-message-center.git
synced 2026-05-13 15:09:19 +00:00
@@ -53,6 +53,11 @@ auth.get("/callback", async (c) => {
|
||||
// Exchange code for user access token and user info
|
||||
const userData = await feishuClient.getUserAccessToken(code);
|
||||
|
||||
if (!userData) {
|
||||
logger.error("[Auth] Failed to get user data from code");
|
||||
return c.json({ error: "Failed to get user info from Feishu" }, 500);
|
||||
}
|
||||
|
||||
// Check if user exists, otherwise create
|
||||
let user = await db.query.users.findFirst({
|
||||
where: eq(users.feishuUserId, userData.open_id),
|
||||
|
||||
@@ -8,6 +8,9 @@ export interface UserAccessTokenData {
|
||||
refresh_token: string;
|
||||
refresh_expires_in: number;
|
||||
scope: string;
|
||||
name: string;
|
||||
open_id: string;
|
||||
email?: string;
|
||||
}
|
||||
|
||||
export class FeishuClient {
|
||||
|
||||
@@ -35,30 +35,33 @@ export default function AdminView() {
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setActiveTab("load")}
|
||||
className={`${activeTab === "load"
|
||||
className={`${
|
||||
activeTab === "load"
|
||||
? "border-indigo-500 text-indigo-600"
|
||||
: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||
} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`}
|
||||
} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`}
|
||||
>
|
||||
System Load
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setActiveTab("requests")}
|
||||
className={`${activeTab === "requests"
|
||||
className={`${
|
||||
activeTab === "requests"
|
||||
? "border-indigo-500 text-indigo-600"
|
||||
: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||
} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`}
|
||||
} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`}
|
||||
>
|
||||
Topic Requests
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setActiveTab("topics")}
|
||||
className={`${activeTab === "topics"
|
||||
className={`${
|
||||
activeTab === "topics"
|
||||
? "border-indigo-500 text-indigo-600"
|
||||
: "border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"
|
||||
} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`}
|
||||
} whitespace-nowrap pb-4 px-1 border-b-2 font-medium text-sm`}
|
||||
>
|
||||
All Topics
|
||||
</button>
|
||||
@@ -167,12 +170,13 @@ function TopicsManagement() {
|
||||
</td>
|
||||
<td className="px-6 py-4 whitespace-nowrap">
|
||||
<span
|
||||
className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${topic.status === "approved"
|
||||
className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${
|
||||
topic.status === "approved"
|
||||
? "bg-green-100 text-green-800"
|
||||
: topic.status === "rejected"
|
||||
? "bg-red-100 text-red-800"
|
||||
: "bg-yellow-100 text-yellow-800"
|
||||
}`}
|
||||
}`}
|
||||
>
|
||||
{topic.status}
|
||||
</span>
|
||||
|
||||
@@ -219,20 +219,20 @@ export default function TopicsView() {
|
||||
const updatedSubs = isSubscribed
|
||||
? t.subscriptions.filter((s) => s.userId !== userId)
|
||||
: [
|
||||
...t.subscriptions,
|
||||
{
|
||||
userId,
|
||||
user:
|
||||
users.find((u) => u.id === userId) ||
|
||||
(currentUser
|
||||
? {
|
||||
id: currentUser.id,
|
||||
name: currentUser.name,
|
||||
email: currentUser.email,
|
||||
}
|
||||
: { id: "unknown", name: "Unknown" }),
|
||||
},
|
||||
];
|
||||
...t.subscriptions,
|
||||
{
|
||||
userId,
|
||||
user:
|
||||
users.find((u) => u.id === userId) ||
|
||||
(currentUser
|
||||
? {
|
||||
id: currentUser.id,
|
||||
name: currentUser.name,
|
||||
email: currentUser.email,
|
||||
}
|
||||
: { id: "unknown", name: "Unknown" }),
|
||||
},
|
||||
];
|
||||
return { ...t, subscriptions: updatedSubs };
|
||||
}
|
||||
return t;
|
||||
@@ -244,20 +244,20 @@ export default function TopicsView() {
|
||||
const updatedSubs = isSubscribed
|
||||
? selectedTopic.subscriptions.filter((s) => s.userId !== userId)
|
||||
: [
|
||||
...selectedTopic.subscriptions,
|
||||
{
|
||||
userId,
|
||||
user:
|
||||
users.find((u) => u.id === userId) ||
|
||||
(currentUser
|
||||
? {
|
||||
id: currentUser.id,
|
||||
name: currentUser.name,
|
||||
email: currentUser.email,
|
||||
}
|
||||
: { id: "unknown", name: "Unknown" }),
|
||||
},
|
||||
];
|
||||
...selectedTopic.subscriptions,
|
||||
{
|
||||
userId,
|
||||
user:
|
||||
users.find((u) => u.id === userId) ||
|
||||
(currentUser
|
||||
? {
|
||||
id: currentUser.id,
|
||||
name: currentUser.name,
|
||||
email: currentUser.email,
|
||||
}
|
||||
: { id: "unknown", name: "Unknown" }),
|
||||
},
|
||||
];
|
||||
setSelectedTopic({ ...selectedTopic, subscriptions: updatedSubs });
|
||||
}
|
||||
|
||||
@@ -429,10 +429,11 @@ export default function TopicsView() {
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleSelfSubscribe(topic)}
|
||||
className={`inline-flex items-center px-3 py-1 border text-xs font-medium rounded-md ${isSubscribedToTopic(topic)
|
||||
className={`inline-flex items-center px-3 py-1 border text-xs font-medium rounded-md ${
|
||||
isSubscribedToTopic(topic)
|
||||
? "border-red-300 text-red-700 bg-red-50 hover:bg-red-100"
|
||||
: "border-green-300 text-green-700 bg-green-50 hover:bg-green-100"
|
||||
}`}
|
||||
}`}
|
||||
>
|
||||
{isSubscribedToTopic(topic) ? (
|
||||
<>
|
||||
@@ -584,12 +585,13 @@ export default function TopicsView() {
|
||||
</p>
|
||||
<div className="flex items-center">
|
||||
<span
|
||||
className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${req.status === "approved"
|
||||
className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${
|
||||
req.status === "approved"
|
||||
? "bg-green-100 text-green-800"
|
||||
: req.status === "rejected"
|
||||
? "bg-red-100 text-red-800"
|
||||
: "bg-yellow-100 text-yellow-800"
|
||||
}`}
|
||||
}`}
|
||||
>
|
||||
{req.status === "approved"
|
||||
? "Approved"
|
||||
@@ -688,10 +690,11 @@ export default function TopicsView() {
|
||||
</div>
|
||||
{submitStatus && (
|
||||
<div
|
||||
className={`p-3 rounded-md text-sm ${submitStatus.type === "success"
|
||||
className={`p-3 rounded-md text-sm ${
|
||||
submitStatus.type === "success"
|
||||
? "bg-green-50 text-green-800"
|
||||
: "bg-red-50 text-red-800"
|
||||
}`}
|
||||
}`}
|
||||
>
|
||||
{submitStatus.message}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user