مراية لـ
https://github.com/postalserver/postal.git
تم المزامنة 2026-03-04 06:44:06 +00:00
Compare commits
9 الالتزامات
| المؤلف | SHA1 | التاريخ | |
|---|---|---|---|
|
|
da90e75036 | ||
|
|
2b0919c145 | ||
|
|
3a33e53d84 | ||
|
|
4fa88acea0 | ||
|
|
d510499190 | ||
|
|
39f704c256 | ||
|
|
c12f30e300 | ||
|
|
5a2f31ed77 | ||
|
|
07c6b317f2 |
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
".": "3.3.1"
|
".": "3.3.4"
|
||||||
}
|
}
|
||||||
|
|||||||
23
CHANGELOG.md
23
CHANGELOG.md
@@ -2,6 +2,29 @@
|
|||||||
|
|
||||||
This file contains all the latest changes and updates to Postal.
|
This file contains all the latest changes and updates to Postal.
|
||||||
|
|
||||||
|
## [3.3.4](https://github.com/postalserver/postal/compare/3.3.3...3.3.4) (2024-06-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix `postal version` command ([4fa88ac](https://github.com/postalserver/postal/commit/4fa88acea0dececd0eae485506a2ad8268fbea59))
|
||||||
|
* fix issue running message pruning task ([3a33e53](https://github.com/postalserver/postal/commit/3a33e53d843584757bb00898746aa059d7616db4))
|
||||||
|
* raise NotImplementedError when no call method on a scheduled task ([2b0919c](https://github.com/postalserver/postal/commit/2b0919c1454eabea93db96f50ecbd8e36bb89f1f))
|
||||||
|
|
||||||
|
## [3.3.3](https://github.com/postalserver/postal/compare/3.3.2...3.3.3) (2024-04-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **legacy-api:** allow _expansions to be provided as true to return all expansions ([39f704c](https://github.com/postalserver/postal/commit/39f704c256fc3e71a1dc009acc77796a1efffead)), closes [#2932](https://github.com/postalserver/postal/issues/2932)
|
||||||
|
|
||||||
|
## [3.3.2](https://github.com/postalserver/postal/compare/3.3.1...3.3.2) (2024-03-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Code Refactoring
|
||||||
|
|
||||||
|
* **versioning:** improve how current version and branch is determined and set ([07c6b31](https://github.com/postalserver/postal/commit/07c6b317f2b9dc04b6a8c88df1e6aa9e54597504))
|
||||||
|
|
||||||
## [3.3.1](https://github.com/postalserver/postal/compare/3.3.0...3.3.1) (2024-03-21)
|
## [3.3.1](https://github.com/postalserver/postal/compare/3.3.0...3.3.1) (2024-03-21)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ COPY ./docker/wait-for.sh /docker-entrypoint.sh
|
|||||||
COPY --chown=postal . .
|
COPY --chown=postal . .
|
||||||
|
|
||||||
# Export the version
|
# Export the version
|
||||||
ARG VERSION=null
|
ARG VERSION
|
||||||
ARG BRANCH=null
|
ARG BRANCH
|
||||||
RUN echo $VERSION > VERSION \
|
RUN if [ "$VERSION" != "" ]; then echo $VERSION > VERSION; fi \
|
||||||
&& echo $BRANCH > BRANCH
|
&& if [ "$BRANCH" != "" ]; then echo $BRANCH > BRANCH; fi
|
||||||
|
|
||||||
# Set paths for when running in a container
|
# Set paths for when running in a container
|
||||||
ENV POSTAL_CONFIG_FILE_PATH=/config/postal.yml
|
ENV POSTAL_CONFIG_FILE_PATH=/config/postal.yml
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ module LegacyAPI
|
|||||||
message_hash = { id: message.id, token: message.token }
|
message_hash = { id: message.id, token: message.token }
|
||||||
expansions = api_params["_expansions"]
|
expansions = api_params["_expansions"]
|
||||||
|
|
||||||
if expansions.include?("status")
|
if expansions == true || (expansions.is_a?(Array) && expansions.include?("status"))
|
||||||
message_hash[:status] = {
|
message_hash[:status] = {
|
||||||
status: message.status,
|
status: message.status,
|
||||||
last_delivery_attempt: message.last_delivery_attempt&.to_f,
|
last_delivery_attempt: message.last_delivery_attempt&.to_f,
|
||||||
@@ -33,7 +33,7 @@ module LegacyAPI
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if expansions.include?("details")
|
if expansions == true || (expansions.is_a?(Array) && expansions.include?("details"))
|
||||||
message_hash[:details] = {
|
message_hash[:details] = {
|
||||||
rcpt_to: message.rcpt_to,
|
rcpt_to: message.rcpt_to,
|
||||||
mail_from: message.mail_from,
|
mail_from: message.mail_from,
|
||||||
@@ -49,7 +49,7 @@ module LegacyAPI
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if expansions.include?("inspection")
|
if expansions == true || (expansions.is_a?(Array) && expansions.include?("inspection"))
|
||||||
message_hash[:inspection] = {
|
message_hash[:inspection] = {
|
||||||
inspected: message.inspected,
|
inspected: message.inspected,
|
||||||
spam: message.spam,
|
spam: message.spam,
|
||||||
@@ -59,15 +59,15 @@ module LegacyAPI
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if expansions.include?("plain_body")
|
if expansions == true || (expansions.is_a?(Array) && expansions.include?("plain_body"))
|
||||||
message_hash[:plain_body] = message.plain_body
|
message_hash[:plain_body] = message.plain_body
|
||||||
end
|
end
|
||||||
|
|
||||||
if expansions.include?("html_body")
|
if expansions == true || (expansions.is_a?(Array) && expansions.include?("html_body"))
|
||||||
message_hash[:html_body] = message.html_body
|
message_hash[:html_body] = message.html_body
|
||||||
end
|
end
|
||||||
|
|
||||||
if expansions.include?("attachments")
|
if expansions == true || (expansions.is_a?(Array) && expansions.include?("attachments"))
|
||||||
message_hash[:attachments] = message.attachments.map do |attachment|
|
message_hash[:attachments] = message.attachments.map do |attachment|
|
||||||
{
|
{
|
||||||
filename: attachment.filename.to_s,
|
filename: attachment.filename.to_s,
|
||||||
@@ -79,15 +79,15 @@ module LegacyAPI
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if expansions.include?("headers")
|
if expansions == true || (expansions.is_a?(Array) && expansions.include?("headers"))
|
||||||
message_hash[:headers] = message.headers
|
message_hash[:headers] = message.headers
|
||||||
end
|
end
|
||||||
|
|
||||||
if expansions.include?("raw_message")
|
if expansions == true || (expansions.is_a?(Array) && expansions.include?("raw_message"))
|
||||||
message_hash[:raw_message] = Base64.encode64(message.raw_message)
|
message_hash[:raw_message] = Base64.encode64(message.raw_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
if expansions.include?("activity_entries")
|
if expansions == true || (expansions.is_a?(Array) && expansions.include?("activity_entries"))
|
||||||
message_hash[:activity_entries] = {
|
message_hash[:activity_entries] = {
|
||||||
loads: message.loads,
|
loads: message.loads,
|
||||||
clicks: message.clicks
|
clicks: message.clicks
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class ApplicationScheduledTask
|
|||||||
end
|
end
|
||||||
|
|
||||||
def call
|
def call
|
||||||
# override me
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :logger
|
attr_reader :logger
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
class ProcessMessageRetentionScheduledTask < ApplicationScheduledTask
|
class ProcessMessageRetentionScheduledTask < ApplicationScheduledTask
|
||||||
|
|
||||||
def perform
|
def call
|
||||||
Server.all.each do |server|
|
Server.all.each do |server|
|
||||||
if server.raw_message_retention_days
|
if server.raw_message_retention_days
|
||||||
# If the server has a maximum number of retained raw messages, remove any that are older than this
|
# If the server has a maximum number of retained raw messages, remove any that are older than this
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ require "dotenv"
|
|||||||
require "klogger"
|
require "klogger"
|
||||||
|
|
||||||
require_relative "error"
|
require_relative "error"
|
||||||
require_relative "version"
|
|
||||||
require_relative "config_schema"
|
require_relative "config_schema"
|
||||||
require_relative "legacy_config_source"
|
require_relative "legacy_config_source"
|
||||||
require_relative "signer"
|
require_relative "signer"
|
||||||
@@ -131,7 +130,7 @@ module Postal
|
|||||||
notifier.notify!(short_message: short_message, **{
|
notifier.notify!(short_message: short_message, **{
|
||||||
facility: Config.gelf.facility,
|
facility: Config.gelf.facility,
|
||||||
_environment: Config.rails.environment,
|
_environment: Config.rails.environment,
|
||||||
_version: Postal::VERSION.to_s,
|
_version: Postal.version.to_s,
|
||||||
_group_ids: group_ids.join(" ")
|
_group_ids: group_ids.join(" ")
|
||||||
}.merge(payload.transform_keys { |k| "_#{k}".to_sym }.transform_values(&:to_s)))
|
}.merge(payload.transform_keys { |k| "_#{k}".to_sym }.transform_values(&:to_s)))
|
||||||
end
|
end
|
||||||
@@ -146,7 +145,7 @@ module Postal
|
|||||||
ActiveRecord::Base.connection_pool.disconnect!
|
ActiveRecord::Base.connection_pool.disconnect!
|
||||||
|
|
||||||
config = ActiveRecord::Base.configurations
|
config = ActiveRecord::Base.configurations
|
||||||
.configs_for(env_name: Rails.env)
|
.configs_for(env_name: Config.rails.environment)
|
||||||
.first
|
.first
|
||||||
.configuration_hash
|
.configuration_hash
|
||||||
|
|
||||||
@@ -159,10 +158,26 @@ module Postal
|
|||||||
def branch
|
def branch
|
||||||
return @branch if instance_variable_defined?("@branch")
|
return @branch if instance_variable_defined?("@branch")
|
||||||
|
|
||||||
@branch = begin
|
@branch ||= read_version_file("BRANCH")
|
||||||
path = Rails.root.join("BRANCH")
|
end
|
||||||
File.read(path).strip if File.exist?(path)
|
|
||||||
end
|
# Return the version
|
||||||
|
#
|
||||||
|
# @return [String, nil]
|
||||||
|
def version
|
||||||
|
return @version if instance_variable_defined?("@version")
|
||||||
|
|
||||||
|
@version ||= read_version_file("VERSION") || "0.0.0"
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def read_version_file(file)
|
||||||
|
path = File.expand_path("../../../" + file, __FILE__)
|
||||||
|
return unless File.exist?(path)
|
||||||
|
|
||||||
|
value = File.read(path).strip
|
||||||
|
value.empty? ? nil : value
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
module Postal
|
|
||||||
|
|
||||||
VERSION_PATH = File.expand_path("../../VERSION", __dir__)
|
|
||||||
if File.file?(VERSION_PATH)
|
|
||||||
VERSION = File.read(VERSION_PATH).strip.delete_prefix("v")
|
|
||||||
else
|
|
||||||
VERSION = "0.0.0-dev"
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.version
|
|
||||||
VERSION
|
|
||||||
end
|
|
||||||
|
|
||||||
Version = VERSION
|
|
||||||
|
|
||||||
end
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require File.expand_path("../lib/postal/version", __dir__)
|
require File.expand_path("../lib/postal/config", __dir__)
|
||||||
puts Postal.version
|
puts Postal.version
|
||||||
|
|||||||
@@ -88,6 +88,49 @@ RSpec.describe "Legacy Messages API", type: :request do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when all expansions are requested" do
|
||||||
|
let(:expansions) { true }
|
||||||
|
|
||||||
|
it "returns details about the message" do
|
||||||
|
expect(response.status).to eq 200
|
||||||
|
parsed_body = JSON.parse(response.body)
|
||||||
|
expect(parsed_body["status"]).to eq "success"
|
||||||
|
expect(parsed_body["data"]).to match({
|
||||||
|
"id" => message.id,
|
||||||
|
"token" => message.token,
|
||||||
|
"status" => { "held" => false,
|
||||||
|
"hold_expiry" => nil,
|
||||||
|
"last_delivery_attempt" => nil,
|
||||||
|
"status" => "Pending" },
|
||||||
|
"details" => { "bounce" => false,
|
||||||
|
"bounce_for_id" => 0,
|
||||||
|
"direction" => "outgoing",
|
||||||
|
"mail_from" => "test@example.com",
|
||||||
|
"message_id" => message.message_id,
|
||||||
|
"rcpt_to" => "john@example.com",
|
||||||
|
"received_with_ssl" => nil,
|
||||||
|
"size" => kind_of(String),
|
||||||
|
"subject" => "An example message",
|
||||||
|
"tag" => nil,
|
||||||
|
"timestamp" => kind_of(Float) },
|
||||||
|
"inspection" => { "inspected" => false,
|
||||||
|
"spam" => false,
|
||||||
|
"spam_score" => 0.0,
|
||||||
|
"threat" => false,
|
||||||
|
"threat_details" => nil },
|
||||||
|
"plain_body" => message.plain_body,
|
||||||
|
"html_body" => message.html_body,
|
||||||
|
"attachments" => [],
|
||||||
|
"headers" => message.headers,
|
||||||
|
"raw_message" => Base64.encode64(message.raw_message),
|
||||||
|
"activity_entries" => {
|
||||||
|
"loads" => [],
|
||||||
|
"clicks" => []
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "when the status expansion is requested" do
|
context "when the status expansion is requested" do
|
||||||
let(:expansions) { ["status"] }
|
let(:expansions) { ["status"] }
|
||||||
|
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم