Move ensureSuffix
This commit is contained in:
1 parent
270be1ee77
commit
ebf5532f27
2 files changed
+15
-10
No files matched your search
@@ -11,15 +11,7 @@ import {
|
||||
MessageText
|
||||
} from "./all.dto";
|
||||
import {Whatsapp} from "venom-bot";
|
||||
|
||||
const SUFFIX_DIRECT_MESSAGE = "@c.us"
|
||||
|
||||
function ensureSuffix(phone){
|
||||
if (phone.endsWith(SUFFIX_DIRECT_MESSAGE)){
|
||||
return phone
|
||||
}
|
||||
return phone + SUFFIX_DIRECT_MESSAGE
|
||||
}
|
||||
import {ensureSuffix} from "../whatsapp.service";
|
||||
|
||||
@Controller('api')
|
||||
@ApiTags('chatting')
|
||||
|
||||
+14
-1
@@ -1,5 +1,5 @@
|
||||
import {create, Message, Whatsapp} from "venom-bot";
|
||||
import {ConsoleLogger, Inject, Injectable, Logger, OnApplicationShutdown} from "@nestjs/common";
|
||||
import {ConsoleLogger, Inject, Injectable, OnApplicationShutdown} from "@nestjs/common";
|
||||
import {ConfigService} from "@nestjs/config";
|
||||
import * as path from "path";
|
||||
import {WhatsappConfigService} from "./config.service";
|
||||
@@ -169,3 +169,16 @@ export class WhatsappService implements OnApplicationShutdown {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const SUFFIX_DIRECT_MESSAGE = "@c.us"
|
||||
|
||||
/**
|
||||
* Add WhatsApp suffix (@c.us) to the phone number if it doesn't have it yet
|
||||
* @param phone
|
||||
*/
|
||||
export function ensureSuffix(phone) {
|
||||
if (phone.endsWith(SUFFIX_DIRECT_MESSAGE)) {
|
||||
return phone
|
||||
}
|
||||
return phone + SUFFIX_DIRECT_MESSAGE
|
||||
}
|
||||
Reference in new issue
Block a user