This repository was archived by the owner on Nov 8, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork20
chore(deps): bump sentry from 6.4.1 to 7.0.2#92
Closed
Uh oh!
There was an error while loading.Please reload this page.
Closed
Changes fromall commits
Commits
Show all changes
170 commits Select commitHold shift + click to select a range
14d04ab
build(deps-dev): bump excoveralls from 0.9.2 to 0.10.0
dependabot-support64b769c
build(deps): bump phoenix_ecto from 3.3.0 to 3.4.0
dependabot-supportab0c67b
build(deps): bump dataloader from 1.0.3 to 1.0.4
dependabot-support1287541
build(deps-dev): bump inch_ex from 1.0.0 to 1.0.1
dependabot-support0da40c2
Merge pull request #73 from coderplanets/dependabot/hex/dataloader-1.0.4
mydearxym41e5e54
Merge pull request #74 from coderplanets/dependabot/hex/inch_ex-1.0.1
mydearxym4c05c6c
Merge pull request #70 from coderplanets/dependabot/hex/phoenix_ecto-…
mydearxym65d2ac2
build(deps): bump guardian from 1.1.0 to 1.1.1
dependabot-supported86377
build(deps-dev): bump mix_test_watch from 0.8.0 to 0.9.0
dependabot-supporte2a22ca
build(deps-dev): bump credo from 0.10.0 to 0.10.1
dependabot-support12fa5f1
Merge pull request #65 from coderplanets/dependabot/hex/guardian-1.1.1
mydearxym06fd5b7
Merge pull request #66 from coderplanets/dependabot/hex/excoveralls-0…
mydearxymeb990fd
Merge pull request #71 from coderplanets/dependabot/hex/mix_test_watc…
mydearxym9ac99e7
Merge pull request #72 from coderplanets/dependabot/hex/credo-0.10.1
mydearxym302104b
build: production
mydearxymb0e7063
ci(fix apollo schema check): schema check broken fix
mydearxymdc46e65
chore(deps): upgrade
mydearxymb443237
build(postgresql): update to 10
mydearxymc0c6d4a
ci(postgresql): fallback to 9.4
mydearxym214a66a
fix(profile test): fix work backgorund test
mydearxymf8f86aa
build: production
mydearxym6d39990
fix(cms video): missing field publish_at
mydearxym6b59ffa
feat(geoinfo): user info geo & community geo
mydearxym531bdcc
Merge branch 'geo-service' into dev
mydearxym584fcab
chore(wip clean up): clean up wip
mydearxym5b635cd
Update README.md
mydearxymb5d07cf
fix: add missing cms_thread
mydearxyma32ffdc
refactor(cms.repo): use new repo fields
mydearxym76ead2f
refactor(repo thread): change fields to match frontend
mydearxym3af77fc
Merge branch 'repo-refactor' into dev
mydearxymc932c26
feat(repo thread): debug with frontend, feature is done
mydearxymc02018c
Merge branch 'repo-refactor' into dev
mydearxym35cf03b
refactor(comments): replace body:string -> body:text
mydearxymd98d512
feat(video comments): basic curd comments
mydearxym94cbaec
feat(video comments): add like/dilike
mydearxymae7c30b
feat(repo comment test): done with test cover
mydearxyme7e010c
Merge branch 'comments-for-other-threads' into dev
mydearxymbe7ee5e
refactor(comments): add a bug tag for spec case
mydearxymcb895ca
Merge branch 'comments-for-other-threads' into dev
mydearxym9b5ad22
feat(wiki thread): add wiki with test
mydearxymbec08ec
feat(wiki thread): add basic wiki query
mydearxym8fc9f67
feat(wiki thread): add sync content and add contributor
mydearxym37a2eca
chore(wiki thread): clean up wiki
mydearxymb303c10
feat(cheatsheet): add feature just like wiki
mydearxym8136cce
chore(clean up): warnings and wip tag
mydearxym05805e0
refactor(factory): auto camelize factory attrs if need
mydearxym1daab98
Merge branch 'mapkeys' into dev
mydearxym266aa53
feat(json encode): config Jason in absinthe , ecto
mydearxym00fb4da
refactor(test): clean up warning
mydearxymb250f5c
style: fmt
mydearxymb8ff8df
fix: missing field
mydearxyme10a33e
Merge branch 'wiki-thread' into dev
mydearxym04d7ac4
refactor(reactions): extract comment fields and fix job reaction
mydearxym531e1cf
Merge branch 'cheatsheet-thread' into dev
mydearxym85d8b67
feat(video reactions): add basic favorite / star
mydearxyma344032
chore(reactions): add reactions test
mydearxymfb5847b
fix(video reaction): job_id -> video_id
mydearxym5177dfe
Merge branch 'reactions' into dev
mydearxym5850812
test(video comments): add like/dislike tests
mydearxym8c51ac7
refactor(rename): comments -> pagedComments
mydearxym5050661
test(repo tests): badic query tests
mydearxymfef0793
test: add mutation tests for video/repo comments
mydearxym5f6bee2
feat(job comment): add like / dislike & test
mydearxym1dfd5d9
chore(clean up): remove @wip tag
mydearxymf0c4714
Merge branch 'comments' into dev
mydearxyme4fa80d
refactor(reaction users): more tests on paged reaction users
mydearxym468b8c1
chore(clean up): remove @wip & add @doc
mydearxym6cbc9ce
fix: followersCount makes right by rm dataloader
mydearxym199a447
style: fmt
mydearxymef71466
refactor(user favrites cats): enhance support for jobs / videos
mydearxymb462963
style: fmt
mydearxym3651fdd
Merge branch 'reaction-users' into dev
mydearxym81c7497
feat(user achievement): add source contribute info
mydearxymd93a11b
feat(user signin): init a empty achievement when new signin
mydearxymc45b72b
feat(favorite cats): add last_updated field
mydearxym1cee80b
feat(user): add editable-communities query field
mydearxymf0addbf
refactor(user query): rm unneed filter on some query
mydearxym1906d2b
feat(user page): user published contents done right
mydearxym7c2c86d
chore(clean up): rm :wip tag
mydearxym4e6acca
test(stared contents): add more test on query part
mydearxym8c2e339
refactor(uer favorites test): extract total_count -> @total_count
mydearxym029d502
chore(tests): clean warnings & rm :wip tag
mydearxym113b8c5
Merge branch 'userpage' into dev
mydearxym1f818cf
test(thread comments): add test for particlepators
mydearxym40fea00
feat(cms.contents): add favroted_category_id query field
mydearxym3f49934
test: restore some job tests & clean up
mydearxymebc85cd
fix(user favorite): totalcount mismatch when switch cats
mydearxym08d30e2
Merge branch 'userpage' into dev
mydearxymbbda464
fix(user reputation): fix reputation calc by refactor
mydearxym1451208
refactor(contents reaction): block favorite action from react contents
mydearxymadde568
Merge branch 'userpage' into dev
mydearxymc885767
test(favrotie reaction tests): removed, use favroted category instead
mydearxym4e27a43
feat(user published): publisehd comments
mydearxym68488e7
refactor(comments): extract comments macro
mydearxym7ec06a9
chore: cleanup warnings
mydearxymeac987a
refactor(published comments): support parent content info
mydearxymade4a93
Merge branch 'published' into dev
mydearxym49c4590
fix(cms passport): return empty instead of nil
mydearxym8d62d88
feat(comments): add comemntsCount for job/video/repo
mydearxym5513c76
fix: missing tags
mydearxym046255d
Merge branch 'auth' into dev
mydearxym10ce7d0
feat(reactions): repo favorite with basic test
mydearxymb97ae50
test(reactions): more test & doc for repo-favorite
mydearxymc20a171
chore(cleanup): rm wip tags
mydearxym7a16b4b
Merge branch 'reactions' into dev
mydearxymcd668d3
test(repo reaction): remove unneed tests on favroites
mydearxym392b7f5
Merge branch 'reactions' into dev
mydearxym752af96
feat(comments): comments participators for other
mydearxym723ff2b
Merge branch 'comments' into dev
mydearxymca87c12
feat(cms repo): add missing favorite fields
mydearxym4c46c88
Merge branch 'reactions' into dev
mydearxym8529c04
chore(clean up): wip tag
mydearxym89448da
chore(docs): comments dataloader
mydearxyme059058
Merge branch 'comments' into dev
mydearxym8bd0761
refactor(comments): add paged participators
mydearxymd18e0fe
Merge branch 'comments' into dev
mydearxym0e319b4
test: missing fields
mydearxym68020fd
fix(follow choas): follow / undofollow done right
mydearxym00d7783
chore(clean up): test file warnings
mydearxymac8c503
test(favoreted repos): add missing test for f-repos
mydearxym14f14bc
refactor(cms repos): rename last_fetch_time -> last_sync
mydearxym29d508a
Merge branch 'repo' into dev
mydearxym3e8990c
fix(repo favrote): totalCount query
mydearxym87b9ba5
feat(user): add views field
mydearxym327c3ef
feat(posts): add copy_right fields
mydearxym90056bf
fix: missing copy_right field
mydearxym9e7d122
Merge branch 'userpage' into dev
mydearxymb64f9f5
feat(viewers): add viewer_has_viewed to posts
mydearxymd149449
feat(has_viewed): add for jobs
mydearxymb428bc8
feat(viewer_has_viewed): for videos
mydearxym9dcbb1f
feat(viewer_has_viewd): for repos
mydearxym9a12b5f
chore(clean up): wip tags
mydearxymfefb700
Merge branch 'content-viewer' into dev
mydearxym8902126
fix(contents viewer): add edge case to test dataloader
mydearxyma2259ae
Merge branch 'content-viewer' into dev
mydearxymc209f34
refactor(tests): improve with multi argss
mydearxymee761e8
feat(job): simplify job atts, old one is complex
mydearxym610722e
Merge branch 'jobs' into dev
mydearxym455edf2
fix(job): missing fields
mydearxym4f29efa
fix(graphql parse error): fix graphql error crash server
mydearxym3be43da
fix(job create): clean up & refactor
mydearxym70cdfb1
Merge branch 'jobs' into dev
mydearxym8e55f30
feat(topic): basic topic concept
mydearxym1747494
refactor(topic on posts): impl topic & test only on posts
mydearxym0024269
feat(tags): add topic support
mydearxym63ed78a
chore(clean up): wip tag
mydearxymf5d630c
Merge branch 'topic' into dev
mydearxym3867185
fix(topic): default args error when topic create
mydearxym5e2a0b4
refactor(general): make thread & topic downcase in db
mydearxyme68b08b
fix(passport): community check use raw, not title
mydearxym9697c41
refactor(topic): change default topic to posts
mydearxymd6510de
chore(clean up): wip tag
mydearxymcba7826
refactor(accounts): make inline-subcommunities return paged-version
mydearxym73159f5
refactor(account): remove account endpoint, use general user
mydearxym87d00c7
fix(subscribed community): mismatch cur_user
mydearxym6b938c6
fix: remote ip mismatch
mydearxymf898726
Merge branch 'topic' into dev
mydearxym954381f
feat(content counts): add & refactor cms contents count
mydearxym2858be7
chore(clean up): warnings
mydearxym43861e6
Merge branch 'totalCount' into dev
mydearxymeb29d67
refactor(pin contents): use seperate table to pin contens
mydearxym83926cc
refactor: reduce boil-code
mydearxymc02d827
refactor(pined contents): remove old pin state from communityFlags
mydearxyma820979
chore(clean up): wip tags
mydearxym6756e7c
Merge branch 'flags' into dev
mydearxym32c6e2f
refactor(customization): basic set/get workflow
mydearxym3260a71
Merge branch 'customization' into dev
mydearxym05058d2
fix(c11n): filter nil when user has no c11n & clean up
mydearxym725d403
Merge branch 'customization' into dev
mydearxym448a2fd
chore(deps): bump sentry from 6.4.1 to 7.0.2
dependabot-supportFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletionsMakefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletionsMakefile.include.mk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionREADME.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletionsconfig/config.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Binary file modifieddeploy/production/api_server.tar.gz
Binary file not shown.
85 changes: 85 additions & 0 deletionslib/helper/PublicIpPlug.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# https://www.cogini.com/blog/getting-the-client-public-ip-address-in-phoenix/ | ||
defmodule Helper.PublicIpPlug do | ||
@moduledoc "Get public IP address of request from x-forwarded-for header" | ||
@behaviour Plug | ||
@app :mastani_server | ||
def init(opts), do: opts | ||
def call(%{assigns: %{ip: _}} = conn, _opts), do: conn | ||
def call(conn, _opts) do | ||
process(conn, Plug.Conn.get_req_header(conn, "x-forwarded-for")) | ||
end | ||
def process(conn, []) do | ||
Plug.Conn.assign(conn, :ip, to_string(:inet.ntoa(get_peer_ip(conn)))) | ||
end | ||
def process(conn, vals) do | ||
if Application.get_env(@app, :trust_x_forwarded_for, false) do | ||
ip_address = get_ip_address(conn, vals) | ||
# Rewrite standard remote_ip field with value from header | ||
# See https://hexdocs.pm/plug/Plug.Conn.html | ||
conn = %{conn | remote_ip: ip_address} | ||
Plug.Conn.assign(conn, :ip, to_string(:inet.ntoa(ip_address))) | ||
else | ||
Plug.Conn.assign(conn, :ip, to_string(:inet.ntoa(get_peer_ip(conn)))) | ||
end | ||
end | ||
defp get_ip_address(conn, vals) | ||
defp get_ip_address(conn, []), do: get_peer_ip(conn) | ||
defp get_ip_address(conn, [val | _]) do | ||
# Split into multiple values | ||
comps = | ||
val | ||
|> String.split(~r{\s*,\s*}, trim: true) | ||
# Get rid of "unknown" values | ||
|> Enum.filter(&(&1 != "unknown")) | ||
# Split IP from port, if any | ||
|> Enum.map(&hd(String.split(&1, ":"))) | ||
# Filter out blanks | ||
|> Enum.filter(&(&1 != "")) | ||
# Parse address into :inet.ip_address tuple | ||
|> Enum.map(&parse_address(&1)) | ||
# Elminate internal IP addreses, e.g. 192.168.1.1 | ||
|> Enum.filter(&is_public_ip(&1)) | ||
case comps do | ||
[] -> get_peer_ip(conn) | ||
[comp | _] -> comp | ||
end | ||
end | ||
@spec get_peer_ip(Plug.Conn.t()) :: :inet.ip_address() | ||
defp get_peer_ip(conn) do | ||
{ip, _port} = conn.peer | ||
ip | ||
end | ||
@spec parse_address(String.t()) :: :inet.ip_address() | ||
defp parse_address(ip) do | ||
case :inet.parse_ipv4strict_address(to_charlist(ip)) do | ||
{:ok, ip_address} -> ip_address | ||
{:error, :einval} -> :einval | ||
end | ||
end | ||
# Whether the input is a valid, public IP address | ||
# http://en.wikipedia.org/wiki/Private_network | ||
@spec is_public_ip(:inet.ip_address() | atom) :: boolean | ||
defp is_public_ip(ip_address) do | ||
case ip_address do | ||
{10, _, _, _} -> false | ||
{192, 168, _, _} -> false | ||
{172, second, _, _} when second >= 16 and second <= 31 -> false | ||
{127, 0, 0, _} -> false | ||
{_, _, _, _} -> true | ||
:einval -> false | ||
end | ||
end | ||
end |
32 changes: 32 additions & 0 deletionslib/helper/query_builder.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletionslib/helper/radar_search.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
defmodule Helper.RadarSearch do | ||
@moduledoc """ | ||
find city info by ip | ||
refer: https://lbs.amap.com/api/webservice/guide/api/ipconfig/?sug_index=0 | ||
""" | ||
use Tesla, only: [:get] | ||
import Helper.Utils, only: [get_config: 2] | ||
@endpoint "https://restapi.amap.com/v3/ip" | ||
@ip_service_key get_config(:radar_search, :ip_service) | ||
@timeout_limit 5000 | ||
# plug(Tesla.Middleware.BaseUrl, "https://restapi.amap.com/v3/ip") | ||
plug(Tesla.Middleware.Retry, delay: 200, max_retries: 2) | ||
plug(Tesla.Middleware.Timeout, timeout: @timeout_limit) | ||
plug(Tesla.Middleware.JSON) | ||
@doc """ | ||
this is only match fail situation in test | ||
""" | ||
def locate_city(ip \\ "14.196.0.0") | ||
def locate_city(:fake_ip) do | ||
{:error, "not found"} | ||
end | ||
# http://ip.yqie.com/search.aspx?searchword=%E6%88%90%E9%83%BD%E5%B8%82 | ||
def locate_city(ip) do | ||
query = [ip: ip, key: @ip_service_key] | ||
with true <- Mix.env() !== :test do | ||
case get(@endpoint, query: query) do | ||
%{status: 200, body: body} -> | ||
handle_result({:ok, body["city"]}) | ||
_ -> | ||
{:error, "error"} | ||
end | ||
else | ||
_ -> | ||
{:ok, "成都"} | ||
# {:error, "error"} | ||
end | ||
end | ||
defp handle_result({:ok, result}) do | ||
case result do | ||
[] -> {:error, "not found"} | ||
_ -> cut_tail({:ok, result}) | ||
end | ||
end | ||
defp cut_tail({:ok, result}) do | ||
case String.last(result) == "市" do | ||
true -> {:ok, String.trim_trailing(result, "市")} | ||
false -> {:ok, result} | ||
end | ||
end | ||
end |
72 changes: 66 additions & 6 deletionslib/helper/utils.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.