Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit274efd0

Browse files
authored
chore: oauth & ip service debug (#444)
* chore: add log* chore(deploy): debug oauth* chore(deploy): debug oauth* chore(deploy): debug oauth* chore(deploy): debug oauth* chore(deploy): debug oauth* chore: fix & debug* chore: bump version* chore: debug ip* chore: fix ci errors* chore: add ip debug info* chore: bump version* chore: ip works, clean up* chore: bump version* chore: fix some read issue when debug works* chore: bump version* fix(audit): token fail edege case* chore(deploy): bump version* fix: audit key missing in test env
1 parentc048eb3 commit274efd0

File tree

21 files changed

+376
-229
lines changed

21 files changed

+376
-229
lines changed

‎config/mock.exs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ config :phoenix, :stacktrace_depth, 20
1717

1818
# Configure your database
1919
config:groupher_server,GroupherServer.Repo,
20-
adapter:Ecto.Adapters.Postgres,
21-
22-
# username: "postgres",
23-
# password: "postgres",
24-
# database: "groupher_server_mock",
25-
# hostname: "localhost",
20+
username:"postgres",
21+
password:"postgres",
22+
database:"groupher_server_mock",
23+
hostname:"localhost",
2624
pool_size:90
2725

2826
# config email services

‎config/prod.exs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ config :groupher_server, :github_oauth,
9191

9292
config:groupher_server,:ip_locate,ip_service:System.get_env("IP_LOCATE_KEY")
9393
config:groupher_server,:plausible,token:System.get_env("PLAUSIBLE_TOKEN")
94+
config:groupher_server,:audit,token:System.get_env("AUDIT_TOKEN")
9495

9596
config:sentry,
9697
dsn:System.get_env("SENTRY_DSN"),

‎config/test.exs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ config :groupher_server, :github_oauth,
3232

3333
# config email services
3434
config:groupher_server,GroupherServer.Mailer,adapter:Bamboo.TestAdapter
35+
36+
config:groupher_server,:audit,
37+
token:"24.aa6fb4e4018c371e9ed228db5bea3ec0.2592000.1641816180.282335-25148796"
-104 Bytes
Binary file not shown.

‎lib/groupher_server/cms/delegates/article_curd.ex‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,22 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
552552
|>result()
553553
end
554554

555+
# pending article can be seen is viewer is author
556+
defpcheck_article_pending(thread,id,%User{}=user)whenis_atom(thread)do
557+
with{:ok,info}<-match(thread),
558+
{:ok,article}<-ORM.find(info.model,id,preload::author)do
559+
check_article_pending(article,user)
560+
end
561+
end
562+
555563
defpcheck_article_pending(%{pending:@audit_legal}=article,_)do
556564
{:ok,article}
557565
end
558566

567+
defpcheck_article_pending(%{pending:@audit_failed}=article,_)do
568+
{:ok,article}
569+
end
570+
559571
defpcheck_article_pending(%{pending:@audit_illegal}=article,%User{id:user_id})do
560572
casearticle.author.user_id==user_iddo
561573
true->{:ok,article}
@@ -571,14 +583,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
571583
end
572584
end
573585

574-
# pending article can be seen is viewer is author
575-
defpcheck_article_pending(thread,id,%User{}=user)do
576-
with{:ok,info}<-match(thread),
577-
{:ok,article}<-ORM.find(info.model,id,preload::author)do
578-
check_article_pending(article,user)
579-
end
580-
end
581-
582586
defpcheck_article_pending(%{pending:@audit_illegal})do
583587
raise_error(:pending,"this article is under audition")
584588
end

‎lib/groupher_server/cms/delegates/hooks/cite.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ defmodule GroupherServer.CMS.Delegate.Hooks.Cite do
4848
@article_threadsget_config(:article,:threads)
4949
@valid_article_prefixEnum.map(@article_threads,&"#{@site_host}/#{&1}/")
5050

51-
defhandle(%{body:body}=artiment)do
51+
defhandle(%{body:body}=artiment)whennotis_nil(body)do
5252
with{:ok,%{"blocks"=>blocks}}<-Jason.decode(body),
5353
{:ok,artiment}<-preload_author(artiment)do
5454
Multi.new()

‎lib/groupher_server/cms/delegates/hooks/mention.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule GroupherServer.CMS.Delegate.Hooks.Mention do
1717

1818
@article_mention_class"cdx-mention"
1919

20-
defhandle(%{body:body}=artiment)do
20+
defhandle(%{body:body}=artiment)whennotis_nil(body)do
2121
with{:ok,%{"blocks"=>blocks}}<-Jason.decode(body),
2222
{:ok,artiment}<-preload_author(artiment)do
2323
blocks

‎lib/groupher_server/cms/delegates/works_curd.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ defmodule GroupherServer.CMS.Delegate.WorksCURD do
151151
end
152152

153153
defpget_techstack(title)do
154-
caseORM.find_by(Techstack,%{title:title})do
154+
caseORM.find_by(Techstack,%{raw:title})do
155155
{:error,_}->create_techstack(title)
156156
{:ok,techstack}->{:ok,techstack}
157157
end

‎lib/groupher_server_web/context.ex‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ defmodule GroupherServerWeb.Context do
3333
with["Bearer "<>token]<-get_req_header(conn,"authorization"),
3434
{:ok,cur_user}<-authorize(token)do
3535
# IO.inspect(
36-
# RemoteIP.parse(get_req_header(conn, "x-forwarded-for")),
37-
# label: "x-forwarded-for"
36+
#RemoteIP.parse(get_req_header(conn, "x-forwarded-for")),
37+
#label: "#>#x-forwarded-for"
3838
# )
3939

4040
caseRemoteIP.parse(get_req_header(conn,"x-forwarded-for"))do

‎lib/groupher_server_web/middleware/github_user.ex‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
defmoduleGroupherServerWeb.Middleware.GithubUserdo
2+
@moduledoc"""
3+
handle github oauth login
4+
"""
25
@behaviourAbsinthe.Middleware
36

47
importHelper.Utils,only:[handle_absinthe_error:2]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp