aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/lib/activitypub/send/send-accept.ts
blob: d3f8fbe38475dced9725849aeeaff49306f756b2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12




                                                                                        
                                                             





                                                                                  
                                          











                                                                              
                                                                       







                                    
import { Transaction } from 'sequelize'
import { ActivityAccept } from '../../../../shared/models/activitypub/activity'
import { AccountInstance } from '../../../models'
import { AccountFollowInstance } from '../../../models/account/account-follow-interface'
import { unicastTo } from './misc'
import { getAccountFollowAcceptActivityPubUrl } from '../url'

async function sendAccept (accountFollow: AccountFollowInstance, t: Transaction) {
  const follower = accountFollow.AccountFollower
  const me = accountFollow.AccountFollowing

  const url = getAccountFollowAcceptActivityPubUrl(accountFollow)
  const data = acceptActivityData(url, me)

  return unicastTo(data, me, follower.inboxUrl, t)
}

// ---------------------------------------------------------------------------

export {
  sendAccept
}

// ---------------------------------------------------------------------------

function acceptActivityData (url: string, byAccount: AccountInstance) {
  const activity: ActivityAccept = {
    type: 'Accept',
    id: url,
    actor: byAccount.url
  }

  return activity
}