-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get Contact avatarUrl rather than a image file #1918
Comments
valid size suffix :
|
Thanks for the issue and the pull request, appreciate it. Currently, we are using FileBox to encapsulate all files inside the Wechaty framework, including the avatar image. The reason we use FileBox is that in some conditions we can use NOT the URL directly, for example, the Web WeChat protocol requires you send the cookie to the HTTP server when you are getting your image from the URL. However, if you are using the wechaty-puppet-padplus, I believe there's a chance to do a workaround for archiving your goal by getting the import { FileBoxType } from 'file-box'
const fileBox = await contact.avatar()
const type = (fileBox as any).boxType
if (type === FileBoxType.Url) {
console.info('url:', (fileBox as any).remoteUrl)
} else {
console.info('not a url type for FileBox')
} According to the above reason (Web Protocol limitation), we can not accept the design in your Pull Request because we need to make sure the abstract of wechaty-puppet can support all protocols, which should including the current ones, and the future ones (a puppet implementation might use Base64 encoding for your avatar, which will be no url at all). So please let me know if the workaround works for you (if you are using the pad protocol), and let's keep this issue open and to see if we can get any better ideas to solve it. BTW: We can consider using the new |
I'm using pad protocol( padplus ) now. By the way If get avatar by new It's seems will take some times for files download complete one by one. If |
No, you needn't download anything to your server when you are using Please read the code before you continue designing, you will get to know the right direction for this problem. |
I am sorry for my carelessness I found that in #1871 class Image {
url(): string // does not grantee to be visited directly (?)
thumbnail(): FileBox
hd(): FileBox
artwork(): FileBox
} Looking forward to Wechaty@0.31.17 available 😃 |
Is your feature request related to a problem? Please describe.
I'd like to save contact's avatar url into my db directly
By this way ,I can display avatar flexibly
egg.
My avatar
[ 132px * 132*px ] http://wx.qlogo.cn/mmhead/ver_1/ib8fq9LMlcm17X8IILM3hNgGtcKENm7fYibPozFSDfp7x7oLBEiaia6TdAdNILEkSORbW8umkU31MGy9EgAd8QesJA/132
If change last part , It will return different size.
[ 1024px* 1024px ]
http://wx.qlogo.cn/mmhead/ver_1/ib8fq9LMlcm17X8IILM3hNgGtcKENm7fYibPozFSDfp7x7oLBEiaia6TdAdNILEkSORbW8umkU31MGy9EgAd8QesJA/0
Describe the solution you'd like
add some code to
src/user/contact.ts
[enhancement]
The text was updated successfully, but these errors were encountered: