mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +03:00
fix: include email in mentioned user's hover card
This commit is contained in:
1 parent
0e5aea8194
commit
446a097f90
5 files changed
+22
-11
No files matched your search
@@ -125,6 +125,7 @@ function HoverPreviewDesktop({ element, data, dataLoading, onClose }: Props) {
|
||||
avatarUrl={data.avatarUrl}
|
||||
color={data.color}
|
||||
lastActive={data.lastActive}
|
||||
email={data.email}
|
||||
/>
|
||||
) : data.type === UnfurlResourceType.Document ? (
|
||||
<HoverPreviewDocument
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Preview, Title, Info, Card, CardContent } from "./Components";
|
||||
type Props = Omit<UnfurlResponse[UnfurlResourceType.Mention], "type">;
|
||||
|
||||
const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention(
|
||||
{ avatarUrl, name, lastActive, color }: Props,
|
||||
{ avatarUrl, name, lastActive, color, email }: Props,
|
||||
ref: React.Ref<HTMLDivElement>
|
||||
) {
|
||||
return (
|
||||
@@ -24,7 +24,7 @@ const HoverPreviewMention = React.forwardRef(function _HoverPreviewMention(
|
||||
size={AvatarSize.XLarge}
|
||||
/>
|
||||
<Flex column gap={2} justify="center">
|
||||
<Title>{name}</Title>
|
||||
<Title>{`${name}(${email})`}</Title>
|
||||
<Info>{lastActive}</Info>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
@@ -6,10 +6,13 @@ import { Document, User, View } from "@server/models";
|
||||
import { opts } from "@server/utils/i18n";
|
||||
import { GitHubUtils } from "plugins/github/shared/GitHubUtils";
|
||||
|
||||
async function presentUnfurl(data: Record<string, any>) {
|
||||
async function presentUnfurl(
|
||||
data: Record<string, any>,
|
||||
options?: { includeEmail: boolean }
|
||||
) {
|
||||
switch (data.type) {
|
||||
case UnfurlResourceType.Mention:
|
||||
return presentMention(data);
|
||||
return presentMention(data, options);
|
||||
case UnfurlResourceType.Document:
|
||||
return presentDocument(data);
|
||||
case UnfurlResourceType.PR:
|
||||
@@ -32,7 +35,8 @@ const presentOEmbed = (
|
||||
});
|
||||
|
||||
const presentMention = async (
|
||||
data: Record<string, any>
|
||||
data: Record<string, any>,
|
||||
options?: { includeEmail: boolean }
|
||||
): Promise<UnfurlResponse[UnfurlResourceType.Mention]> => {
|
||||
const user: User = data.user;
|
||||
const document: Document = data.document;
|
||||
@@ -43,6 +47,7 @@ const presentMention = async (
|
||||
return {
|
||||
type: UnfurlResourceType.Mention,
|
||||
name: user.name,
|
||||
email: options && options.includeEmail ? user.email : null,
|
||||
avatarUrl: user.avatarUrl,
|
||||
color: user.color,
|
||||
lastActive: `${lastOnlineInfo} • ${lastViewedInfo}`,
|
||||
|
||||
@@ -10,7 +10,7 @@ import auth from "@server/middlewares/authentication";
|
||||
import { rateLimiter } from "@server/middlewares/rateLimiter";
|
||||
import validate from "@server/middlewares/validate";
|
||||
import { Document, Share, Team, User } from "@server/models";
|
||||
import { authorize } from "@server/policies";
|
||||
import { authorize, can } from "@server/policies";
|
||||
import presentUnfurl from "@server/presenters/unfurl";
|
||||
import { APIContext, Unfurl } from "@server/types";
|
||||
import { CacheHelper } from "@server/utils/CacheHelper";
|
||||
@@ -53,11 +53,14 @@ router.post(
|
||||
authorize(actor, "read", user);
|
||||
authorize(actor, "read", document);
|
||||
|
||||
ctx.body = await presentUnfurl({
|
||||
type: UnfurlResourceType.Mention,
|
||||
user,
|
||||
document,
|
||||
});
|
||||
ctx.body = await presentUnfurl(
|
||||
{
|
||||
type: UnfurlResourceType.Mention,
|
||||
user,
|
||||
document,
|
||||
},
|
||||
{ includeEmail: !!can(actor, "readEmail", user) }
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,6 +335,8 @@ export type UnfurlResponse = {
|
||||
type: UnfurlResourceType.Mention;
|
||||
/** Mentioned user's name */
|
||||
name: string;
|
||||
/** Mentioned user's email */
|
||||
email: string | null;
|
||||
/** Mentioned user's avatar URL */
|
||||
avatarUrl: string | null;
|
||||
/** Used to create mentioned user's avatar if no avatar URL provided */
|
||||
|
||||
Reference in new issue
Block a user