Skip to content

Commit

Permalink
Merge pull request #897 from traPtitech/chores
Browse files Browse the repository at this point in the history
Chores
  • Loading branch information
wtks authored May 8, 2020
2 parents 83e1510 + bb2426e commit b8b7d81
Show file tree
Hide file tree
Showing 30 changed files with 164 additions and 709 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-gomod-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gomod-
- run: go mod download
build:
name: Build
Expand Down Expand Up @@ -148,7 +146,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Spectral checks
uses: stoplightio/spectral-action@v0.5.5
uses: stoplightio/spectral-action@v0.6.1
with:
file_glob: docs/*.yaml
file_glob: docs/v3-api.yaml
repo_token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions cmd/migrate_v2_to_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func convertMessages(db *gorm.DB, logger *zap.Logger, dryRun bool, startMessageP
converted += strings.Join(links, "\n")

if !dryRun {
s.Acquire(context.Background(), 1)
_ = s.Acquire(context.Background(), 1)
defer s.Release(1)

err := db.Transaction(func(tx *gorm.DB) error {
Expand Down Expand Up @@ -238,7 +238,7 @@ func linkFileToChannel(db *gorm.DB, logger *zap.Logger, dryRun bool, startFilePa
}

wg.Add(1)
s.Acquire(context.Background(), 1)
_ = s.Acquire(context.Background(), 1)
go func(file *model.File) {
defer wg.Done()
defer s.Release(1)
Expand Down
17 changes: 8 additions & 9 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,15 @@ func Execute() error {
func getLogger() (logger *zap.Logger) {
if c.DevMode {
return getCLILogger()
} else {
cfg := zap.Config{
Level: zap.NewAtomicLevelAt(zapcore.InfoLevel),
Encoding: "json",
EncoderConfig: zapdriver.NewProductionEncoderConfig(),
OutputPaths: []string{"stdout"},
ErrorOutputPaths: []string{"stderr"},
}
logger, _ = cfg.Build(zapdriver.WrapCore(zapdriver.ServiceName("traq", fmt.Sprintf("%s.%s", Version, Revision))))
}
cfg := zap.Config{
Level: zap.NewAtomicLevelAt(zapcore.InfoLevel),
Encoding: "json",
EncoderConfig: zapdriver.NewProductionEncoderConfig(),
OutputPaths: []string{"stdout"},
ErrorOutputPaths: []string{"stderr"},
}
logger, _ = cfg.Build(zapdriver.WrapCore(zapdriver.ServiceName("traq", fmt.Sprintf("%s.%s", Version, Revision))))
return
}

Expand Down
12 changes: 6 additions & 6 deletions cmd/stamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const (
twemoji Copyright 2019 Twitter, Inc and other contributors
Graphics licensed under CC-BY 4.0: https://creativecommons.org/licenses/by/4.0/
*/
emojiZipUrl = "https://github.com/twitter/twemoji/archive/v12.1.5.zip"
emojiZipURL = "https://github.com/twitter/twemoji/archive/v12.1.5.zip"
emojiDir = "twemoji-12.1.5/assets/svg/"
emojiMetaUrl = "https://raw.githubusercontent.com/emojione/emojione/master/emoji.json"
emojiMetaURL = "https://raw.githubusercontent.com/emojione/emojione/master/emoji.json"
)

