1
1
// file object params used, but not required - see https://github.com/qertis/telegram-bot-express
2
2
const fromUnixTime = require ( 'date-fns/fromUnixTime' ) ;
3
3
4
+ const getFullName = ( x ) => {
5
+ return ( x . first_name + ' ' + ( x . last_name ?? '' ) ) . trimEnd ( )
6
+ }
7
+
4
8
const person = ( x ) => ( {
5
9
type : 'Person' ,
6
- name : ( x . first_name + ' ' + ( x . last_name ?? '' ) ) . trimEnd ( ) ,
10
+ name : getFullName ( x ) ,
7
11
id : String ( x . id ) ,
8
12
} ) ;
9
13
@@ -26,7 +30,7 @@ const group = (x) => ({
26
30
27
31
const profile = ( x ) => ( {
28
32
type : 'Profile' ,
29
- name : x . contact . first_name + ' ' + x . contact . last_name ,
33
+ name : getFullName ( x . contact ) ,
30
34
id : String ( x . contact . user_id ) ,
31
35
to : x . contact . phone_number ? `tel:+${ x . contact . phone_number } ` : null ,
32
36
} ) ;
@@ -182,9 +186,10 @@ function time(date) {
182
186
183
187
module . exports = ( message ) => {
184
188
const now = Math . round ( new Date ( ) . getTime ( ) / 1000 )
189
+ const context = 'https://www.w3.org/ns/activitystreams'
185
190
if ( message . channel_post ) {
186
191
return {
187
- '@context' : 'https://www.w3.org/ns/activitystreams' ,
192
+ '@context' : context ,
188
193
type : 'Activity' ,
189
194
instrument : instrument ( message ) ,
190
195
object : objects ( message . channel_post ) ,
@@ -195,7 +200,7 @@ module.exports = (message) => {
195
200
}
196
201
} else if ( message . sender_chat ) {
197
202
return {
198
- '@context' : 'https://www.w3.org/ns/activitystreams' ,
203
+ '@context' : context ,
199
204
type : 'Activity' ,
200
205
instrument : instrument ( message ) ,
201
206
object : objects ( message ) ,
@@ -207,7 +212,7 @@ module.exports = (message) => {
207
212
}
208
213
209
214
return {
210
- '@context' : 'https://www.w3.org/ns/activitystreams' ,
215
+ '@context' : context ,
211
216
type : 'Activity' ,
212
217
summary : message . type ,
213
218
instrument : instrument ( message ) ,
0 commit comments