Code Monkey home page Code Monkey logo

artalkgo's Introduction

artalkgo's People

Contributors

dependabot[bot] avatar fossabot avatar kevinzonda avatar qwqcode avatar syfxlin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

artalkgo's Issues

关于连接 PostgreSQL 问题

image

由于 model 定义了很多 boolean 类型的字段,使用 gorm 进行查询 where 方法查询很多地方直接传递了字符串 xxx = 1,在 MySQL 数据库和 SQLite 下 gorm 拼接的语句能正常工作。

参考:f420fb5

然而,由于 pgsql 字段类型丰富,自带 boolean 字段类型;而 MySQL 本身无,故 gorm 创建字段类型 tinyint 来替代。导致了 pgsql 数据库和 MySQL 查询语句的差异性。

解决办法:将所有 boolean 字段类型改成 int,消除 gorm 创建 table 在不同数据库间的类型差异性。

另外还有很多问题,MySQL 和 SQLite 外键约束功能正常,而 PgSQL 测试不正常。

参考:go-gorm/gorm#3624

适配难度较大,需要一定的时间和精力,暂时搁置。

目前仅测试兼容 MySQL 和 SQLite 两种数据库。

[Bug Report] 开启评论审核后无法发送回复通知

开启所有评论都需要审核后

moderator:
  pending_default: true 

存在以下问题:

  • 管理员审核通过后,回复该评论无法自动通过审核,也需要手动通过审核
  • 回复该评论后,即使手动通过审核,也无法给原评论用户发送回复通知邮件(取消评论审核后,回复评论的通知可以正常发出)

希望是这样的逻辑:

  • 管理员审核通过后,回复该评论应该自动通过审核,并同时发出回复通知邮件
  • A 用户评论(管理员通过审核),B 用户给 A 用户该条评论回复,管理员对 B 用户的回复审核通过后,给 A 用户发出评论通知

分离 Artransfer

由于数据迁移工具常常发生变动,将其单独拆分成一个程序,利于及时更新。

help: error startup when connect mysql AutoMigrate with error="Error 1170: BLOB/TEXT column 'name' used in key specification without a key length"

log

ERRO[0000] CREATE TABLE `sites` (`id` bigint unsigned AUTO_INCREMENT,`created_at` datetime(3) NULL,`updated_at` datetime(3) NULL,`deleted_at` datetime(3) NULL,`name` longtext,`urls` longtext,`users` longtext,PRIMARY KEY (`id`),INDEX idx_sites_deleted_at (`deleted_at`),UNIQUE INDEX idx_sites_name (`name`)) [7.659879ms]  error="Error 1170: BLOB/TEXT column 'name' used in key specification without a key length"
ERRO[0000] SELECT * FROM `sites` WHERE name = '唔该博客' AND `sites`.`deleted_at` IS NULL ORDER BY `sites`.`id` LIMIT 1 [2.043661ms]  error="Error 1146: Table 'artalk.sites' doesn't exist"
ERRO[0000] INSERT INTO `sites` (`created_at`,`updated_at`,`deleted_at`,`name`,`urls`,`users`) VALUES ('2021-11-30 18:29:16.34','2021-11-30 18:29:16.34',NULL,'唔该博客','','') [4.668251ms]  error="Error 1146: Table 'artalk.sites' doesn't exist"
ERRO[0000] Create Site error: Error 1146: Table 'artalk.sites' doesn't exist 

conf.yml

db:
  type: "mysql" # 支持 mysql, sqlite, pgsql, sqlserver
  dsn: "root:root@tcp(192.168.1.100:3306)/artalk?charset=utf8mb4&parseTime=True&loc=Local"

docker image

artalk/artalk-go:2.0.5

mysql version

5.7.32

飞书通知设置无效

按照文档设置了飞书通知,测试发现没有作用。检查了Artalk文档和飞书机器人文档,设置应该没有问题,飞书机器人没有设置任何禁止策略。查看后台日志也没有任何输出。

bug: use mysql keyword or reserved word in table pages with error="Error 1064: You have an error in your SQL syntax;

ERRO[0181] SELECT * FROM `pages` WHERE (key = 'http://127.0.0.1:8888/post/java-urlencoder' AND site_name = '唔该博客') AND `pages`.`deleted_at` IS NULL ORDER BY `pages`.`id` LIMIT 1 [704.131µs]  error="Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = ? AND site_name = ?) AND `pages`.`deleted_at` IS NULL ORDER BY `pages`.`id' at line 1"

column key in table pages and notifies is mysql reserved word

table model code query code
pages https://github.com/ArtalkJS/ArtalkGo/blob/v2.0.5/model/page.go#L16 https://github.com/ArtalkJS/ArtalkGo/blob/v2.0.5/model/query.go#L193
notifies https://github.com/ArtalkJS/ArtalkGo/blob/v2.0.5/model/notify.go#L22 https://github.com/ArtalkJS/ArtalkGo/blob/v2.0.5/model/query.go#L103

如何使用带有密码认证的Redis缓存

