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

Method fromObject

src/static/js/ChatMessage.ts:17–32  ·  view source on GitHub ↗
(obj: ChatMessage)

Source from the content-addressed store, hash-verified

15 displayName: string|null
16 time: number|null
17 static fromObject(obj: ChatMessage) {
18 // The userId property was renamed to authorId, and userName was renamed to displayName. Accept
19 // the old names in case the db record was written by an older version of Etherpad.
20 obj = Object.assign({}, obj); // Don't mutate the caller's object.
21 if ('userId' in obj && !('authorId' in obj)) { // @ts-ignore
22 obj.authorId = obj.userId;
23 }
24 // @ts-ignore
25 delete obj.userId;
26 if ('userName' in obj && !('displayName' in obj)) { // @ts-ignore
27 obj.displayName = obj.userName;
28 }
29 // @ts-ignore
30 delete obj.userName;
31 return Object.assign(new ChatMessage(), obj);
32 }
33
34 /**
35 * @param {?string} [text] - Initial value of the `text` property.

Callers 3

addMessageFunction · 0.80
getChatMessageMethod · 0.80
handleChatMessageFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected