MCPcopy Index your code
hub / github.com/ether/etherpad / remove

Method remove

src/node/db/Pad.ts:804–863  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

802 }
803
804 async remove() {
805 const padID = this.id;
806 const p = [];
807
808 // kick everyone from this pad
809 padMessageHandler.kickSessionsFromPad(padID);
810
811 // delete all relations - the original code used async.parallel but
812 // none of the operations except getting the group depended on callbacks
813 // so the database operations here are just started and then left to
814 // run to completion
815
816 // is it a group pad? -> delete the entry of this pad in the group
817 if (padID.indexOf('$') >= 0) {
818 // it is a group pad
819 const groupID = padID.substring(0, padID.indexOf('$'));
820 const group = await db.get(`group:${groupID}`);
821
822 // remove the pad entry
823 delete group.pads[padID];
824
825 // set the new value
826 p.push(db.set(`group:${groupID}`, group));
827 }
828
829 // remove the readonly entries
830 p.push(readOnlyManager.getReadOnlyId(padID).then(async (readonlyID: string) => {
831 await db.remove(`readonly2pad:${readonlyID}`);
832 }));
833 p.push(db.remove(`pad2readonly:${padID}`));
834
835 // delete all chat messages
836 // @ts-ignore
837 p.push(timesLimit(this.chatHead + 1, 500, async (i: string) => {
838 await this.db.remove(`pad:${this.id}:chat:${i}`);
839 }));
840
841 // delete all revisions
842 // @ts-ignore
843 p.push(timesLimit(this.head + 1, 500, async (i: string) => {
844 await this.db.remove(`pad:${this.id}:revs:${i}`);
845 }));
846
847 // remove pad from all authors who contributed
848 this.getAllAuthors().forEach((authorId) => {
849 p.push(authorManager.removePad(authorId, padID));
850 });
851
852 // delete the pad entry and delete pad from padManager
853 p.push(padManager.removePad(padID));
854 p.push(padDeletionManager.removeDeletionToken(padID));
855 p.push(hooks.aCallAll('padRemove', {
856 get padID() {
857 pad_utils.warnDeprecated('padRemove padID context property is deprecated; use pad.id instead');
858 return this.pad.id;
859 },
860 pad: this,
861 }));

Callers 15

runner.jsFile · 0.45
helper.jsFile · 0.45
clearTokenFunction · 0.45
closeFunction · 0.45
SessionStore.tsFile · 0.45
cleanUpPadsFunction · 0.45
export_list.tsFile · 0.45

Calls 6

getAllAuthorsMethod · 0.95
timesLimitFunction · 0.85
getMethod · 0.80
pushMethod · 0.80
setMethod · 0.80
removePadMethod · 0.80

Tested by

no test coverage detected