正在使用的Redis带有密码认证,ArtalkGo在使用redis做缓存时,如何设置?
密码认证无法关闭。
例子
Redis访问链接:redis://default:YOCnibb5ijA9eltMBI1RGb2SVBFEdN56@redis-12875.c57.us-east-1-4.ec2.cloud.redislabs.com:12875
如何配置?

# 缓存
cache:
  type: "builtin" # 支持 redis, memcache, builtin (自带缓存)
  expires: 30     # 缓存过期时间 (单位:分钟)
  warm_up: false  # 程序启动时预热缓存
  server: ""      # 连接缓存服务器 (例如:"localhost:6379")

Redis 缓存相关导致报错

突然间,无法登录了,相关日志:

Artalk (2.1.4/2ad6864)

 -> A Selfhosted Comment System.
 -> https://artalk.js.org

-------------------------------

⇨ http server started on [::]:23366
echo: http: panic serving 127.0.0.1:38796: interface conversion: interface {} is string, not []uint8
goroutine 52 [running]:
net/http.(*conn).serve.func1(0xc00026cd20)
	/usr/local/go/src/net/http/server.go:1804 +0x153
panic(0x14d4a00, 0xc0007f6b70)
	/usr/local/go/src/runtime/panic.go:971 +0x499
github.com/ArtalkJS/ArtalkGo/http.getActionLastTime(0x1927aa8, 0xc00024abe0, 0x157f5a0, 0xc0008f0cc0, 0x16a72c7)
	/go/src/github.com/ArtalkJS/ArtalkGo/http/permission.go:163 +0x189
github.com/ArtalkJS/ArtalkGo/http.IsActionInTimeFrame(0x1927aa8, 0xc00024abe0, 0xc000896600)
	/go/src/github.com/ArtalkJS/ArtalkGo/http/permission.go:150 +0x39
github.com/ArtalkJS/ArtalkGo/http.IsReqNeedCaptchaCheck(0x1927aa8, 0xc00024abe0, 0xd)
	/go/src/github.com/ArtalkJS/ArtalkGo/http/permission.go:127 +0x105
github.com/ArtalkJS/ArtalkGo/http.ActionLimitMiddleware.func1.1(0x1927aa8, 0xc00024abe0, 0xc0000e0000, 0x0)
	/go/src/github.com/ArtalkJS/ArtalkGo/http/permission.go:59 +0x1f7
github.com/onrik/logrus/echo.Middleware.func1.1(0x1927aa8, 0xc00024abe0, 0x16b7df2, 0x1b)
	/go/pkg/mod/github.com/onrik/[email protected]/echo/middleware.go:62 +0x16e
github.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1(0x1927aa8, 0xc00024abe0, 0x3, 0x4)
	/go/pkg/mod/github.com/labstack/echo/[email protected]/middleware/cors.go:186 +0x1016
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc000662480, 0x1904a28, 0xc00087f180, 0xc00084ec00)
	/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:654 +0x2bc
net/http.serverHandler.ServeHTTP(0xc000182e00, 0x1904a28, 0xc00087f180, 0xc00084ec00)
	/usr/local/go/src/net/http/server.go:2867 +0xa3
net/http.(*conn).serve(0xc00026cd20, 0x1909fd0, 0xc000755280)
	/usr/local/go/src/net/http/server.go:1932 +0x8cd
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2993 +0x39b

MariaDB数据库错误

使用 MariaDB 10.5.12数据库,连接方式使用mysql。
启动后数据库只创建了sites表,报如下错误
ERROR CREATE TABLE pages (id bigint unsigned AUTO_INCREMENT,created_at datetime(3) NULL,updated_at datetime(3) NULL,deleted_at datetime(3) NULL,key varchar(191),title longtext,admin_only boolean,site_name varchar(191),vote_up bigint,vote_down bigint,PRIMARY KEY (id),INDEX idx_pages_deleted_at (deleted_at),INDEX idx_pages_key (key),INDEX idx_pages_site_name (site_name),CONSTRAINT fk_pages_site FOREIGN KEY (site_name) REFERENCES sites(name)) [505.1µs] error=Error 1005: Can't create table artalk.pages (errno: 150 "Foreign key constraint is incorrectly formed")
ERROR SELECT * FROM users WHERE (LOWER(name) = LOWER('admin') AND LOWER(email) = LOWER('[email protected]')) AND users.deleted_at IS NULL ORDER BY users.id LIMIT 1 [537.9µs] error=Error 1146: Table 'artalk.users' doesn't exist
ERROR INSERT INTO users (created_at,updated_at,deleted_at,name,email,link,password,badge_name,badge_color,last_ip,last_ua,is_admin,is_in_conf) VALUES ('2022-02-08 04:26:29.312','2022-02-08 04:26:29.312',NULL,'admin','[email protected]','','','管理员','#FF6C00','','',true,true) [518.5µs] error=Error 1146: Table 'artalk.users' doesn't exist
ERROR SELECT * FROM users WHERE is_in_conf = 1 AND users.deleted_at IS NULL [0s] error=Error 1146: Table 'artalk.users' doesn't exist

