mirror of
https://github.com/outline/outline.git
synced 2026-11-25 23:24:06 +03:00
40 lines
700 B
TypeScript
40 lines
700 B
TypeScript
import type { Transaction } from "sequelize";
|
|
import { Event, type Group, type User } from "@server/models";
|
|
|
|
type Props = {
|
|
group: Group;
|
|
name: string;
|
|
actor: User;
|
|
ip: string;
|
|
transaction?: Transaction;
|
|
};
|
|
|
|
export default async function groupUpdater({
|
|
group,
|
|
name,
|
|
actor,
|
|
ip,
|
|
transaction,
|
|
}: Props): Promise<Group> {
|
|
group.name = name;
|
|
|
|
if (group.changed()) {
|
|
await group.save({ transaction });
|
|
await Event.create(
|
|
{
|
|
name: "groups.update",
|
|
modelId: group.id,
|
|
teamId: actor.teamId,
|
|
actorId: actor.id,
|
|
data: {
|
|
name: group.name,
|
|
},
|
|
ip,
|
|
},
|
|
{ transaction }
|
|
);
|
|
}
|
|
|
|
return group;
|
|
}
|