fix: Invited users should not appear as option in @mention, closes #5006
This commit is contained in:
@@ -34,7 +34,10 @@ function MentionMenu({ search, ...rest }: MentionMenuProps) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { users, auth } = useStores();
|
const { users, auth } = useStores();
|
||||||
const { data, request } = useRequest(
|
const { data, request } = useRequest(
|
||||||
React.useCallback(() => users.fetchPage({ query: search }), [users, search])
|
React.useCallback(
|
||||||
|
() => users.fetchPage({ query: search, filter: "active" }),
|
||||||
|
[users, search]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
import { buildTeam, buildAdmin, buildUser } from "@server/test/factories";
|
import {
|
||||||
|
buildTeam,
|
||||||
|
buildAdmin,
|
||||||
|
buildUser,
|
||||||
|
buildInvite,
|
||||||
|
} from "@server/test/factories";
|
||||||
import { seed, getTestServer } from "@server/test/support";
|
import { seed, getTestServer } from "@server/test/support";
|
||||||
|
|
||||||
const server = getTestServer();
|
const server = getTestServer();
|
||||||
@@ -70,6 +75,26 @@ describe("#users.list", () => {
|
|||||||
expect(body.data.length).toEqual(0);
|
expect(body.data.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should allow filtering to active", async () => {
|
||||||
|
const user = await buildUser({
|
||||||
|
name: "Tester",
|
||||||
|
});
|
||||||
|
await buildInvite({
|
||||||
|
name: "Tester",
|
||||||
|
teamId: user.teamId,
|
||||||
|
});
|
||||||
|
const res = await server.post("/api/users.list", {
|
||||||
|
body: {
|
||||||
|
query: "test",
|
||||||
|
filter: "active",
|
||||||
|
token: user.getJwtToken(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const body = await res.json();
|
||||||
|
expect(res.status).toEqual(200);
|
||||||
|
expect(body.data.length).toEqual(1);
|
||||||
|
});
|
||||||
|
|
||||||
it("should allow filtering to invited", async () => {
|
it("should allow filtering to invited", async () => {
|
||||||
const user = await buildUser({
|
const user = await buildUser({
|
||||||
name: "Tester",
|
name: "Tester",
|
||||||
|
|||||||
@@ -101,6 +101,19 @@ router.post("users.list", auth(), pagination(), async (ctx: APIContext) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "active": {
|
||||||
|
where = {
|
||||||
|
...where,
|
||||||
|
lastActiveAt: {
|
||||||
|
[Op.ne]: null,
|
||||||
|
},
|
||||||
|
suspendedAt: {
|
||||||
|
[Op.is]: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "all": {
|
case "all": {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user