非管理员用户侧边栏提示错误:Referer 不被允许

感谢作者提供如此优秀的开源项目🙏🙏🙏

在使用中遇到了这个问题,不太懂相关代码,希望好心人能帮忙解答下🙏

具体错误如下:
image

​ hello artalk-sidebar
index.f7f00175.js:1 hello artalk-sidebar
index.f7f00175.js:1 非法请求:Referer 不被允许
onError @ index.f7f00175.js:1
(anonymous) @ index.f7f00175.js:1
a @ index.f7f00175.js:1
index.f7f00175.js:1 Uncaught (in promise) Object
a @ index.f7f00175.js:1

API 新增建议

1.获取前 N 位最新评论数据。
2.获取前 N 位 PV 数最高的文章。
3.根据 URL 批量获取对应文章的评论数。


博客可以拿来实现热门文章、最新评论、文章评论数量显示。

[Bug Report] Telegram 评论通知

模板排版

默认的 Telegram 通知模板中(见上图),「来自 xxxx 的回复」这一行与评论内容之间并没有空行。

image

建议:除了邮件提供自定义模板外,Telegram、钉钉等也提供用户自定义通知模板设置,方便用户自己修改。

重复通知

设置了邮件通知和 Telegram 通知后,收到评论会同时通过邮件和 Telegram 进行通知。

建议:提供一个管理员收取通知的渠道配置,例如:

notify:
  # 管理员收取通知的方式
  admin:
    - email
    - telegram
    - dingtalk
notify:
  # 管理员收取通知的方式
  admin:
    - telegram
    - dingtalk

关于连接 MariaDB 和 MySQL 数据库的问题

由于创建数据表直接使用了 Golang 的 ORM 框架 Gorm,之前开发也没有测试到有这些问题

目前 ArtalkGo 使用 MariaDB 和 MySQL 数据库需要“曲线救国”的方式....

  1. 才疏学浅,某些表里面使用了 MySQL 的保留关键字(例如:key, name)作为字段名,所以会有问题(而 SQLite 没问题)
  2. Golang 的 ORM 框架 Gorm 自动创建数据功能,似乎生成的 SQL 语句不太兼容一些种类的数据库

之后有时间会修改,但修改数据表结构,版本更新老版本与新版,对老用户来说,数据迁移又是一个麻烦事 🥲🥲🥲

Originally posted by @qwqcode in #14 (comment)

upgit 图片上传

上传成功后能否也把图片文件删掉

if config.Instance.ImgUpload.Upgit.Enabled {
upgitURL := execUpgitUpload(fileFullPath)
if upgitURL == "" || !lib.ValidateURL(upgitURL) {
// 上传失败,删除源图片文件
var err = os.Remove(fileFullPath)
if err != nil {
logrus.Error(err)
}
logrus.Error("[IMG_UPLOAD] [upgit] upgit output: ", upgitURL)
return RespError(c, "图片通过 upgit 上传失败")
}
// 使用从 upgit 获取的图片 URL
imgURL = upgitURL
}

导入评论时必须指定目标站点 URL的问题

哈喽 非常感谢作者开源
在导入valine历史评论的过程中发现一个问题:
导入评论时必须指定 目标站点 URL 如 https://xxx.com
这样会让导入的那些评论的 page_key 字段自动拼接目标站点 URL
而如果前端 实例化时pageKey 为相对路径时,就没法正确的展示评论,必须手动去数据库将历史评论的 目标站点 URL 前缀去除。

优化关于docker的配置文件映射问题

  1. docker不建议直接挂载文件,应改为挂载目录.

原因: 当配置文件修改时,文件inode会改变,而容器仅存储了首次挂载的inode,导致读取不到而启动失败.

  1. 建议配置文件自动生成.

可采用入口点脚本作shell判断实现.

一点建议

看了作者的作品,小小年纪能有如此造诣实属不易,加油
另给一点不成熟的小建议

1、尽量采用依赖注入的方式进行开发,比如lib.DB这种全局变量最好不用,虽然开发起来比较简单,但是不利于扩展,也不利于测试,推荐使用google wire,https://github.com/google/wire
2、模块之间尽可能的使用DDD**进行拆分,基于接口开发,利于mock单元测试

一点小建议,希望对你有帮助

Windows系统下时区异常

问题

我在一台新装的Windows Server 2019上部署,无论将timezone设为何值结果均等效于UTC+0
image
在debug模式可以看到这里insert了一个19:28:58进去,但我是在第二天的3:28启动的。
实际上,在添加评论的时候,在前端显示的结果也会是8小时前

可能的原因

由于我不太了解Golang,所以去查了一下原因,找到了语言下的一个issue
golang/go#38453

denverLoc, _ := time.LoadLocation(Instance.TimeZone)

应该是这里出的问题。

同时根据上面issue提供的线索,我用procmon探了一下zoneinfo.zip的读取,是在运行盘符:\usr\local\go\lib\time\zoneinfo.zip上。我拷了一份过去,目前工作正常,不过这个问题确实影响在win上的直接部署。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.