The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/models/server/raw/Integrations.ts

43 lines
1.1 KiB

import { BaseRaw, IndexSpecification } from './BaseRaw';
import { IIntegration } from '../../../../definition/IIntegration';
export class IntegrationsRaw extends BaseRaw<IIntegration> {
protected indexes: IndexSpecification[] = [{ key: { type: 1 } }];
findOneByUrl(url: string): Promise<IIntegration | null> {
return this.findOne({ url });
}
updateRoomName(oldRoomName: string, newRoomName: string): ReturnType<BaseRaw<IIntegration>['updateMany']> {
const hashedOldRoomName = `#${oldRoomName}`;
const hashedNewRoomName = `#${newRoomName}`;
return this.updateMany(
{
channel: hashedOldRoomName,
},
{
$set: {
'channel.$': hashedNewRoomName,
},
},
);
}
findOneByIdAndCreatedByIfExists({
_id,
createdBy,
}: {
_id: IIntegration['_id'];
createdBy: IIntegration['_createdBy'];
}): Promise<IIntegration | null> {
return this.findOne({
_id,
...(createdBy && { '_createdBy._id': createdBy }),
});
}
disableByUserId(userId: string): ReturnType<BaseRaw<IIntegration>['updateMany']> {
return this.updateMany({ userId }, { $set: { enabled: false } });
}
}