type emojiMeta struct {
Expand Down Expand Up @@ -102,15 +102,15 @@ func stampInstallEmojisCommand() *cobra.Command {

func installEmojis(repo repository.Repository, logger *zap.Logger, update bool) error {
// 絵文字メタデータをダウンロード
logger.Info("downloading meta data...: " + emojiMetaUrl)
logger.Info("downloading meta data...: " + emojiMetaURL)
emojis, err := downloadEmojiMeta()
if err != nil {
return err
}
logger.Info("finished downloading meta data")

// 絵文字画像データをダウンロード
logger.Info("downloading twemoji...: " + emojiZipUrl)
logger.Info("downloading twemoji...: " + emojiZipURL)
twemojiZip, err := downloadEmojiZip()
if err != nil {
return err
Expand Down Expand Up @@ -209,7 +209,7 @@ func installEmojis(repo repository.Repository, logger *zap.Logger, update bool)
}

func downloadEmojiZip() (*bytes.Reader, error) {
res, err := http.Get(emojiZipUrl)
res, err := http.Get(emojiZipURL)
if err != nil {
return nil, err
}
Expand All @@ -220,7 +220,7 @@ func downloadEmojiZip() (*bytes.Reader, error) {
}

func downloadEmojiMeta() (map[string]*emojiMeta, error) {
res, err := http.Get(emojiMetaUrl)
res, err := http.Get(emojiMetaURL)
if err != nil {
return nil, err
}
Expand Down
151 changes: 15 additions & 136 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1033,17 +1033,10 @@ paths:
tags:
- pin
operationId: getPinnedMessages
description: チャンネルのピン留め一覧を取得します。
security:
- traqOAuth2:
- read
description: このAPIは削除されました
responses:
'200':
description: 正常に取得できました。
content:
application/json:
schema:
$ref: '#/components/schemas/PinList'
'410':
description: このAPIは削除されました
'/channels/{channelID}/topic':
parameters:
- $ref: '#/components/parameters/channelIdInPath'
Expand Down Expand Up @@ -1659,23 +1652,10 @@ paths:
tags:
- pin
operationId: pinMessage
description: チャンネルにメッセージをピン留めします。
security:
- traqOAuth2:
- write
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/MessageIDObject'
description: このAPIは削除されました
responses:
'201':
description: 正常にピン留めできました。
content:
application/json:
schema:
$ref: '#/components/schemas/PinIDObject'
'410':
description: このAPIは削除されました
'/pins/{pinID}':
parameters:
- $ref: '#/components/parameters/pinIdInPath'
Expand All @@ -1684,31 +1664,19 @@ paths:
tags:
- pin
operationId: getPinnedMessage
description: ピン留めを取得します。
security:
- traqOAuth2:
- read
description: このAPIは削除されました
responses:
'200':
description: 正常に取得できました。
content:
application/json:
schema:
$ref: '#/components/schemas/Pin'
'410':
description: このAPIは削除されました
delete:
deprecated: true
tags:
- pin
operationId: unpinMessage
description: ピン留めを外します。
security:
- traqOAuth2:
- write
description: このAPIは削除されました
responses:
'204':
description: 正常に外せました。
'404':
description: '+| 指定したIDのピンは存在しません。'
'410':
description: このAPIは削除されました
/stamps:
get:
tags:
Expand Down Expand Up @@ -2037,21 +2005,10 @@ paths:
tags:
- webhook
operationId: postGitHubWebhook
description: Github-Compatibleなwebhookを送信します。
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
description: このAPIは削除されました
responses:
'204':
description: 正常に送信できました。
'400':
description: 正常に送信できませんでした。リクエスト内容が不正です。
'404':
description: 正常に送信できませんでした。指定されたwebhookは存在しません。
'410':
description: このAPIは削除されました
/groups:
get:
deprecated: true
Expand Down Expand Up @@ -3427,15 +3384,6 @@ components:
type: string
description: Markdown形式のメッセージ本文
example: Raskって誰?
MessageIDObject:
type: object
required:
- messageId
properties:
messageId:
type: string
format: uuid
description: ピン留めするメッセージID
MessageStamp:
type: object
properties:
Expand Down Expand Up @@ -3469,38 +3417,6 @@ components:
minimum: 1
default: 1
example: 1
Pin:
type: object
properties:
pinId:
type: string
format: uuid
description: ピンUUID
channelId:
type: string
format: uuid
description: チャンネルUUID
userId:
type: string
format: uuid
description: ピン留めしたユーザーのUUID
dateTime:
type: string
format: date-time
description: ピン留めした日時
message:
$ref: '#/components/schemas/Message'
PinList:
type: array
items:
$ref: '#/components/schemas/Pin'
PinIDObject:
type: object
properties:
id:
type: string
format: uuid
description: ピンID
NotificationUsers:
type: object
properties:
Expand Down Expand Up @@ -4186,43 +4102,6 @@ components:
format: uuid
description: チャンネルUUID
description: ChildCreated
WebRTCUserState:
type: object
properties:
userId:
type: string
format: uuid
description: ユーザーUUID
channelId:
type: string
format: uuid
description: ユーザーの接続先チャンネルUUID(未接続の場合は00000000-0000-0000-0000-000000000000)
state:
type: array
items:
type: string
description: ユーザーの状態の配列(未接続の場合は空配列)
WebRTCChannelState:
type: object
properties:
users:
type: array
items:
$ref: '#/components/schemas/WebRTCUserState'
description: 接続ユーザーの状態の配列
PutWebRTCState:
type: object
properties:
channelId:
type: string
format: uuid
nullable: true
description: ユーザーの接続先チャンネルUUID(切断はnullを指定)
state:
type: array
items:
type: string
description: ユーザーの状態の配列(切断は空配列を指定)
ChannelStats:
type: object
properties:
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ require (
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
google.golang.org/api v0.23.0
gopkg.in/go-playground/webhooks.v5 v5.13.0
gopkg.in/gormigrate.v1 v1.6.0
gopkg.in/ini.v1 v1.51.1 // indirect
gopkg.in/square/go-jose.v2 v2.4.1 // indirect
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12 h1:TgXhFz35pKlZuUz1pN
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3 h1:SRgJV+IoxM5MKyFdlSUeNy6/ycRUF2yBAKdAQswoHUk=
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d h1:iaAPcMIY2f+gpk8tKf0BMW5sLrlhaASiYAnFmvVG5e0=
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/googleapis/gax-go/v2 v2.0.4 h1:hU4mGcQI4DaAYW+IbTun+2qEZVFxK0ySjQLTbS0VQKc=
Expand Down Expand Up @@ -549,6 +550,7 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 h1:WQ8q63x+f/zpC8Ac1s9wLElVoHhm32p6tudrU72n1QA=
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421 h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI=
Expand Down Expand Up @@ -606,6 +608,7 @@ golang.org/x/sys v0.0.0-20200331124033-c3d80250170d h1:nc5K6ox/4lTFbMVSL9WRR81ix
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f h1:gWF768j/LaZugp8dyS4UwsslYCYz9XgFxvlgsn0n9H8=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e h1:hq86ru83GdWTlfQFZGO4nZJTU4Bs2wfHl8oFHRaXsfc=
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
Expand Down Expand Up @@ -692,6 +695,7 @@ google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5 h1:tycE03LOZYQNhDpS27tcQdAzLCVMaj7QT2SXxebnpCM=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
Expand All @@ -715,6 +719,7 @@ google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfG
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940 h1:MRHtG0U6SnaUb+s+LhNE1qt1FQ1wlhqr5E4usBKC0uA=
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84 h1:pSLkPbrjnPyLDYUO2VM9mDLqo2V6CFBY84lFSZAfoi4=
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/grpc v1.19.0 h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
Expand All @@ -732,6 +737,7 @@ google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk=
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.28.0 h1:bO/TA4OxCOummhSf10siHuG7vJOiwh7SpRpFZDkOgl4=
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
google.golang.org/grpc v1.29.1 h1:EC2SB8S04d2r73uptxphDSUG+kTKVgjRPF+N3xpxRB4=
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand All @@ -748,8 +754,6 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/go-playground/webhooks.v5 v5.13.0 h1:e9vtkQZK464+UdL3YjRox2yR8JSmh2094PUBMvdriFs=
gopkg.in/go-playground/webhooks.v5 v5.13.0/go.mod h1:LZbya/qLVdbqDR1aKrGuWV6qbia2zCYSR5dpom2SInQ=
gopkg.in/gormigrate.v1 v1.6.0 h1:XpYM6RHQPmzwY7Uyu+t+xxMXc86JYFJn4nEc9HzQjsI=
gopkg.in/gormigrate.v1 v1.6.0/go.mod h1:Lf00lQrHqfSYWiTtPcyQabsDdM6ejZaMgV0OU6JMSlw=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
Expand Down
4 changes: 2 additions & 2 deletions notification/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,11 @@ func stampPaletteDeletedHandler(ns *Service, ev hub.Message) {
func userWebRTCv3StateChangedHandler(ns *Service, ev hub.Message) {
type StateSession struct {
State string `json:"state"`
SessionId string `json:"sessionId"`
SessionID string `json:"sessionId"`
}
sessions := make([]StateSession, 0)
for session, state := range ev.Fields["sessions"].(map[string]string) {
sessions = append(sessions, StateSession{State: state, SessionId: session})
sessions = append(sessions, StateSession{State: state, SessionID: session})
}

go ns.ws.WriteMessage("USER_WEBRTC_STATE_CHANGED", map[string]interface{}{
Expand Down
Loading

0 comments on commit b8b7d81

Please sign in to comment.