Skip to content
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

关于 contributor Token 自动续期的方案 #5

Open
osindex opened this issue Dec 2, 2021 · 2 comments
Open

关于 contributor Token 自动续期的方案 #5

osindex opened this issue Dec 2, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@osindex
Copy link

osindex commented Dec 2, 2021

主要目的:每个开发者可以通过关注friday 查询自己的token有效期,申请或重新续期
相关问题:
1.如何判断当前询问人是否属于开发者
2.如何查询当前开发者拥有的token
3.如何续期不同puppet的token

@huan
1>查询是否在 Contributor 名单,可以按照是否在开发者群为标准 或者 使用 Authing Wechaty Plugin https://github.com/authing/wechaty-authing
2>TOKEN 可以有一个 POOL ,登记上是谁领取就可以了,比如最简单可以在本地一个 json 文件,因为数据量很小。我理想中使用 Google Spreadsheet 做后台,比如这里有一个 Library 可以很方便的实现: https://www.npmjs.com/package/sheet-db 。POOL 由我们社区的 Puppet Service Provider 提供支持。

@osindex
Copy link
Author

osindex commented Dec 15, 2021

设计了两个结构来实现这套逻辑,可以讨论看看:

结构

// token-pool
{
   "token-1": {
     puppet: '',
     token: 'token-1',
     exp: '', // yyyy-mm-dd hh:mm:ss
     used: true, // false
   },
   "token-2": {
     puppet: '',
     token: 'token-2',
     exp: '', // yyyy-mm-dd hh:mm:ss
     used: false, // false
   }
}

// token-user
{
   "user-1": 
   [
     {
       puppet: '',
       token: 'token-1',
       exp: '', // yyyy-mm-dd hh:mm:ss
       iat: '', // yyyy-mm-dd hh:mm:ss
       owner: 'user-1', 
     },
     {
       puppet: '',
       token: 'token-2',
       exp: '', // yyyy-mm-dd hh:mm:ss
       iat: '', // yyyy-mm-dd hh:mm:ss
       owner: 'user-1', 
     }
   ]
}

场景

// 场景 1
1. user X send => 'what is my token'
2. `token-user` query `user-X`
3. return [...] if null to 4.
4. `user-X` is not match group to 5. else 6.
5. send 'pls add group ...'
6. `token-pool` query used: false
7. send {token: ...}

// 场景 2
1. user X send => 'token: token-1'
2. `token-pool` query
3. return {token: ...} and say: 'del / renewal token...'
4.1 user X send => 'del token-1'
4.2 user X send => 'renewal token-1' then update exp

需要做puppet对pool的增删改查操作

@huan
Copy link
Member

huan commented Dec 15, 2021

Your design looks good for building our first PoC!

Please go ahead and look forward to your PR to demonstrate this new feature.

BTW: the pool can be simply defined as a {} in JS, and we can enhance it in the future versions later.

@huan huan transferred this issue from wechaty/friday Dec 15, 2021
@huan huan added the enhancement New feature or request label Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants