MCPcopy Create free account
hub / github.com/Treeki/BirdBridge / activityToNotification

Function activityToNotification

conversion.ts:403–434  ·  view source on GitHub ↗
(activity: Record<string, any>)

Source from the content-addressed store, hash-verified

401}
402
403export function activityToNotification(activity: Record<string, any>): Record<string, any> | null {
404 const note: Record<string, any> = {};
405
406 note.id = activity.max_position;
407 note.created_at = convertTimestamp(activity.created_at);
408 if (activity.action === 'favorite') {
409 note.type = 'favourite';
410 note.status = tweetToToot(activity.targets[0]);
411 note.account = userToAccount(activity.sources[0]);
412 } else if (activity.action === 'reply') {
413 note.type = 'mention';
414 note.status = tweetToToot(activity.targets[0]);
415 note.account = userToAccount(activity.sources[0]);
416 } else if (activity.action === 'mention') {
417 note.type = 'mention';
418 note.status = tweetToToot(activity.target_objects[0]);
419 note.account = userToAccount(activity.sources[0]);
420 } else if (activity.action === 'retweet') {
421 note.type = 'reblog';
422 note.status = tweetToToot(activity.targets[0]);
423 note.account = userToAccount(activity.sources[0]);
424 } else if (activity.action === 'follow') {
425 note.type = 'follow';
426 note.account = userToAccount(activity.sources[0]);
427 } else {
428 console.warn('unhandled activity', activity);
429 note.type = 'invalid';
430 return note;
431 }
432
433 return note;
434}

Callers 1

main.tsFile · 0.90

Calls 3

convertTimestampFunction · 0.85
tweetToTootFunction · 0.85
userToAccountFunction · 0.85

Tested by

no test coverage detected