MCPcopy Create free account
hub / github.com/eleith/emailjs / createMessageStack

Method createMessageStack

src/client.ts:87–134  ·  view source on GitHub ↗
(
		message: Message,
		callback: MessageCallback = function () {
			/* ø */
		}
	)

Source from the content-addressed store, hash-verified

85 }
86
87 public createMessageStack(
88 message: Message,
89 callback: MessageCallback = function () {
90 /* ø */
91 }
92 ) {
93 const [{ address: from }] = addressparser(message.header.from)
94 const stack = {
95 message,
96 to: [] as ReturnType<typeof addressparser>,
97 from,
98 callback: callback.bind(this),
99 } as MessageStack
100
101 const {
102 header: { to, cc, bcc, 'return-path': returnPath },
103 } = message
104
105 if ((typeof to === 'string' || Array.isArray(to)) && to.length > 0) {
106 stack.to = addressparser(to)
107 }
108
109 if ((typeof cc === 'string' || Array.isArray(cc)) && cc.length > 0) {
110 stack.to = stack.to.concat(
111 addressparser(cc).filter(
112 (x) => stack.to.some((y) => y.address === x.address) === false
113 )
114 )
115 }
116
117 if ((typeof bcc === 'string' || Array.isArray(bcc)) && bcc.length > 0) {
118 stack.to = stack.to.concat(
119 addressparser(bcc).filter(
120 (x) => stack.to.some((y) => y.address === x.address) === false
121 )
122 )
123 }
124
125 if (typeof returnPath === 'string' && returnPath.length > 0) {
126 const parsedReturnPath = addressparser(returnPath)
127 if (parsedReturnPath.length > 0) {
128 const [{ address: returnPathAddress }] = parsedReturnPath
129 stack.returnPath = returnPathAddress
130 }
131 }
132
133 return stack
134 }
135
136 protected _poll() {
137 if (this.timer != null) {

Callers 3

sendMethod · 0.95
client.test.tsFile · 0.80

Calls 1

addressparserFunction · 0.85

Tested by

no test coverage detected