提交 a2c56e62 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

follow friendship puppet abstract interface change

上级 f0a00db1
......@@ -1260,11 +1260,11 @@ export class PuppetPadchat extends Puppet {
* Friendship
*
*/
public async friendshipVerify(
public async friendshipAdd(
contactId : string,
hello : string,
): Promise<void> {
log.verbose('PuppetPadchat', 'friendshipVerify(%s, %s)', contactId, hello)
log.verbose('PuppetPadchat', 'friendshipAdd(%s, %s)', contactId, hello)
if (!this.padchatManager) {
throw new Error('no padchat manager')
......@@ -1276,7 +1276,7 @@ export class PuppetPadchat extends Puppet {
* If the contact is not stranger, than ussing WXSearchContact can get user_name
*/
if (rawSearchPayload.user_name !== '' && !isStrangerV1(rawSearchPayload.user_name) && !isStrangerV2(rawSearchPayload.user_name)) {
log.warn('PuppetPadchat', 'friendRequestSend %s has been friend with bot, no need to send friend request!', contactId)
log.warn('PuppetPadchat', 'friendshipAdd %s has been friend with bot, no need to send friend request!', contactId)
return
}
......
......@@ -1068,14 +1068,14 @@ export class PuppetPuppeteer extends Puppet {
}
}
public async friendshipVerify(
public async friendshipAdd(
contactId : string,
hello : string,
): Promise<void> {
try {
await this.bridge.verifyUserRequest(contactId, hello)
} catch (e) {
log.warn('PuppetPuppeteer', 'bridge.verifyUserRequest(%s, %s) rejected: %s', contactId, hello, e.message)
log.warn('PuppetPuppeteer', 'friendshipAdd() bridge.verifyUserRequest(%s, %s) rejected: %s', contactId, hello, e.message)
Raven.captureException(e)
throw e
}
......
......@@ -66,20 +66,34 @@ export class Friendship extends Accessory {
return newFriendship
}
/**
* @deprecated use add() instead
*/
public static async send(contact: Contact, hello: string) {
log.warn('Friendship', 'static send() DEPRECATED, use add() instead.')
return this.add(contact, hello)
}
/**
* Send a Friend Request to a `contact` with message `hello`.
* @param contact
* @param hello
*/
public static async send(
public static async add(
contact : Contact,
hello : string,
): Promise<void> {
log.verbose('Friendship', 'static send(%s, %s)',
log.verbose('Friendship', 'static add(%s, %s)',
contact.id,
hello,
)
await this.puppet.friendshipVerify(contact.id, hello)
await this.puppet.friendshipAdd(contact.id, hello)
}
public static async del(
contact: Contact,
): Promise<void> {
log.verbose('Friendship', 'static del(%s)', contact.id)
throw new Error('to be implemented')
}
// public static createConfirm(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册